-
Notifications
You must be signed in to change notification settings - Fork 0
Ddb/ssf 8 admin order management frontend #51
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?
Changes from all commits
1697cbe
3f6f05c
379edb7
7023e8a
27ba9d9
693bed0
7fe9ca5
121d373
a89873d
815daab
4a53a23
21eb829
505836d
b462dba
906b21b
a2fec8c
35951a4
585b809
56a9a82
fdd5784
cb5ce22
54d4175
4eff2ee
b594158
ae13e1f
8ca82ec
7991740
ecad35e
430c293
a570951
1cc1d48
eb144ae
577b6aa
039e240
71bade1
8fc17d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,24 @@ | ||
| import { MigrationInterface, QueryRunner } from "typeorm"; | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class RemoveUnusedStatuses1764816885341 implements MigrationInterface { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE allocations DROP COLUMN IF EXISTS status;`, | ||
| ); | ||
| await queryRunner.query( | ||
| `ALTER TABLE donation_items DROP COLUMN IF EXISTS status;`, | ||
| ); | ||
| } | ||
|
|
||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE allocations DROP COLUMN IF EXISTS status;` | ||
| ); | ||
| await queryRunner.query( | ||
| `ALTER TABLE donation_items DROP COLUMN IF EXISTS status;` | ||
| ); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE allocations | ||
| ADD COLUMN status VARCHAR(25) NOT NULL DEFAULT 'pending'; | ||
| `); | ||
|
|
||
| await queryRunner.query(` | ||
| await queryRunner.query(` | ||
| ALTER TABLE donation_items | ||
| ADD COLUMN status VARCHAR(25) NOT NULL DEFAULT 'available'; | ||
| `); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,13 +16,17 @@ export class OrdersService { | |
| const qb = this.repo | ||
| .createQueryBuilder('order') | ||
| .leftJoinAndSelect('order.pantry', 'pantry') | ||
| .leftJoinAndSelect('pantry.volunteers', 'volunteers') | ||
| .select([ | ||
| 'order.orderId', | ||
| 'order.status', | ||
| 'order.createdAt', | ||
| 'order.shippedAt', | ||
| 'order.deliveredAt', | ||
| 'pantry.pantryName', | ||
| 'volunteers.id', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the frontend type corresponding to the return type of this method implies that more user attributes than these will be returned. We need to change one or the other |
||
| 'volunteers.firstName', | ||
| 'volunteers.lastName', | ||
| ]); | ||
|
|
||
| if (filters?.status) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import React, { useState, useEffect } from 'react'; | ||
dburkhart07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { | ||
| Text, | ||
| Dialog, | ||
| CloseButton, | ||
| Flex, | ||
| Textarea, | ||
| Field, | ||
| Tag, | ||
| } from '@chakra-ui/react'; | ||
| import ApiClient from '@api/apiClient'; | ||
| import { FoodRequest, Order } from 'types/types'; | ||
| import { formatDate } from '@utils/utils'; | ||
|
|
||
| interface OrderDetailsModalProps { | ||
| order: Order; | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| const OrderDetailsModal: React.FC<OrderDetailsModalProps> = ({ | ||
| order, | ||
| isOpen, | ||
| onClose, | ||
| }) => { | ||
| const [foodRequest, setFoodRequest] = useState<FoodRequest | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (isOpen) { | ||
| const fetchData = async () => { | ||
| try { | ||
| const foodRequestData = await ApiClient.getFoodRequestFromOrder( | ||
| order.orderId, | ||
| ); | ||
| setFoodRequest(foodRequestData); | ||
| } catch (error) { | ||
| console.error('Error fetching food request details:', error); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be a toast instead?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with this. Is there a reason we are deciding to start using toasts now? This is our first time using it in the project. I think if we want to do this, this should be a separate frontend ticket to change a majority of our alerts and console logs to be toasts instead.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the confusion, I didn't mean a Chakra toast, I meant a browser alert. (I thought those were also called toasts but apparently not because they block user interaction) |
||
| } | ||
| }; | ||
|
|
||
| fetchData(); | ||
| } | ||
| }, [isOpen, order.orderId]); | ||
|
|
||
| return ( | ||
| <Dialog.Root | ||
| open={isOpen} | ||
| size="xl" | ||
| onOpenChange={(e: { open: boolean }) => { | ||
| if (!e.open) onClose(); | ||
| }} | ||
| closeOnInteractOutside | ||
| > | ||
| <Dialog.Backdrop /> | ||
| <Dialog.Positioner> | ||
| <Dialog.Content maxW={650}> | ||
| <Dialog.Header pb={0} mt={2}> | ||
| <Dialog.Title fontSize="lg" fontWeight={700} fontFamily="inter"> | ||
| Order {order.orderId} | ||
| </Dialog.Title> | ||
| </Dialog.Header> | ||
| <Dialog.Body> | ||
| {foodRequest && ( | ||
| <> | ||
| <Text textStyle="p2" color="#111111"> | ||
| {order.pantry.pantryName} | ||
| </Text> | ||
| <Text mb={8} color="#52525B" textStyle="p2" pt={0} mt={0}> | ||
| Requested {formatDate(foodRequest.requestedAt)} | ||
| </Text> | ||
|
|
||
| <Field.Root mb={4}> | ||
| <Field.Label> | ||
| <Text textStyle="p2" fontWeight={600} color="neutral.800"> | ||
| Size of Shipment | ||
| </Text> | ||
| </Field.Label> | ||
| <Text | ||
| fontSize="sm" | ||
| fontWeight="400" | ||
| color="neutral.800" | ||
| mt={1} | ||
| w="full" | ||
| > | ||
| {foodRequest.requestedSize} | ||
| </Text> | ||
| </Field.Root> | ||
|
|
||
| <Field.Root mb={4}> | ||
| <Field.Label> | ||
| <Text textStyle="p2" fontWeight={600} color="neutral.800"> | ||
| Food Type(s) | ||
| </Text> | ||
| </Field.Label> | ||
| <Flex wrap="wrap" mt={1} gap={2}> | ||
| {foodRequest.requestedItems.map((item, index) => ( | ||
| <Tag.Root | ||
| key={index} | ||
| size="xl" | ||
| variant="solid" | ||
| bg="neutral.100" | ||
| color="neutral.800" | ||
| borderRadius="4px" | ||
| borderColor="neutral.300" | ||
| borderWidth="1px" | ||
| fontFamily="Inter" | ||
| fontWeight={500} | ||
| > | ||
| <Tag.Label>{item}</Tag.Label> | ||
| </Tag.Root> | ||
| ))} | ||
| </Flex> | ||
| </Field.Root> | ||
|
|
||
| <Field.Root mb={4}> | ||
| <Field.Label> | ||
| <Text textStyle="p2" fontWeight={600} color="neutral.800"> | ||
| Additional Information | ||
| </Text> | ||
| </Field.Label> | ||
| <Textarea | ||
| value={ | ||
| foodRequest.additionalInformation || | ||
| 'No additional information supplied.' | ||
| } | ||
| readOnly | ||
| pl={-2} | ||
| size="lg" | ||
| textStyle="p2" | ||
| color="neutral.800" | ||
| bg="white" | ||
| border="none" | ||
| resize="none" | ||
| disabled | ||
| /> | ||
| </Field.Root> | ||
| </> | ||
| )} | ||
| </Dialog.Body> | ||
|
|
||
| <Dialog.CloseTrigger asChild> | ||
| <CloseButton size="lg" /> | ||
| </Dialog.CloseTrigger> | ||
| </Dialog.Content> | ||
| </Dialog.Positioner> | ||
| </Dialog.Root> | ||
| ); | ||
| }; | ||
|
|
||
| export default OrderDetailsModal; | ||
Uh oh!
There was an error while loading. Please reload this page.