diff --git a/frontend/src/components/asp/requests/SchedulingFormCalendar.tsx b/frontend/src/components/asp/requests/SchedulingFormCalendar.tsx index 3044388c..64fe7ad9 100644 --- a/frontend/src/components/asp/requests/SchedulingFormCalendar.tsx +++ b/frontend/src/components/asp/requests/SchedulingFormCalendar.tsx @@ -2,6 +2,7 @@ import { Box, Button, Center, + Flex, FormControl, FormLabel, Grid, @@ -26,7 +27,9 @@ type SchedulingFormCalendarProps = { handleNext: () => void; }; -const SchedulingFormCalendar: React.FunctionComponent = ({ +const SchedulingFormCalendar: React.FunctionComponent< + SchedulingFormCalendarProps +> = ({ scheduledDropOffTime, setScheduledDropOffTime, dates, @@ -78,6 +81,12 @@ const SchedulingFormCalendar: React.FunctionComponent - + Scheduled drop-off time - setScheduledDropOffTime(e.target.value)} - type="time" - placeholder="Select a time" - width={{ base: "100%", md: "100%" }} - /> + + setScheduledDropOffTime(e.target.value)} + type="time" + placeholder="Select a time" + flex="1" + /> + + {scheduledDropOffTime && + " - " + + scheduledDropOffTimeEnd.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + })} + + diff --git a/frontend/src/components/asp/requests/SchedulingFormWeekly.tsx b/frontend/src/components/asp/requests/SchedulingFormWeekly.tsx index 588ac396..68b02fbc 100644 --- a/frontend/src/components/asp/requests/SchedulingFormWeekly.tsx +++ b/frontend/src/components/asp/requests/SchedulingFormWeekly.tsx @@ -1,6 +1,7 @@ import { Box, Button, + Flex, Grid, GridItem, Input, @@ -206,23 +207,28 @@ const SchedulingFormWeekly: React.FunctionComponent< - - Scheduled drop-off time* - - setScheduledDropOffTime(e.target.value)} - type="time" - placeholder="Select a time" - width={{ base: "100%", md: "100%" }} - /> + + + Scheduled drop-off time* + + setScheduledDropOffTime(e.target.value)} + type="time" + placeholder="Select a time" + width={{ base: "100%", md: "100%" }} + /> + HH:MM AM/PM + diff --git a/frontend/src/components/meal_donor/donation_form/MealDeliveryDetails.tsx b/frontend/src/components/meal_donor/donation_form/MealDeliveryDetails.tsx index f05eed05..f9ee75af 100644 --- a/frontend/src/components/meal_donor/donation_form/MealDeliveryDetails.tsx +++ b/frontend/src/components/meal_donor/donation_form/MealDeliveryDetails.tsx @@ -32,51 +32,56 @@ const MealDeliveryDetails: React.FunctionComponent = ( - {mealRequestsInformation?.map((request: MealRequest) => ( - - - - - {new Date(request.dropOffDatetime + "Z").toLocaleDateString( - undefined, - { + {mealRequestsInformation?.map((request: MealRequest) => { + const startDate = new Date(request.dropOffDatetime + "Z"); + const endDate = new Date(request.dropOffDatetime + "Z"); + endDate.setHours(endDate.getHours() + 1); + return ( + + + + + {startDate.toLocaleDateString(undefined, { month: "long", day: "numeric", - }, - )} - - - {request.mealInfo.portions} Meals - - - {new Date(request.dropOffDatetime + "Z").toLocaleTimeString( - "en-US", - { + })} + + + {request.mealInfo.portions} Meals + + + {startDate.toLocaleTimeString("en-US", { hour: "numeric", minute: "numeric", hour12: true, - }, - )} - - - - Acommodations: - {request.mealInfo.dietaryRestrictions} - - - - ))} + }) + + " - " + + endDate.toLocaleTimeString("en-US", { + hour: "numeric", + minute: "numeric", + hour12: true, + })} + + + + Acommodations: + {request.mealInfo.dietaryRestrictions} + + + + ); + })} ); diff --git a/frontend/src/components/mealrequest/ASPListView.tsx b/frontend/src/components/mealrequest/ASPListView.tsx index 06726820..03669444 100644 --- a/frontend/src/components/mealrequest/ASPListView.tsx +++ b/frontend/src/components/mealrequest/ASPListView.tsx @@ -173,46 +173,53 @@ const ASPListView = ({ authId, rowsPerPage = 10 }: ASPListViewProps) => { GET_MEAL_REQUESTS_BY_ID, { onCompleted: (results) => { - setData({ + // Get the time requested plus one hour + const newData = { nodes: results.getMealRequestsByRequestorId?.map( ( mealRequest: MealRequest, index: number, - ): TABLE_LIBRARY_TYPES.TableNode => ({ - id: index, - meal_request_id: mealRequest.id, - date_requested: new Date(mealRequest.dropOffDatetime + "Z"), - time_requested: new Date(mealRequest.dropOffDatetime + "Z"), - donor_name: - mealRequest.donationInfo?.donor.info?.organizationName, - num_meals: mealRequest.mealInfo?.portions, - primary_contact: - mealRequest.donationInfo?.donor?.info?.primaryContact ?? null, - onsite_contacts: mealRequest.onsiteContacts, - donor_onsite_contacts: - mealRequest.donationInfo?.donorOnsiteContacts ?? [], - delivery_notes: mealRequest.deliveryInstructions, - dietary_restrictions: - mealRequest.mealInfo?.dietaryRestrictions ?? "", + ): TABLE_LIBRARY_TYPES.TableNode => { + const startDate = new Date(mealRequest.dropOffDatetime + "Z"); + const endDate = new Date(startDate); + endDate.setHours(endDate.getHours() + 1); - meal_description: mealRequest.donationInfo?.mealDescription, - meal_donor_notes: mealRequest.donationInfo?.additionalInfo, - delivery_instructions: mealRequest.deliveryInstructions, - pending: mealRequest.status === MealStatus.OPEN, - status: mealRequest.status, - _hasContent: false, - nodes: null, - }), + return { + id: index, + meal_request_id: mealRequest.id, + date_requested: new Date(mealRequest.dropOffDatetime + "Z"), + time_requested_start: startDate, + time_requested_end: endDate, + donor_name: + mealRequest.donationInfo?.donor.info?.organizationName, + num_meals: mealRequest.mealInfo?.portions, + primary_contact: + mealRequest.donationInfo?.donor?.info?.primaryContact ?? null, + onsite_contacts: mealRequest.onsiteContacts, + donor_onsite_contacts: + mealRequest.donationInfo?.donorOnsiteContacts ?? [], + delivery_notes: mealRequest.deliveryInstructions, + dietary_restrictions: + mealRequest.mealInfo?.dietaryRestrictions ?? "", + + meal_description: mealRequest.donationInfo?.mealDescription, + meal_donor_notes: mealRequest.donationInfo?.additionalInfo, + delivery_instructions: mealRequest.deliveryInstructions, + pending: mealRequest.status === MealStatus.OPEN, + status: mealRequest.status, + _hasContent: false, + nodes: null, + }; + }, ), - }); + }; + setData(newData); }, }, ); - const [ - itemToDelete, - setItemToDelete, - ] = useState(null); + const [itemToDelete, setItemToDelete] = + useState(null); function reloadMealRequests( fetchPolicy: WatchQueryFetchPolicy = "cache-first", @@ -297,10 +304,15 @@ const ASPListView = ({ authId, rowsPerPage = 10 }: ASPListViewProps) => { label: "Time Requested", renderCell: (item: TABLE_LIBRARY_TYPES.TableNode) => ( - {item.time_requested.toLocaleTimeString("en-US", { + {item.time_requested_start.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", - })} + }) + + " - " + + item.time_requested_end.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + })} ), }, @@ -524,7 +536,7 @@ const ASPListView = ({ authId, rowsPerPage = 10 }: ASPListViewProps) => { onClose={(newMealRequest) => { setIsEditModalOpen(false); setCurrentlyEditingMealRequestId(undefined); - if(newMealRequest !== undefined) { + if (newMealRequest !== undefined) { reloadMealRequests(); } }} diff --git a/frontend/src/components/mealrequest/MealDonorListView.tsx b/frontend/src/components/mealrequest/MealDonorListView.tsx index e022c582..81c8e730 100644 --- a/frontend/src/components/mealrequest/MealDonorListView.tsx +++ b/frontend/src/components/mealrequest/MealDonorListView.tsx @@ -53,14 +53,23 @@ const MealDonorListView = ({ }, { label: "Time Requested", - renderCell: (item: TABLE_LIBRARY_TYPES.TableNode) => ( - - {item.time_requested.toLocaleTimeString("en-US", { - hour: "2-digit", - minute: "2-digit", - })} - - ), + renderCell: (item: TABLE_LIBRARY_TYPES.TableNode) => { + const endDate = new Date(item.time_requested); + endDate.setHours(endDate.getHours() + 1); + return ( + + {item.time_requested.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + }) + + " - " + + endDate.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + })} + + ); + }, }, { label: "ASP Name", @@ -185,7 +194,7 @@ const MealDonorListView = ({ ) : null} - + ), }; diff --git a/frontend/src/pages/UpcomingPage.tsx b/frontend/src/pages/UpcomingPage.tsx index 1a41625a..79989fb7 100644 --- a/frontend/src/pages/UpcomingPage.tsx +++ b/frontend/src/pages/UpcomingPage.tsx @@ -184,6 +184,14 @@ export const UpcomingCard = ({ event, setShouldReload }: { event: UpcomingEvent, setIsEditModalOpen(true); setCurrentlyEditingMealRequestId(meal?.id); }; + + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const startDate = new Date(mealRequest!.dropOffDatetime + "Z") ?? null; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const endDate = new Date(mealRequest!.dropOffDatetime + "Z") ?? null; + if (startDate) { + endDate.setHours(endDate.getHours() + 1); + } return (
@@ -217,14 +225,19 @@ export const UpcomingCard = ({ event, setShouldReload }: { event: UpcomingEvent, } - {new Date( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - mealRequest!.dropOffDatetime + "Z", - ).toLocaleTimeString("en-US", { - hour: "numeric", - minute: "numeric", - hour12: true, - }) ?? ""} + {startDate + ? startDate.toLocaleTimeString("en-US", { + hour: "numeric", + minute: "numeric", + hour12: true, + }) + + " - " + + endDate.toLocaleTimeString("en-US", { + hour: "numeric", + minute: "numeric", + hour12: true, + }) + : ""}