Skip to content

[SSF-226] Pantry Deleting & Editing Food Requests Frontend#186

Open
jiang-h-y wants to merge 6 commits into
mainfrom
hj/SSF-226-pantry-delete-edit-requests
Open

[SSF-226] Pantry Deleting & Editing Food Requests Frontend#186
jiang-h-y wants to merge 6 commits into
mainfrom
hj/SSF-226-pantry-delete-edit-requests

Conversation

@jiang-h-y
Copy link
Copy Markdown

ℹ️ Issue

Closes SSF-226

📝 Description

  • added edit and delete buttons
  • added editing view + delete request modal
  • added success/error toasts
    • Note: the status for the toasts are temporarily incorrect + hard-coded since I recently refactored alerts in a different branch, and I would rather use the refactored version once it's merged.
  • connected to existing backend endpoints
  • edge case handling for if the user:
    • clears "Additional Information"
    • makes back-to-back edits without closing the modal
    • clicks "Update Request" but changes nothing

✔️ Verification

  • tested edit/delete request flows
  • verified that changes are committed to the database

Base Request Modal:
image

Editing View:
image

Delete Request Modal:
image

Success Toast Example:
image

🏕️ (Optional) Future Work / Notes

  • not sure if some of my design choices (colors, hover, etc.) were consistent with the rest of the codebase
  • sometimes received this error, but I couldn't reproduce it:
    Uncaught Error: Your focus-trap needs to have at least one focusable element

@jiang-h-y jiang-h-y self-assigned this May 31, 2026
Copy link
Copy Markdown

@dburkhart07 dburkhart07 left a comment

Choose a reason for hiding this comment

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

few things, looking beautiful tho!!

isOpen={deleteRequest !== null}
onClose={() => setDeleteRequest(null)}
onSuccess={() => {
setAlertMessage('Successfully deleted food request.');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note: Once you merge in your PR for fixing the alert messages, you'll need to adjust this to be a success (right now, it shows up as an error, but don't bother fixing that till your later PR comes in)

}
};

const editButton = (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We shouldnt display either of these buttons for a closed food request

});

const handleUpdate = async () => {
const changed: UpdateFoodRequestBody = {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for looking into this. This might just be me, but I personally don't think we need any of this code, and may want to go with the simpler design approach. We could pretty easily get rid of all of this if we just use the actual state variables that we are changing in the form to compose the body as is. All of the fields are optional, so I think it's fine if we just pass them in anyways. This would mean just changing the function to something more like

const handleUpdate = async () => {
    try {
      await apiClient.updateFoodRequest(request.requestId, {
        requestedSize,
        requestedFoodTypes: selectedFoodTypes,
        additionalInformation: additionalNotes === '' ? null : additionalNotes,
      });
      onSuccess();
      setAlertMessage('Successfully updated food request.');
      setIsEditing(false);
    } catch {
      setAlertMessage('Food request could not be updated.');
    }
  };

This would also remove any baseline stuff, at the cost of a potential no-op network call which should be fine, and we can (and should) account for this in the service call. lmk if u disagree tho

}
};

const editButton = (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: both editButton and deleteButton are only used once within the code, so making a const for them outside of it is likely unnecessary, and inconsistent with how we have done most icons previously. can we make this change both in this file and pantryDeleteRequestModal?

subtle: { value: '#FEE2E2' },
hover: { value: '#972729' },
// NOTE: not sure if this is the right color or what color we want hover to be for delete buttons
200: { value: '#FEC9C9' },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you ask our DL, Priya about this and adjust accordingly for both of these?

<Box
borderWidth={1}
p={6}
borderColor={'neutral.100'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: i think this is supposed to be #E4E4E7, not neutral 100

borderWidth={1}
p={6}
borderColor={'neutral.100'}
borderRadius={5}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you change this to 6?

))}

{selectedViewDetailsRequest && (
{selectedViewDetailsRequest && !deleteRequest && (
Copy link
Copy Markdown

@dburkhart07 dburkhart07 Jun 1, 2026

Choose a reason for hiding this comment

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

This is what's causing your bug. We are doing conditional rendering for the dialog, as opposed to using the open prop. We want to keep the Dialog mounted whenever a request is selected, and let the open prop do the showing/hiding. We essentially don't want to keep mounting and unmounting like we are right now (when deleteRequest gets a value, the component becomes faulty and gets unmounted), and should change it to this:

{selectedViewDetailsRequest && (
    <RequestDetailsModal
      request={selectedViewDetailsRequest}
      isOpen={!deleteRequest} 
      onClose={() => {
        setSelectedViewDetailsRequest(null);
        if (initialRequestId) {
          navigate(location.pathname, { replace: true });
        }
      }}
      onSuccess={loadRequests}
      onDelete={() => setDeleteRequest(selectedViewDetailsRequest)}
    />
  )}

This way, we toggle visibility on the presence of the delete request rather than mounting and unmounting

@dburkhart07 dburkhart07 self-assigned this Jun 1, 2026
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.

2 participants