Skip to content
This repository was archived by the owner on Aug 24, 2025. It is now read-only.

Feat/home page#16

Merged
ditto-11 merged 3 commits into
mainfrom
feat/home-page
Jun 20, 2025
Merged

Feat/home page#16
ditto-11 merged 3 commits into
mainfrom
feat/home-page

Conversation

@ditto-11

@ditto-11 ditto-11 commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

Closes #9

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive dashboard home page with real-time user statistics, revenue and ticket reports, and interactive charts for visualizing data trends.
  • Style

    • Improved layout and visual presentation of the user list page by centering content, increasing vertical spacing, and applying a maximum width constraint.
  • Refactor

    • Updated the main landing page to automatically redirect users to the dashboard home page.

@ditto-11 ditto-11 requested a review from a team as a code owner June 20, 2025 21:22
@ditto-11 ditto-11 linked an issue Jun 20, 2025 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Jun 20, 2025

Copy link
Copy Markdown

Walkthrough

The Home page was rewritten as a functional dashboard, incorporating data fetching, aggregation, and visualization for users, revenue, and tickets using custom hooks and Chart.js. The root page now redirects to /home. Minor layout adjustments were made to the Users page container for improved centering and spacing.

Changes

File(s) Change Summary
src/app/(dashboard)/home/page.tsx Rewrote HomePage as a dashboard: fetches users, revenue, ticket data; computes stats; renders charts.
src/app/page.tsx Changed to immediately redirect to /home instead of rendering content.
src/app/(dashboard)/users/page.tsx Updated container class for horizontal centering, max width, and increased vertical spacing.

Sequence Diagram(s)

sequenceDiagram
    participant HomePage
    participant useUsers
    participant useRevenueTicket
    participant useReportTicket
    participant ChartJS

    HomePage->>useUsers: Fetch paginated user data
    HomePage->>useRevenueTicket: Fetch revenue data
    HomePage->>useReportTicket: Fetch ticket data
    useUsers-->>HomePage: Return user data & pagination
    useRevenueTicket-->>HomePage: Return revenue data
    useReportTicket-->>HomePage: Return ticket data

    HomePage->>HomePage: Aggregate and compute statistics
    HomePage->>ChartJS: Render Line and Pie charts with processed data
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement a web dashboard home page (#9)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

  • Feat/report #15: Introduced Chart.js and react-chartjs-2 dependencies, directly enabling the chart rendering in the dashboard implemented by this PR.

Poem

A dashboard blooms where plain text stood,
With charts and stats, as all good code should.
Users, revenue, tickets in view,
Graphs and pies in colors anew.
With data fetched and insights clear,
This home page brings the numbers near!
🐇📊✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-20T21_23_28_361Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/app/page.tsx (1)

3-5: Remove unnecessary async keyword

The function doesn't perform any asynchronous operations, so the async keyword is not needed.

-export default async function Page() {
+export default function Page() {
   redirect('/home');
 }
src/app/(dashboard)/home/page.tsx (1)

79-131: Consider splitting the data fetching logic for better maintainability

The current useEffect handles multiple data types in a single effect, making it complex to maintain and debug. Consider splitting into separate effects for each data type (users, revenue, tickets).

This would improve:

  • Code readability and maintainability
  • Easier debugging of specific data fetching issues
  • Independent error handling for each data type
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6c496f and d83f21a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • src/app/(dashboard)/home/page.tsx (1 hunks)
  • src/app/(dashboard)/users/page.tsx (1 hunks)
  • src/app/page.tsx (1 hunks)
🔇 Additional comments (1)
src/app/(dashboard)/users/page.tsx (1)

84-84: Good layout improvements!

The addition of horizontal centering and max-width constraint improves the visual consistency of the dashboard. The increased vertical spacing also enhances readability.


const { totalUsers, growthCount, growthPercentage, newUsersThisMonth } =
useMemo(() => {
const now = new Date('2025-06-21T03:50:00+07:00'); // Updated to current time

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace hard-coded dates with actual current date

Using hard-coded dates will cause incorrect calculations in production. The dashboard will show outdated statistics and charts.

Replace all instances with:

-const now = new Date('2025-06-21T03:50:00+07:00'); // Updated to current time
+const now = new Date();

Also applies to: 179-179, 245-245

🤖 Prompt for AI Agents
In src/app/(dashboard)/home/page.tsx at lines 135, 179, and 245, replace the
hard-coded date strings with dynamic calls to get the actual current date and
time using new Date() without arguments. This change ensures that the dashboard
calculations use the real current date instead of fixed past dates, preventing
outdated statistics and charts.

Comment on lines +257 to +261
const termLabel =
term === -1
? 'No Term'
: `${term / 30} Month${term / 30 > 1 ? 's' : ''}`;
acc[termLabel] = (acc[termLabel] || 0) + report.openedCount;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve ticket term calculation accuracy

The current implementation assumes all months have 30 days, which could lead to inaccurate term labels (e.g., "1.03 Months" for 31-day terms).

Consider using ranges or a more accurate calculation:

-const termLabel =
-  term === -1
-    ? 'No Term'
-    : `${term / 30} Month${term / 30 > 1 ? 's' : ''}`;
+const termLabel =
+  term === -1
+    ? 'No Term'
+    : term <= 30
+      ? '1 Month'
+      : term <= 90
+        ? '3 Months'
+        : term <= 180
+          ? '6 Months'
+          : `${Math.round(term / 30)} Months`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const termLabel =
term === -1
? 'No Term'
: `${term / 30} Month${term / 30 > 1 ? 's' : ''}`;
acc[termLabel] = (acc[termLabel] || 0) + report.openedCount;
const termLabel =
term === -1
? 'No Term'
: term <= 30
? '1 Month'
: term <= 90
? '3 Months'
: term <= 180
? '6 Months'
: `${Math.round(term / 30)} Months`;
acc[termLabel] = (acc[termLabel] || 0) + report.openedCount;
🤖 Prompt for AI Agents
In src/app/(dashboard)/home/page.tsx around lines 257 to 261, the term
calculation currently divides by 30 to convert days to months, which
inaccurately assumes all months have 30 days. To fix this, replace the direct
division with a range-based approach or use a more precise method to convert
days to months, such as mapping term values to predefined month ranges or using
a date library to calculate the exact month difference. Update the termLabel
logic accordingly to reflect these ranges or accurate calculations without
producing fractional months.

@ditto-11 ditto-11 merged commit f3aed27 into main Jun 20, 2025
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] home page

1 participant