Skip to content

Conversation

@Juwang110
Copy link

@Juwang110 Juwang110 commented Jan 23, 2025

ℹ️ Issue

Closes Food Request Form

📝 Description

I added a food request form button modal which is a button component that opens a pop up modal which houses a form. This form is for pantries to request food (shipment size, shipment contents). This is important so we can keep track of what certain pantries request. I also created a food-requests backend folder which houses the controller, entity, module and service. This enables API calls to the backend food-requests table. I created two routes, find and create where the create route is used to create a food request in the database based on the form answers.

Briefly list the changes made to the code:

  1. Added food request form button pop up modal.
  2. Added backend support for food requests
  3. Added create and find routes for food requests

✔️ Verification

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.

To verify the frontend part of the component I simply added the component to an existing page (landing page) and verified it looked and worked properly. To verify the backend I had to manually add a user row to PGAdmin and a pantry to PGAdmin to fulfill foreign key constraints for an actual pantry to have a food request. After manually adding this filler data, I submitted the form via the frontend and I verified the new food request in the database.

Provide screenshots of any new components, styling changes, or pages.

Screenshot 2025-01-23 120052
Screenshot 2025-01-23 120117

🏕️ (Optional) Future Work / Notes

Additional Notes:

Right now in the form component the pantryID is hard coded to submit requests for ID = 1 due to the incomplete implementation of authentication currently.
I did not add any authentication/interceptor for the food-requests backend which might need to be done later on? I'm not really sure if it's needed or how to go about it though.
The existing old food requests route and form still exists, I wasn't sure if I should delete it or not.

TODO:

Add entities for pantries and food manufacturers so many-to-one relationships can be defined in the requests entity because panties/manufacturers can both be associated with multiple requests.

Add these to requests.entity:

manytoone(() => Pantry, (pantry) => pantry.foodRequests, { nullable: false })
joincolumn({ name: 'pantry_id' })
pantry: Pantry;

manytoone(() => FoodManufacturer, (manufacturer) => manufacturer.foodRequests, { nullable: true })
joincolumn({ name: 'fulfilled_by' })
fulfilledByManufacturer: FoodManufacturer;

@@ -0,0 +1,243 @@
import {
Copy link

@fanzzz368 fanzzz368 Jan 24, 2025

Choose a reason for hiding this comment

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

you can delete this entire file since we will be using your requestformmodalbutton instead (and you can delete it from inside foodrequest.tsx)

Copy link
Author

Choose a reason for hiding this comment

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

fixed

/>
</FormControl>
<Flex justifyContent="space-between" mt={4}>
<Button type="submit">Submit</Button>

Choose a reason for hiding this comment

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

nit: maybe we can switch the positions of the submit and cancel button b/c I usually expect submit to be on the right

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link

@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.

Changes look good! No additional comments.

@Juwang110 Juwang110 merged commit aea2c59 into main Feb 1, 2025
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.

4 participants