Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/frontend/src/components/forms/orderDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const OrderDetailsModal: React.FC<OrderDetailsModalProps> = ({
{foodRequest && (
<>
<Text textStyle="p2" color="#111111">
{order.pantry.pantryName}
{order.request.pantry.pantryName}
</Text>
<Text mb={8} color="#52525B" textStyle="p2" pt={0} mt={0}>
Requested {formatDate(foodRequest.requestedAt)}
Expand Down
5 changes: 0 additions & 5 deletions apps/frontend/src/components/forms/pantryApplicationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ const PantryApplicationModal: React.FC<PantryApplicationModalProps> = ({
<Text fontWeight="bold">Phone</Text>
</GridItem>
<GridItem>{pantryUser.phone}</GridItem>

<GridItem>
<Text fontWeight="bold">Role</Text>
</GridItem>
<GridItem>{pantryUser.role}</GridItem>
</Grid>
) : (
<Text>No user details available.</Text>
Expand Down
211 changes: 109 additions & 102 deletions apps/frontend/src/containers/adminOrderManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ const AdminOrderManagement: React.FC = () => {

for (const order of data) {
const status = order.status;

const orderWithColor: OrderWithColor = { ...order };
if (order.pantry.volunteers && order.pantry.volunteers.length > 0) {
if (
order.request.pantry.volunteers &&
order.request.pantry.volunteers.length > 0
) {
orderWithColor.assigneeColor =
ASSIGNEE_COLORS[counters[status] % ASSIGNEE_COLORS.length];
counters[status]++;
Expand Down Expand Up @@ -170,15 +174,17 @@ const AdminOrderManagement: React.FC = () => {

// Get pantry options through all orders in the status
const pantryOptions = [
...new Set(allOrders.map((o) => o.pantry.pantryName)),
...new Set(allOrders.map((o) => o.request.pantry.pantryName)),
].sort((a, b) => a.localeCompare(b));

// Apply filters and sorting to all orders
const filteredOrders = allOrders
.filter(
(o) =>
filterState.selectedPantries.length === 0 ||
filterState.selectedPantries.includes(o.pantry.pantryName),
filterState.selectedPantries.includes(
o.request.pantry.pantryName,
),
)
.sort((a, b) =>
filterState.sortAsc
Expand Down Expand Up @@ -559,9 +565,9 @@ const OrderStatusSection: React.FC<OrderStatusSectionProps> = ({
{...tableHeaderStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
width="25%"
width="15%"
>
Pantry
Status
</Table.ColumnHeader>
<Table.ColumnHeader
{...tableHeaderStyles}
Expand All @@ -575,118 +581,119 @@ const OrderStatusSection: React.FC<OrderStatusSectionProps> = ({
{...tableHeaderStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
width="15%"
width="25%"
>
Status
Pantry
</Table.ColumnHeader>
<Table.ColumnHeader
{...tableHeaderStyles}
textAlign="right"
width="25%"
>
Date Started
Dates
</Table.ColumnHeader>
</Table.Row>
</Table.Header>
<Table.Body>
{orders.map((order, index) => (
<Table.Row
key={`${order.orderId}-${index}`}
_hover={{ bg: 'gray.50' }}
>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
<Button
variant="plain"
fontWeight="400"
textDecoration="underline"
onClick={() => onOrderSelect(order.orderId)}
>
{order.orderId}
</Button>
{selectedOrderId === order.orderId && (
<OrderDetailsModal
order={order}
isOpen={true}
onClose={() => onOrderSelect(null)}
/>
)}
</Table.Cell>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
{orders.map((order, index) => {
const pantry = order.request.pantry;
const volunteers = pantry.volunteers || [];

return (
<Table.Row
key={`${order.orderId}-${index}`}
_hover={{ bg: 'gray.50' }}
>
{order.pantry.pantryName}
</Table.Cell>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
<Box
direction="row"
display="flex"
alignItems="center"
justifyContent="center"
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
{order.pantry.volunteers &&
order.pantry.volunteers.length > 0 ? (
<Box
key={index}
borderRadius="full"
bg={order.assigneeColor || 'gray'}
width="33px"
height="33px"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
p={2}
>
{/* TODO: Change logic later to only get one volunteer */}
{order.pantry.volunteers[0].firstName
.charAt(0)
.toUpperCase()}
{order.pantry.volunteers[0].lastName
.charAt(0)
.toUpperCase()}
</Box>
) : (
<Box>No Assignees</Box>
<Button
variant="plain"
fontWeight="400"
textDecoration="underline"
onClick={() => onOrderSelect(order.orderId)}
>
{order.orderId}
</Button>
{selectedOrderId === order.orderId && (
<OrderDetailsModal
order={order}
isOpen={true}
onClose={() => onOrderSelect(null)}
/>
)}
</Box>
</Table.Cell>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
<Box
borderRadius="md"
bg={colors[0]}
color={colors[1]}
display="inline-block"
fontWeight="500"
my={2}
py={1}
px={3}
</Table.Cell>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
{capitalize(order.status)}
</Box>
</Table.Cell>
<Table.Cell
{...tableCellStyles}
textAlign="right"
color="neutral.700"
>
{formatDate(order.createdAt)}
</Table.Cell>
</Table.Row>
))}
<Box
borderRadius="md"
bg={colors[0]}
color={colors[1]}
display="inline-block"
fontWeight="500"
my={2}
py={1}
px={3}
>
{capitalize(order.status)}
</Box>
</Table.Cell>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
<Box
direction="row"
display="flex"
alignItems="center"
justifyContent="center"
>
{volunteers && volunteers.length > 0 ? (
<Box
key={index}
borderRadius="full"
bg={order.assigneeColor || 'gray'}
width="33px"
height="33px"
display="flex"
alignItems="center"
justifyContent="center"
color="white"
p={2}
>
{/* TODO: Change logic later to only get one volunteer */}
{volunteers[0].firstName.charAt(0).toUpperCase()}
{volunteers[0].lastName.charAt(0).toUpperCase()}
</Box>
) : (
<Box>No Assignees</Box>
)}
</Box>
</Table.Cell>
<Table.Cell
{...tableCellStyles}
borderRight="1px solid"
borderRightColor="neutral.100"
>
{pantry.pantryName}
</Table.Cell>
<Table.Cell
{...tableCellStyles}
textAlign="left"
color="neutral.700"
>
{formatDate(order.createdAt)}-
{order.deliveredAt && formatDate(order.deliveredAt)}
</Table.Cell>
</Table.Row>
);
})}
</Table.Body>
</Table.Root>

Expand Down
29 changes: 16 additions & 13 deletions apps/frontend/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Pantry {
secondaryContactPhone?: string;
pantryUser?: User;
status: PantryStatus;
dateApplied: Date;
dateApplied: string;
activities: Activity[];
activitiesComments?: string;
itemsInStock: string;
Expand Down Expand Up @@ -183,8 +183,8 @@ export interface FoodRequest {
requestedSize: string;
requestedItems: string[];
additionalInformation: string | null;
requestedAt: Date;
dateReceived: Date | null;
requestedAt: string;
dateReceived: string | null;
feedback: string | null;
photos: string[] | null;
orders?: Order[];
Expand Down Expand Up @@ -228,7 +228,7 @@ export interface CreateFoodRequestBody {
additionalInformation: string | null | undefined;
status: string;
fulfilledBy: number | null | undefined;
dateReceived: Date | null | undefined;
dateReceived: string | null | undefined;
feedback: string | null | undefined;
photos: string[] | null | undefined;
}
Expand Down Expand Up @@ -287,14 +287,17 @@ export interface OrderSummary {
orderId: number;
status: OrderStatus;
createdAt: string;
shippedAt: string | null;
deliveredAt: string | null;
pantry: {
pantryName: string;
volunteers?: {
id: number;
firstName: string;
lastName: string;
}[];
shippedAt?: string;
deliveredAt?: string;
request: {
pantryId: number;
pantry: {
pantryName: string;
volunteers?: {
id: number;
firstName: string;
lastName: string;
}[];
};
};
}