luceroweb / karot-saving-smart

Millions of us are living paycheck to paycheck. It can be difficult to build a budget that helps you pay for your bills as well as plan for the future - without making you feel like you have to do without. You may have heard about the tried and true cash “Envelope Savings” system, which can help you to make sure you always have enough to pay your b
https://karot-saving-smart.netlify.app/
3 stars 13 forks source link

Sr 123 bugfix edit expense #124

Closed srosenberg74 closed 2 years ago

srosenberg74 commented 2 years ago

Changes

  1. Imported useEffect.
  2. Added a useEffect to reset the label in the ExpenseModal whenever the expenseModalVisibility state changes and the mode is set to "add".
  3. Removed the lines that reset the label whenever the ExpenseModal was edited.
  4. Removed the useEffect, decided to try to find a less complex solution, and found a bug with this solution.
  5. Added conditional in value property of the Label to account for the different modal modes.
  6. Removed lines that reset the values of amount and label after an expense is added because the conditionals now cover the same functionality.

Purpose This was done so that if a user wants to edit an expense a second time, after already editing it once, the information for the expense still shows up in the form.

Approach Initially, every time a user edited an expense the label was reset. Now, the label is not reset if the user wants to re-edit the same expense. This was accomplished by removing the code that automatically reset the label when an expense is edited, but this necessitated adding a way to reset the label whenever a new expense is added, so I also added the useEffect. However, I found a bug with this solution and found it overly complex, so I removed the useEffect and added a conditional to the value property of the <TextInput> for the label instead.

Learning Focused on trying to use a solution that didn't add unnecessary complexity to the app and that required the least amount of change to the code base while hopefully accomplishing the necessary fix.

Closes #123

srosenberg74 commented 2 years ago

This seems to have fixed the issue referenced by the bug ticket. However, there are still issues if a user adds an expense while already viewing another expense's details and then goes back to the expense that they were already viewing. However, I'm not sure if that is the intended behavior for the app, that a user could add an expense while already viewing the details of another one. Also not sure if that would be considered a new bug or related to this one.