Skip to content

[SSF-232] Edit & Delete Donation Items Frontend#199

Open
jiang-h-y wants to merge 9 commits into
mainfrom
hj/SSF-232-edit-delete-donations
Open

[SSF-232] Edit & Delete Donation Items Frontend#199
jiang-h-y wants to merge 9 commits into
mainfrom
hj/SSF-232-edit-delete-donations

Conversation

@jiang-h-y

Copy link
Copy Markdown

ℹ️ Issue

Closes SSF-232

📝 Description

For /fm-donation-management:

  • added edit/delete buttons for donations
  • added editing view + delete modal

✔️ Verification

Tested cases for:

  • editing donations
  • adding/removing donation rows
  • updating donations without making any changes
  • deleting donations
  • no edit/delete buttons if the user is not a FM or if the donation already has allocations (matches editDonationItems backend)
  • all fields are required

Edit/Delete Buttons:
image

Editing View:
image

Delete Modal:
image

🏕️ (Optional) Future Work / Notes

  • made a small bug fix where i removed ownership guards for creating donations (may need to revisit this)
  • not sure if deleting donations should be allowed if there already are allocations

what's the difference between "matched" and "available" donations?

i have an "available" donation with allocations, so no edit/delete buttons are displayed (screenshot).

if some "available" donations have edit/delete buttons (no allocations) and some don't have these buttons (because they have allocations), i think it's kind of confusing for the user since both donations are under "available." it would be helpful to put a note/visual indicator that "available" donations with allocations cannot be edited/deleted.

image

@dburkhart07 dburkhart07 self-assigned this Jun 24, 2026
@jiang-h-y jiang-h-y self-assigned this Jun 24, 2026

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looking good so far! just some small things

Comment thread apps/frontend/src/components/editDeleteButtons.tsx Outdated
Comment thread apps/backend/src/donations/donations.controller.ts
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/containers/foodManufacturerDonationManagement.tsx Outdated
@jiang-h-y jiang-h-y requested a review from dburkhart07 June 25, 2026 10:05
@jiang-h-y

jiang-h-y commented Jun 26, 2026

Copy link
Copy Markdown
Author

Just got an update that admins should also be able to edit/delete donation items - this PR isn't completely ready atm

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

all small things, pr looks really good!!

Comment thread apps/frontend/src/containers/foodManufacturerDonationManagement.tsx
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/components/forms/fmDeleteDonationModal.tsx Outdated

@Yurika-Kan Yurika-Kan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

found some regression bugs! --> addressing effects race condition, deep linking

lmk if you need more clarification~

onDelete: () => void;
}

interface DonationRow {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this reimplements newDonationFormModal's item editing fully with duplicate DonationRow, addRow/deleteRow/handleChange, donation items table. can we extract the item-rows component instead of duplicating it here? that way we use the same logic for validating donation items (regardless of if it was created or edited/updated)

.find((d) => d.donation.donationId === id);
if (match) {
setSelectedViewDetailsDonation(match.donation);
} else navigate(ROUTES.FM_DONATION_MANAGEMENT);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

bug: FM dashboard --> donation details via "View Donation Details/Requirements" is broken

when this page is initially rendering
this useEffect "B" runs on mount alongside the init effect "A" (L139). however that init is async & yields at its first await:

const init = async () => {
      try {
        const fmId = await ApiClient.getCurrentUserFoodManufacturerId();

so effect "B" runs before effect "A" can get to fetchDonations (L144) which set donation statuses (L91). statusDonations const is still exactly what useState initialized it to (L48-54, empty buckets). in effect "B", match (L165) is undefined, leaving us to the navigate (L170) case where it strips the ?donationId= param before data loads = modal never opens!

fix: gate effect "B" on loading complete so the match waits for populated donation data. add
if (loading) return;
to effect "B" at the top & also gate on loading so that it navigates when genuinely

<DonationDetailsModal
donation={selectedViewDetailsDonation}
isOpen={selectedViewDetailsDonation !== null}
onClose={() => setSelectedViewDetailsDonation(null)}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

bug: onclose does not clear the ?donationId= param in the URL, resulting in possible modal reopening after closing due to the param still being there.

fix: handle this how adminDonation.tsx already does by clearing the param on close

  setSelectedViewDetailsDonation(null);
 navigate(ROUTES.FM_DONATION_MANAGEMENT, { replace: true });
}}``` (adminDonation.tsx:313-315) 

}}
onSuccess={() => {
setAlertMessage(
'Successfully deleted donation items.',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Successfully deleted donation items --> Successfully deleted donation

since delete just removed the whole thing

}}
onSuccess={() => {
setAlertMessage(
'Successfully deleted donation items.',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

^^

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.

3 participants