-
Notifications
You must be signed in to change notification settings - Fork 0
[SSF-79] Improve Peformance for Log New Donation Form Modal #58
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
base: main
Are you sure you want to change the base?
[SSF-79] Improve Peformance for Log New Donation Form Modal #58
Conversation
3c5bca7 to
3c3e332
Compare
d73a38e to
20b9bbe
Compare
amywng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change the field in donationItems entity to donationId instead of donation_id, also merge main so i can run it w/o issues
apps/backend/src/donationItems/donationItems.controller.spec.ts
Outdated
Show resolved
Hide resolved
apps/frontend/src/components/forms/deliveryConfirmationModal.tsx
Outdated
Show resolved
Hide resolved
apps/frontend/src/components/forms/deliveryConfirmationModal.tsx
Outdated
Show resolved
Hide resolved
apps/frontend/src/components/forms/deliveryConfirmationModal.tsx
Outdated
Show resolved
Hide resolved
| totalValue = 0; | ||
|
|
||
| updatedRows.forEach((row) => { | ||
| if (row.numItems && row.ozPerItem && row.valuePerItem) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo i feel like we shouldn't wait til they're all filled out, but update as any row is changed (also know this isn't part of your ticket but food for thought ig
apps/backend/src/donationItems/dtos/create-donationItems.dto.ts
Outdated
Show resolved
Hide resolved
apps/backend/src/donationItems/dtos/create-donationItems.dto.ts
Outdated
Show resolved
Hide resolved
apps/backend/src/donationItems/dtos/create-donation-items.dto.ts
Outdated
Show resolved
Hide resolved
apps/backend/src/donationItems/donationItems.controller.spec.ts
Outdated
Show resolved
Hide resolved
amywng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add validation to the form because i was able to submit an invalid entry and it added it to the database but i'm going to say that is whoever does the new form's job
amywng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple small comments. once justin's pr goes in you'll have to fix the status stuff but i'm approving
| return; | ||
| } | ||
|
|
||
| onClose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason we close it first? it works asyncly is what i am understanding how you can set this as closed before api call finishes. is this just better design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, you make a good point. I think it should not really matter where we place it, but for error handling, it is probably better for them to receive some browser alert if something went wrong before closing it. I just changed the location!
| const donationId = donationResponse?.donationId; | ||
|
|
||
| // Automatically update the page after creating new donation | ||
| onDonationSuccess(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing here of calling this end result function before the api await call a few lines after!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also changed for same reason!
| if (!acc[item.foodType]) acc[item.foodType] = []; | ||
| acc[item.foodType].push(item); | ||
| return acc; | ||
| }, {} as Record<string, DonationItem[]>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to think of a case where this could be null/undef since Record<string, DonationItem[]> technically could take any string, which means it could be set to acc[null].push(item) for example. thoughts on handling for null/undef here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another really good point. We have been in the process of making sure our backend and frontend types match, and this caught an issue we had. I have changed the frontend DonationItem so that the type is of FoodType enum. This will make it so that we cannot have null/undef cases, since it always needs to be one of those options now, and can stay handled as this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test
Yurika-Kan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good! just minor clarifications
Yurika-Kan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some more comments ><
| reservedQuantity: number; | ||
| ozPerItem: number; | ||
| estimatedValue: number; | ||
| foodType: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be the enum type defined above
| alert('Error submitting new donation'); | ||
| alert('Error submitting new donation: ' + error); | ||
| } | ||
| onClose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but should we move onClose to inside the try catch so that is submission fails the modal stays open & user can fix issue
| <Table.Cell> | ||
| <Input | ||
| type="number" | ||
| min={0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be min={1} to match the backend dto ozPerItem being @min(1)
| <Table.Cell> | ||
| <Input | ||
| type="number" | ||
| min={0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here with estimatedValue being min of 1
| alert('Error submitting new donation'); | ||
| alert('Error submitting new donation: ' + error); | ||
| } | ||
| onClose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be better to have this inside the try catch so its not silently failing & the modal will not close even when the submission fails
| <Table.Cell> | ||
| <Input | ||
| type="number" | ||
| min={0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numitems is quantity in backend dto which should be min 1
ℹ️ Issue
Closes #79
📝 Description
✔️ Verification
Ensured only 1 api call was being made via console logs
Successful confirmation of 1 api call being made:

🏕️ (Optional) Future Work / Notes
Still need to write tests for the rest of the controllers, as well as the services. We are holding off on service tests for now though, pending a potential change in how we do testing.