Skip to content
30 changes: 21 additions & 9 deletions hackathon_site/dashboard/frontend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const teamOrderListSerialization = (
(hardwareRequested[hardware.id] = hardware.requested_quantity)
);
order.items.forEach(({ id, hardware_id, part_returned_health }) => {
if (part_returned_health) {
if (part_returned_health && part_returned_health !== "Rejected") {
const returnItemKey = `${hardware_id}-${part_returned_health}`;
if (returnedItems[returnItemKey])
returnedItems[returnItemKey].quantity += 1;
Expand All @@ -55,14 +55,26 @@ export const teamOrderListSerialization = (
};
}
} else {
if (hardwareItems[hardware_id])
hardwareItems[hardware_id].quantityGranted += 1;
else
hardwareItems[hardware_id] = {
id: hardware_id,
quantityGranted: 1,
quantityRequested: hardwareRequested[hardware_id],
};
if (
!(
part_returned_health === "Rejected" &&
order.status === "Picked Up"
)
) {
if (hardwareItems[hardware_id]) {
if (part_returned_health !== "Rejected")
hardwareItems[hardware_id].quantityGranted += 1;
hardwareItems[hardware_id].quantityGrantedBySystem += 1;
} else {
hardwareItems[hardware_id] = {
id: hardware_id,
quantityGranted:
part_returned_health === "Rejected" ? 0 : 1,
quantityRequested: hardwareRequested[hardware_id],
quantityGrantedBySystem: 1,
};
}
}
}
hardwareIdsToFetch[hardware_id] = hardware_id;
});
Expand Down
9 changes: 8 additions & 1 deletion hackathon_site/dashboard/frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ export type OrderStatus =
| "Picked Up"
| "Cancelled"
| "Returned";
export type PartReturnedHealth = "Healthy" | "Heavily Used" | "Broken" | "Lost";
export type PartReturnedHealth =
| "Healthy"
| "Heavily Used"
| "Broken"
| "Lost"
| "Rejected";

export type ItemsInOrder = Omit<OrderItem, "order" | "time_occurred">;

Expand All @@ -127,13 +132,15 @@ export interface OrderFilters {
ordering?: OrderOrdering;
status?: OrderStatus[];
search?: string;
limit?: number;
}

/** Sanitized Orders */
export interface OrderItemTableRow {
id: number;
quantityRequested: number;
quantityGranted: number;
quantityGrantedBySystem: number;
}

export interface OrderInTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ export const EnhancedOrderFilter = () => {
const dispatch = useDispatch();

const handleSubmit = ({ ordering, status }: OrderFilters) => {
const limit = 1000;
const filters: OrderFilters = {
ordering,
status,
limit,
};
dispatch(setFilters(filters));
dispatch(getOrdersWithFilters());
Expand All @@ -185,6 +187,7 @@ export const EnhancedOrderFilter = () => {
initialValues={{
ordering: "",
status: [],
limit: 1000,
}}
onSubmit={handleSubmit}
onReset={handleReset}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const TeamActionTable = () => {
];

return (
<Grid container direction="column" spacing={1} item md={6} xs={12}>
<Grid container direction="column" spacing={1} item md={4} xs={12}>
<Grid item>
<Typography variant="h2">Actions</Typography>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TableContainer,
TableHead,
TableRow,
Typography,
} from "@material-ui/core";
import React, { useState } from "react";
import Container from "@material-ui/core/Container";
Expand Down Expand Up @@ -398,6 +399,13 @@ export const TeamCheckedOutOrderTable = () => {
spacing={1}
style={{ marginTop: "10px" }}
>
<Grid item style={{ marginTop: "5px" }}>
<Typography variant="body2">
Note: participants will receive an
email every time you change the
status of their order.
</Typography>
</Grid>
<Grid item>
<Button
color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const TeamInfoTable = () => {
};

return (
<Grid container direction="column" spacing={1} item md={6} xs={12}>
<Grid container direction="column" spacing={1} item md={8} xs={12}>
<Grid item>
<Typography variant="h2">Team info</Typography>
</Grid>
Expand Down
Loading