Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: User Dashboard Implementation - Backend #134

Open
Juninhotech opened this issue Jul 27, 2024 · 0 comments
Open

[FEAT]: User Dashboard Implementation - Backend #134

Juninhotech opened this issue Jul 27, 2024 · 0 comments
Assignees

Comments

@Juninhotech
Copy link
Contributor

Juninhotech commented Jul 27, 2024

Description:

Implement a backend API endpoint to provide data for the user dashboard page, displaying key metrics and product sales data.

Acceptance Criteria (Backend):

  • API endpoint /api/v1/user_dashboard is implemented and accessible.
  • The endpoint returns a JSON response with the correct structure, including status, message, and data fields.
  • All required data points (totalRevenue, subscriptions, sales, activeUsers, monthlyRevenue, recentSales) are included in the response.

Features:

  • Total Revenue
  • Subscriptions
  • Sales
  • Active Users
  • Monthly revenue data
  • Recent Sales list

Purpose:

Create an API endpoint that returns all necessary data for the dashboard in a single request.

Proposed API Endpoint:

GET /api/v1/user_dashboard

Expected Response:

  • Status Code: 200 OK
  • Content-Type: application/json
  • Body:
    {
      "status": 200,
      "message": "Success",
      "data": {
        "overview": {
          "totalRevenue": 45000.00,
          "subscriptions": 2350,
          "sales": 15000,
          "activeUsers": 574
        },
        "monthlyRevenue": [
          { "month": "Jan", "revenue": 4500 },
          { "month": "Feb", "revenue": 3000 },
          { "month": "Mar", "revenue": 6000 },
          { "month": "Apr", "revenue": 3000 },
          { "month": "May", "revenue": 5500 },
          { "month": "Jun", "revenue": 2000 },
          { "month": "Jul", "revenue": 1000 },
          { "month": "Aug", "revenue": 1500 },
          { "month": "Sep", "revenue": 3000 },
          { "month": "Oct", "revenue": 500 },
          { "month": "Nov", "revenue": 200 },
          { "month": "Dec", "revenue": 4000 }
        ],
        "recentSales": [
          { "name": "Jackson Lee", "email": "[email protected]", "amount": 2999.00 },
          { "name": "Olivia Martin", "email": "[email protected]", "amount": 7999.00 },
          { "name": "Joseph Chernyesuck", "email": "[email protected]", "amount": 5999.00 },
          { "name": "Paul Halland", "email": "[email protected]", "amount": 12999.00 },
          { "name": "Eden Hazard", "email": "[email protected]", "amount": 3999.00 },
          { "name": "Ronaldo Messi", "email": "[email protected]", "amount": 4999.00 }
        ]
      }
    }

Handling Empty Lists:

If any list in the response is empty (e.g., no monthly revenue data or no recent sales), return an empty array for that field rather than omitting it. For example:

{
  "status": 200,
  "message": "Success",
  "data": {
    "overview": {
      "totalRevenue": 0,
      "subscriptions": 0,
      "sales": 0,
      "activeUsers": 0
    },
    "monthlyRevenue": [],
    "recentSales": []
  }
}

Unit Testing Requirements:

  • Implement comprehensive unit tests for the dashboard API. Tests should cover:
    • Ensure all required data points are present in the response.
    • Verify handling of extreme values (very large numbers, zero values).
    • Test calculation of total revenue, subscriptions, sales, and active users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant