Skip to content
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

IEEE-287 (adding new order statuses) #513

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0d5c650
modified helpers.ts to add new statuses
carmen-chau Jan 2, 2024
2ea6603
added rejected order status to types.ts
carmen-chau Jan 2, 2024
435e5a3
changed comment in types.ts
carmen-chau Jan 2, 2024
c7b27ac
updated helpers.ts comment
carmen-chau Jan 2, 2024
37f0b8a
added pink colour to differentiate UI order tags and time tags
carmen-chau Jan 2, 2024
515230b
added comments
carmen-chau Jan 2, 2024
6ae13b1
commented out line and added orderStatus
carmen-chau Jan 2, 2024
19a47ea
added pink styling
carmen-chau Jan 2, 2024
d55e7ba
added new UI chip tag for pending order
carmen-chau Jan 2, 2024
830d10d
added new status categories
carmen-chau Jan 2, 2024
f936150
added payload results for new statuses
carmen-chau Jan 2, 2024
d52667a
added view for pending order in admin table. button incomplete
carmen-chau Jan 2, 2024
44cc919
modified comment
carmen-chau Jan 2, 2024
5443960
changed hardware signout date to ensure testing was possible locally
carmen-chau Jan 2, 2024
a9776c9
additional changes
carmen-chau Jan 2, 2024
934c29e
modified pending order selector to fit new order statuses
carmen-chau Jan 2, 2024
6fbbe94
added new status to models.py
carmen-chau Jan 2, 2024
0814664
added files with uncertainties about change
carmen-chau Jan 2, 2024
38849aa
revert changes to type.ts
carmen-chau Jan 4, 2024
c8e63ae
removed rejected order status
carmen-chau Jan 4, 2024
7e497fa
deleted rejected payload
carmen-chau Jan 4, 2024
34f3023
renamed pending orders to packing
carmen-chau Jan 4, 2024
3123f6c
changed pending to packing
carmen-chau Jan 4, 2024
ae549df
changed pending orders to packing, changed migrations too
carmen-chau Jan 4, 2024
1fd1436
made ui label changes to orders table on admin side
carmen-chau Jan 4, 2024
91588b3
modified django backend files
carmen-chau Jan 4, 2024
2806011
added files
carmen-chau Jan 8, 2024
4331948
finish commit
carmen-chau Jan 8, 2024
a72bbc2
changes
carmen-chau Jan 8, 2024
e65b57b
add helpers
carmen-chau Jan 8, 2024
08e071a
resolved key issue in views.py
carmen-chau Jan 12, 2024
f29f40e
fixed checkmark box bug, added and revised comments
carmen-chau Jan 12, 2024
7f4f7c7
minor comment and formatting changes
carmen-chau Jan 14, 2024
66d3d11
added todo comment and fixed formatting of migration files
carmen-chau Jan 14, 2024
ff10be9
testing if this change helped pass api tests
carmen-chau Jan 14, 2024
9194b0c
formatted file
carmen-chau Jan 14, 2024
4ee7c34
revert changes to test_api.py
carmen-chau Jan 14, 2024
b2b70cc
revised a test in simpleOrderTable.test.tsx
carmen-chau Jan 14, 2024
2ef7970
modified more tests, made equality check stricter
carmen-chau Jan 14, 2024
f74e191
added a order with packing status to mockData.tsx
carmen-chau Jan 14, 2024
5a90474
added todo comment
carmen-chau Jan 14, 2024
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
24 changes: 21 additions & 3 deletions hackathon_site/dashboard/frontend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export const teamOrderListSerialization = (

const hardwareInTableRow = Object.values(hardwareItems);
if (hardwareInTableRow.length > 0)
(order.status === "Submitted" || order.status === "Ready for Pickup"
(order.status === "Submitted" ||
order.status === "Ready for Pickup" ||
order.status === "Packing" //TODO: Treating "Packing" orders (aka orders in progress of packing) as "Pending Orders" per table in participant side
? pendingOrders
: checkedOutOrders
).push({
Expand Down Expand Up @@ -182,11 +184,14 @@ export const sortCheckedOutOrders = (
export const sortPendingOrders = (orders: OrderInTable[]): OrderInTable[] => {
let ready_orders = [];
let submitted_orders = [];
let packing_orders = []; // Added new array to ensure sorting of orders being packed accomodates for the orders with "packing" tag. This likely helps with the order display on the admin + participant table
for (let order of orders) {
if (order.status === "Ready for Pickup") {
ready_orders.push(order);
} else {
} else if (order.status === "Submitted") {
submitted_orders.push(order);
} else if (order.status === "Packing") {
packing_orders.push(order);
}
}
ready_orders.sort((order1, order2) => {
Expand All @@ -202,7 +207,20 @@ export const sortPendingOrders = (orders: OrderInTable[]): OrderInTable[] => {
new Date(order2.updatedTime).valueOf()
);
});
// Sorting packing orders
packing_orders.sort((order1, order2) => {
return (
new Date(order1.updatedTime).valueOf() -
new Date(order2.updatedTime).valueOf()
);
});

orders.splice(0, orders.length, ...submitted_orders, ...ready_orders);
orders.splice(
0,
orders.length,
...submitted_orders,
...ready_orders,
...packing_orders
);
return orders;
};
13 changes: 7 additions & 6 deletions hackathon_site/dashboard/frontend/src/api/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import ReadyForPickupIcon from "assets/images/icons/statusIcons/readyforpickup-s
import PickedUpIcon from "assets/images/icons/statusIcons/checkout-status.svg";
import CancelledIcon from "assets/images/icons/statusIcons/cancelled-status.svg";
import ReturnedIcon from "assets/images/icons/statusIcons/checkout-status.svg";
import PendingIcon from "assets/images/icons/statusIcons/pending-status.svg";
import InProgressIcon from "assets/images/icons/statusIcons/inprogress-status.svg";
import PackingIcon from "assets/images/icons/statusIcons/pending-status.svg";
//TODO: A low-priority task, but perhaps looking into changing the PackingIcon to be a more accurate fit
//import InProgressIcon from "assets/images/icons/statusIcons/inprogress-status.svg";

import styles from "components/orders/OrdersTable/OrdersTable.module.scss";

Expand All @@ -14,8 +15,8 @@ export const statusIconMap: { [key: string]: string } = {
PickedUp: PickedUpIcon,
Cancelled: CancelledIcon,
Returned: ReturnedIcon,
Pending: PendingIcon,
InProgress: InProgressIcon,
Packing: PackingIcon,
//InProgress: InProgressIcon, //Commented out since we likely don't need this status anymore (Packing should mean the same thing as "In Progress?")
};

export const statusStylesMap: { [key: string]: string } = {
Expand All @@ -24,6 +25,6 @@ export const statusStylesMap: { [key: string]: string } = {
PickedUp: styles.PickedUpIcon,
Cancelled: styles.CancelledIcon,
Returned: styles.ReturnedIcon,
Pending: styles.PendingIcon,
InProgress: styles.InProgressIcon,
Packing: styles.PackingIcon,
//InProgress: styles.InProgressIcon, //Commented out since we likely don't need this status anymore (Packing should mean the same thing as "In Progress?")
};
3 changes: 2 additions & 1 deletion hackathon_site/dashboard/frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export type OrderStatus =
| "Cancelled"
| "Returned"
| "Pending"
| "In Progress";
| "In Progress"
| "Packing";
export type PartReturnedHealth = "Healthy" | "Heavily Used" | "Broken" | "Lost";

export type ItemsInOrder = Omit<OrderItem, "order" | "time_occurred">;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ $colors: (
blueLight: #c3e1ef,
purple: #800080,
purpleLight: #cec4f2,
// added the pink colours. pink is now used to rep the "Updated at" UI tag. blue is now used to rep the "Packing" order tag (to mirror the order table on admin side created in prior merged PR [IEEE 269])
pink: #ff007f,
pinkLight: #ffc0cb,
);

$fonts: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ export const CheckedOutTables = () =>
>
<GeneralOrderTableTitle
orderId={checkedOutOrder.id}
orderStatus={checkedOutOrder.status} // Added the orderStatus element to render UI tag
createdTime={checkedOutOrder.createdTime}
updatedTime={checkedOutOrder.updatedTime}
additionalChipFormatting={true}
//additionalChipFormatting={true} // Commented out this line, not used
/>
<TableContainer
component={Paper}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
}
}

&Pink {
background-color: color(pinkLight);
svg {
color: color(pink);
}
}

&Blue {
background-color: color(blueLight);
svg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import WatchLater from "@material-ui/icons/WatchLater";
import Error from "@material-ui/icons/Error";
import EditIcon from "@material-ui/icons/Edit";
import UpdateIcon from "@material-ui/icons/Update";
import HourglassEmptyIcon from "@material-ui/icons/HourglassEmpty";
import {
Paper,
Table,
Expand Down Expand Up @@ -42,6 +43,15 @@ export const ChipStatus = ({ status }: { status: OrderStatus | "Error" }) => {
className={`${styles.chipOrange} ${styles.chip}`}
/>
);
//TODO: How is the following case going to be triggered?
case "Packing":
return (
<Chip
icon={<HourglassEmptyIcon />}
label="Packing"
className={`${styles.chipBlue} ${styles.chip}`} //Made the colour of this tag blue to match the admin order table colour for the Pending tag
/>
);
case "Error":
return (
<Chip
Expand Down Expand Up @@ -86,16 +96,16 @@ interface GeneralOrderTableTitleProps {
orderStatus?: OrderStatus;
createdTime?: string;
updatedTime?: string;
additionalChipFormatting?: boolean;
//additionalChipFormatting?: boolean; //TODO: Commented out since not used
}

export const GeneralOrderTableTitle = ({
orderId,
orderStatus,
createdTime,
updatedTime,
additionalChipFormatting,
}: GeneralOrderTableTitleProps) => (
}: //additionalChipFormatting, //TODO: Commented out since not used
GeneralOrderTableTitleProps) => (
<div className={styles.titleChip}>
<Typography variant="h2" className={styles.titleChipText}>
Order #{orderId}
Expand All @@ -113,7 +123,7 @@ export const GeneralOrderTableTitle = ({
<Chip
label={[<b>Updated at: </b>, formatDateTime(updatedTime)]}
icon={<UpdateIcon />}
className={`${styles.chipBlue} ${styles.chip}`}
className={`${styles.chipPink} ${styles.chip}`}
/>
</div>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const OrderFilter = ({ handleReset, handleSubmit }: FormikValues) => {
status: "Returned",
numOrders: numStatuses["Returned"],
},
{
status: "Packing", // TODO: Packing -> interpreted as "currently building". This alligns with table changes in IEEE 269
numOrders: numStatuses["Packing"],
},
];

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
background-color: #d9d9d9;
}

.PendingIcon {
.PackingIcon {
color: #2b7bbc;
background-color: #c3e1ef;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ describe("<SimplePendingOrderFulfillmentTable />", () => {
} else {
expect(getByText(/reject order/i)).toBeInTheDocument();
}
if (status === "Submitted") {
if (status === "Packing") {
/*TODO: Changed from status === "Submitted" to status === "Packing"*/
expect(getByText(/complete order/i)).toBeInTheDocument();
expect(queryByText(/picked up/i)).not.toBeInTheDocument();
} else {
} else if (status === "Submitted") {
expect(queryByText(/complete order/i)).not.toBeInTheDocument();
expect(getByText(/picked up/i)).toBeInTheDocument();
expect(queryByText(/ready for packing/i)).toBeInTheDocument();
//expect(queryByText(/complete order/i)).not.toBeInTheDocument();
//expect(getByText(/picked up/i)).toBeInTheDocument();
}
}
});
Expand All @@ -79,7 +82,8 @@ describe("<SimplePendingOrderFulfillmentTable />", () => {
const { queryByDisplayValue, getByDisplayValue } = within(
getByTestId(`admin-simple-pending-order-${order.id}`)
);
if (order.status == "Submitted") {
if (order.status === "Packing") {
/*TODO: Changed from status === "Submitted" to status === "Packing"*/
order.hardwareInTableRow.forEach(({ id }) => {
expect(getByDisplayValue(`hardware-${id}`)).toBeInTheDocument();
});
Expand All @@ -101,7 +105,9 @@ describe("<SimplePendingOrderFulfillmentTable />", () => {
});

mockPendingOrdersInTable
.filter(({ status }) => status === "Submitted")
.filter(
({ status }) => status === "Packing"
) /*TODO: Changed from status === "Submitted" to status === "Packing"*/
.map(({ id }) => {
const { getByText } = within(
getByTestId(`admin-simple-pending-order-${id}`)
Expand All @@ -116,7 +122,9 @@ describe("<SimplePendingOrderFulfillmentTable />", () => {
});

const order = mockPendingOrdersInTable.find(
({ status }) => status === "Submitted"
({ status }) =>
status ===
"Packing" /*TODO: Changed from status === "Submitted" to status === "Packing"*/
);

if (order) {
Expand Down Expand Up @@ -147,7 +155,9 @@ describe("<SimplePendingOrderFulfillmentTable />", () => {
});

const order = mockPendingOrdersInTable.find(
({ status }) => status === "Submitted"
({ status }) =>
status ===
"Packing" /*TODO: Changed from status === "Submitted" to status === "Packing"*/
);

if (order) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const SimplePendingOrderFulfillmentTable = () => {
<GeneralPendingTable
{...{
pendingOrder,
...(pendingOrder.status === "Submitted" &&
...(pendingOrder.status === "Packing" && //This code defines the checkboxes that appear for pending orders. NOTE: changed from === "Submitted" to === "Packing"
enableCheckboxColumn(pendingOrder)),
}}
/>
Expand All @@ -202,7 +202,7 @@ export const SimplePendingOrderFulfillmentTable = () => {
spacing={1}
style={{ marginTop: "10px" }}
>
{pendingOrder.status === "Submitted" && (
{pendingOrder.status === "Submitted" && ( //Will not need to add this to the packing orders, since there is no reason to reject an order that is already being packed.
<Grid item>
<Button
color="secondary"
Expand All @@ -219,8 +219,61 @@ export const SimplePendingOrderFulfillmentTable = () => {
</Button>
</Grid>
)}

{/* On Admin side: The code below adds a button that changes "Submitted" status => "Packing"*/}
{pendingOrder.status === "Submitted" && (
<CompleteOrderButton order={pendingOrder} />
<Grid item>
<Tooltip
title="Order is being packed"
placement="top"
>
<span>
<Button
color="primary" //TODO: Keeping this button "navy blue" (ie: The colour flagged for "primary" tag) to differentiate from the red "Picked up" buttons
variant="contained"
disableElevation
onClick={() =>
updateOrder(
pendingOrder.id,
"Packing"
)
}
>
Ready for packing
</Button>
</span>
</Tooltip>
</Grid>
)}

{/* On Admin side: The code below adds a button that changes "Packing" status => "Ready for Pickup"*/}
{pendingOrder.status === "Packing" && (
<Grid item>
<Tooltip
title="Order is being packed"
placement="top"
>
<span>
<CompleteOrderButton
order={pendingOrder}
/>
{/*Commented out the code below since it caused a bug where if someone doesn't select all orders prior to pressing button, order status changes... */}
{/*<Button*/}
{/* color="primary" //TODO: Keeping this button "navy blue" (ie: The colour flagged for "primary" tag) to differentiate from the red "Picked up" buttons*/}
{/* variant="contained"*/}
{/* disableElevation*/}
{/* onClick={() =>*/}
{/* updateOrder(*/}
{/* pendingOrder.id,*/}
{/* "Ready for Pickup"*/}
{/* )*/}
{/* }*/}
{/*>*/}
{/* Complete order*/}
{/*</Button>*/}
</span>
</Tooltip>
</Grid>
)}
{pendingOrder.status === "Ready for Pickup" && (
<Grid item>
Expand Down
2 changes: 1 addition & 1 deletion hackathon_site/dashboard/frontend/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export const adminGroup = "Hardware Site Admins";
export const minTeamSize = 2;
export const maxTeamSize = 4;
export const hardwareSignOutStartDate = new Date(2020, 9, 1, 23, 59);
export const hardwareSignOutEndDate = new Date(2023, 9, 30, 11, 59);
export const hardwareSignOutEndDate = new Date(2024, 9, 30, 11, 59);
export const hssTestUserGroup = "HSS Test Users";
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface numStatuses {
"Picked Up"?: number;
Cancelled?: number;
Returned?: number;
//TODO: New entries added
Packing?: number;
}

interface adminOrderExtraState {
Expand Down Expand Up @@ -153,6 +155,15 @@ const adminOrderSlice = createSlice({
"Returned",
payload.results
);

//TODO: COMMENTED OUT MOCK DATA HERE FOR NOW
// TODO: Is using payload.results essentially retrieving the "real data" from the (django?) backend?
// state.numStatuses["Pending"] = 3; //Not sure why the above line works fine... somehow feature was already implemented?
//state.numStatuses["Rejected"] = 21;
state.numStatuses["Packing"] = numOrdersByStatus(
"Packing",
payload.results
);
}
adminOrderAdapter.setAll(state, payload.results);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ export const pendingOrdersSelector = createSelector(
(orders) =>
orders.filter(
(order) =>
order.status === "Submitted" || order.status === "Ready for Pickup"
order.status === "Submitted" ||
order.status === "Ready for Pickup" ||
order.status === "Packing"
)
);

Expand Down
Loading
Loading