Changed input handling from onChange() to onSubmission()
Changed prop type validation to allow for strings - the initial value is a string/0.00. It can be listed as an empty string now.
Originally had conditional change handling within the handleChange() functionality. But this was far less flexible than input handling on submission and caused a lot of type value errors.
Had initialState.spendingLimit assigned to the data type of a float/a number. This caused some discrepancies between MUI's textfield/form control API as well as within the handleChange() function.
ONSUBMISSION CHANGES
const handleSubmit = (e) => {
e.preventDefault();
if (obj.firebaseKey) {
updateCategory(formInput).then(() => router.push(`/category/${obj.firebaseKey}`));
} else {
//reassigning the string value of the value assigned to the key formInput.spendingLimit to a parsedFloat version.
formInput.spendingLimit = parseFloat(formInput.spendingLimit);
const payload = { ...formInput, uid: user.uid };
createNewCategory(payload).then(({ name }) => {
const patchPayload = { firebaseKey: name };
updateCategory(patchPayload).then(() => {
router.push(`/category/${patchPayload.firebaseKey}`);
});
});
}
};
NOTE - THIS DATA TYPE ISSUE REACHES ACROSS HOW DATA IS HANDLED ACROSS THE APPLICATION. YOU WILL HAVE TO DETERMINE HOW TO HANDLE THE DATA OF PRE-EXISTING OBJECTS, AS WELL AS ARRAY METHODS RESPONSIBLE FOR THE SUMMATION AND DISPLAY OF DATA.
Related Issue
30
12
Motivation and Context
This is a necessary component
How Can This Be Tested?
Pull PR branch
Install needed dependencies
Add a category
Use float/decimal point value within 'spendingLimit' and ensure that totals render properly.
Screenshots (if appropriate):
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to change)
Description
ONSUBMISSION CHANGES
NOTE - THIS DATA TYPE ISSUE REACHES ACROSS HOW DATA IS HANDLED ACROSS THE APPLICATION. YOU WILL HAVE TO DETERMINE HOW TO HANDLE THE DATA OF PRE-EXISTING OBJECTS, AS WELL AS ARRAY METHODS RESPONSIBLE FOR THE SUMMATION AND DISPLAY OF DATA.
Related Issue
30
12
Motivation and Context
How Can This Be Tested?
Screenshots (if appropriate):
Types of changes