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

feature/df 80 getbudgetbyparams #19

Closed
wants to merge 16 commits into from
Closed

Conversation

trpubz
Copy link
Contributor

@trpubz trpubz commented Feb 10, 2024

Keypoints

  • Add query file for BudgetsByParams
  • Include budgets data into the app js
  • Include budgetsbyparams in fetch call
  • Error: export versus import of default
  • Debug process, changed function input for const to variables for js
  • Add category selection modal
  • getBudgetByParams working on budget widet
  • Get Budget Categories
  • Remove caching on getBudgetCategories
  • Float mutation is incorrect for incomes/expenses but connections are live
  • Fix mutation amount to / 100

Related Issue(s)

closes DF-80

Checklist:

  • New/Modified Tests are Passing
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings or errors.

Additional Notes:

Please enusre you pull to local, test localhost rails server and live server

Copy link

linear bot commented Feb 10, 2024

DF-80 getBudgetByParams

Copy link

vercel bot commented Feb 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dough-fin-fe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 10, 2024 9:10pm

Little adjustments for titleizing the display on some hard-coded text.
@trpubz trpubz marked this pull request as ready for review February 10, 2024 21:04
@@ -51,7 +51,7 @@ const AddIncome = ({ totalIncome, setTotalIncome, setTransactions }) => {
id: data.createIncome.id,
vendor: source,
date,
amount: amountCents,
amount: amountCents / 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

This has an issue with being displayed on Transactions as $5.00 if the user actually wrote $500.00.

Could you look into this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not able to address this today...whoever coded the original logic might be able to lend some advice but there is certainly a disconnect between prop passing and the mutation/queries. This referenced line of code ensures the proper value is sent back through the mutation. Not sure if the issue is closer to data manipulation on the query (for transactions) or just on how it's displayed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my thought. @trpubz your branch still does not appear have the correct useCreateIncome or useCreateExpense mutation that is on main and main seems to be functioning correctly updating state just not posting since the mutation merge yesterday.
Screenshot 2024-02-11 at 12 35 02 PM
Here's how the FE app is handling floats for example with totalIncome:
The getIncomes hook fetches and returns the income as a float
Screenshot 2024-02-11 at 12 36 40 PM
Then to avoid rounding errors, the useEffect handling setting income state coverts the float into a cents integer:
Screenshot 2024-02-11 at 12 43 44 PM
Then whenever any amount needs to be displayed in the App (income, expenses, transaction etc.) it's formatted into a USD currency string:
Screenshot 2024-02-11 at 12 44 27 PM
This means we need to adhere to how floats are handled on main.
A few more thoughts:

  1. Pretty sure this is a bug, it's a matter of this branch not having parts of main like the useMutation fixes from Friday.
  2. We are allowed to fix bugs, but this is a feature branch.
  3. Lets leave this alone, I'm at a loss of words to be honest at this point..

Copy link
Contributor

@chisPmama chisPmama left a comment

Choose a reason for hiding this comment

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

Just one hopefully minor change. The AddIncome displays incorrectly in transactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

This file seems to just contain the tests @josephlee702 wrote, any particular reason they've been copied from his branch and not left on the Cypress branch?
If you're going to add Cypress tests, make sure they test the component you built.

const userName = "Powdered Toast Man";
const email = "[email protected]"

localStorage.setItem('email', email);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can be removed since the localStorage object is not being retrieved anywhere and email is set in the line above.

const { totalIncomeData } = useGetIncomes(email);
const { totalExpensesData } = useGetExpenses(email);
const { transactionsData } = useGetTransactions(email);
const { cashFlowData } = useGetCashFlow(email);
// const { budgetsData } = useGetBudgetsByParams(month, category, email);
Copy link
Contributor

Choose a reason for hiding this comment

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

Like all other useQuery hooks that retrieve data when the App mounts, the useGetBudgetByParams should follow the DDAU design convention.

export default function PieActiveArc() {
export default function BasicPie({ data }) {
// Validate incoming data - simple example
const isValidData = data && Array.isArray(data) && data.length > 0 && data.every(d => d.hasOwnProperty('value') && typeof d.value === 'number');
Copy link
Contributor

Choose a reason for hiding this comment

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

When the budgetData is properly drilled to this component, the chained conditionals can likely be reduced to something similar in the BarChart MUI component.

@@ -1,48 +1,148 @@
import React from 'react'
import React, { useState, useRef, useEffect, useMemo } from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused hook.


const Budget = () => {
return (
const email = "[email protected]";
Copy link
Contributor

Choose a reason for hiding this comment

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

This entire blocked dedicated to fetching budgets and budgetCategories should be be properly drilled through from App. Those states should not be set inside this child component.

setIsDropdownVisible(false); // Hide the modal
};
// Handler to toggle dropdown visibility
const toggleDropdownVisibility = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider refactoring this to utilize a BasicSelect MUI component, there is no need to make these kinds of functions.

document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

The BasicSelect component will remove the need for EventListeners like this. VanillaJS in React is not maintainable/conventional

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add anything new to this file, it's deprecated.

@@ -51,7 +51,7 @@ const AddIncome = ({ totalIncome, setTotalIncome, setTransactions }) => {
id: data.createIncome.id,
vendor: source,
date,
amount: amountCents,
amount: amountCents / 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my thought. @trpubz your branch still does not appear have the correct useCreateIncome or useCreateExpense mutation that is on main and main seems to be functioning correctly updating state just not posting since the mutation merge yesterday.
Screenshot 2024-02-11 at 12 35 02 PM
Here's how the FE app is handling floats for example with totalIncome:
The getIncomes hook fetches and returns the income as a float
Screenshot 2024-02-11 at 12 36 40 PM
Then to avoid rounding errors, the useEffect handling setting income state coverts the float into a cents integer:
Screenshot 2024-02-11 at 12 43 44 PM
Then whenever any amount needs to be displayed in the App (income, expenses, transaction etc.) it's formatted into a USD currency string:
Screenshot 2024-02-11 at 12 44 27 PM
This means we need to adhere to how floats are handled on main.
A few more thoughts:

  1. Pretty sure this is a bug, it's a matter of this branch not having parts of main like the useMutation fixes from Friday.
  2. We are allowed to fix bugs, but this is a feature branch.
  3. Lets leave this alone, I'm at a loss of words to be honest at this point..

@josephlee702
Copy link
Contributor

Was part of capstone pt.1 - closing.

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.

4 participants