Skip to content

Conversation

@ayaz9616
Copy link
Contributor

@ayaz9616 ayaz9616 commented Oct 24, 2025

Description

Adds an “Income by Category” chart to the Dashboard and a toggle to switch between Expense and Income category views. The backend now returns grouped income data, and the frontend reuses the pie chart component for both types.

Related Issue

Fixes #148

Motivation and Context

Provides users with a clear breakdown of income sources by category, matching the existing expense visualization for consistency and better financial planning.

Types of Changes

-New Feature

How Has This Been Tested?

  • Manually verified /api/transactions/charts returns incomeByCategory.
  • Dashboard toggle switches between Expense and Income charts.
  • Checked empty states and theme compatibility.

Screenshots (if applicable):

image image

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Copilot AI review requested due to automatic review settings October 24, 2025 17:28
@netlify
Copy link

netlify bot commented Oct 24, 2025

Deploy Preview for paisable ready!

Name Link
🔨 Latest commit 091c393
🔍 Latest deploy log https://app.netlify.com/projects/paisable/deploys/6904e1ba482c4f0007bb948e
😎 Deploy Preview https://deploy-preview-175--paisable.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95
Accessibility: 100
Best Practices: 100
SEO: 91
PWA: 80
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an "Income by Category" chart to the Dashboard, allowing users to toggle between viewing expense and income category breakdowns using a reusable pie chart component.

Key Changes:

  • Added backend aggregation for income grouped by category
  • Implemented frontend toggle to switch between expense and income views
  • Enhanced CategoryPieChart component to accept dynamic labels

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
backend/controllers/transactionController.js Added income by category aggregation query and included it in the chart data response
frontend/src/components/CategoryPieChart.jsx Made the chart label configurable via props to support both expense and income views
frontend/src/pages/DashboardPage.jsx Added toggle UI and state management to switch between expense and income category charts
Files not reviewed (1)
  • backend/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ayaz9616
Copy link
Contributor Author

Brother have you checked it , either accept it or tell if some changes are required

Copy link
Member

@archa8 archa8 left a comment

Choose a reason for hiding this comment

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

Hey @ayaz9616, thank you for opening the PR. Could you please pull all the recent changes and resolve the conflicts in the frontend file and then commit the changes?

Copilot AI review requested due to automatic review settings October 31, 2025 16:20
@ayaz9616
Copy link
Contributor Author

i have made the required changes , now you can proceed with merging.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • backend/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Data for Expenses by Category (Pie Chart)
const expensesByCategory = await IncomeExpense.aggregate([
{ $match: { user: userId, isIncome: false, isDeleted: false } },
{ $match: { user: userId, isIncome: false, isDeleted: false, ...(dateMatch.addedOn ? { addedOn: dateMatch.addedOn } : {}) } },
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

The spread operator pattern ...(dateMatch.addedOn ? { addedOn: dateMatch.addedOn } : {}) adds complexity and could be simplified. Consider restructuring to build the match object conditionally before the aggregation, which improves readability and maintainability.

Copilot uses AI. Check for mistakes.

// Data for Income by Category (Pie Chart)
const incomeByCategory = await IncomeExpense.aggregate([
{ $match: { user: userId, isIncome: true, isDeleted: false, ...(dateMatch.addedOn ? { addedOn: dateMatch.addedOn } : {}) } },
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

The spread operator pattern ...(dateMatch.addedOn ? { addedOn: dateMatch.addedOn } : {}) adds complexity and could be simplified. Consider restructuring to build the match object conditionally before the aggregation, which improves readability and maintainability.

Copilot uses AI. Check for mistakes.
</button>
<button
type="button"
className={`px-3 py-1 text-sm font-medium border-t border-b rounded-r-md ${categoryView === 'income' ? 'bg-green-600 text-white border-green-600' : 'bg-transparent text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-600'}`}
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Long className string with complex conditional logic reduces readability. Consider extracting the className logic into a helper function or using a library like classnames to improve maintainability.

Copilot uses AI. Check for mistakes.
<div className="inline-flex rounded-md shadow-sm" role="group" aria-label="Toggle category view">
<button
type="button"
className={`px-3 py-1 text-sm font-medium border rounded-l-md ${categoryView === 'expense' ? 'bg-blue-600 text-white border-blue-600' : 'bg-transparent text-gray-700 dark:text-gray-200 border-gray-300 dark:border-gray-600'}`}
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Long className string with complex conditional logic reduces readability. Consider extracting the className logic into a helper function or using a library like classnames to improve maintainability.

Copilot uses AI. Check for mistakes.
Copy link
Member

@archa8 archa8 left a comment

Choose a reason for hiding this comment

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

LGTM! Works as intended.

@archa8 archa8 merged commit 6bbb847 into Code-A2Z:master Oct 31, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

feat: Add “Income by Category” graph similar to “Expense by Category” graph

2 participants