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 269 create table for orders page #500

Merged
merged 32 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
16d929b
orders table init
natapokie Jun 11, 2023
6a3c4f0
adding status icon
natapokie Jun 11, 2023
d3a110b
adding event handler for row double click & files
natapokie Jun 11, 2023
72636e0
adding more statuses
natapokie Jun 11, 2023
497ea7f
adding unit tests
natapokie Jun 11, 2023
7d8047f
reverting yarn lock, seemed to have issues with testing
natapokie Jun 11, 2023
f9639d5
changing node version to 16 for mui data grid
natapokie Jun 13, 2023
2408a91
cleaning up icon code
natapokie Jun 13, 2023
408441d
updating github actions
natapokie Jun 13, 2023
6878650
trying again
natapokie Jun 13, 2023
ca13631
one more time...
natapokie Jun 13, 2023
a697249
trying this...
natapokie Jun 13, 2023
6c28153
Update main.yml
natapokie Jun 13, 2023
9b51226
Merge branch 'develop' into IEEE-269-create-table-for-orders-page
Mustaballer Jun 16, 2023
d40715d
adding styles to module.scss
natapokie Jun 20, 2023
ae5f5f6
making team id visible
natapokie Jun 20, 2023
7698d6f
changing imports
natapokie Jun 20, 2023
351d4f2
adding dependencies
natapokie Jun 20, 2023
7cfca00
Merge branch 'develop' into IEEE-269-create-table-for-orders-page
natapokie Sep 10, 2023
6108852
fixing some code & commenting all tests for order cards
natapokie Sep 11, 2023
c5cdef9
removing mockdata
natapokie Sep 16, 2023
9420271
commenting out unused vars
natapokie Sep 17, 2023
140e43f
cleaning up code
natapokie Sep 17, 2023
f187767
adding more tests
natapokie Sep 17, 2023
5e717ba
adding handle double row click event
natapokie Sep 17, 2023
eca42e8
adding test to check for proper hanlding of double row click
natapokie Sep 17, 2023
526a86f
using type any for valueGetter function
natapokie Sep 17, 2023
443a87d
remove unused vars
natapokie Sep 17, 2023
2319418
removing comments
natapokie Oct 4, 2023
5076466
Merge branch 'develop' into IEEE-269-create-table-for-orders-page
Mustaballer Oct 22, 2023
dd7edc4
adding style to make the grid white
natapokie Nov 14, 2023
5fe3459
Merge branch 'IEEE-269-create-table-for-orders-page' of https://githu…
natapokie Nov 14, 2023
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
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ jobs:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 12.x
uses: actions/setup-node@v1
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: '12.x'
node-version: 16.x
- name: Install dependencies
run: yarn install
- name: Formatting check
Expand All @@ -62,14 +62,14 @@ jobs:
working-directory: hackathon_site/dashboard/frontend

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 12.x
uses: actions/setup-node@v1
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: '12.x'
node-version: 16.x
- name: Install dependencies
run: yarn install
- name: Formatting check
Expand Down
5 changes: 5 additions & 0 deletions hackathon_site/dashboard/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@material-ui/core": "^4.9.13",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.52",
"@mui/material": "^5.13.4",
"@mui/x-data-grid": "^6.7.0",
"@reduxjs/toolkit": "^1.3.6",
"@types/jest": "^26.0.23",
"@types/node": "^15.0.2",
Expand All @@ -14,6 +18,7 @@
"@types/yup": "^0.29.13",
"axios": "^0.21.1",
"connected-react-router": "^6.8.0",
"date-fns": "^2.30.0",
"formik": "^2.1.4",
"history": "^4.10.1",
"lint-staged": "^10.2.2",
Expand Down
36 changes: 36 additions & 0 deletions hackathon_site/dashboard/frontend/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,39 @@
white-space: nowrap;
}
}

// for OrdersTable
.order-Submitted-icon {
natapokie marked this conversation as resolved.
Show resolved Hide resolved
color: #b7941e;
background-color: #ffe899;
}

.order-ReadyforPickup-icon {
color: #43a047;
background-color: #c1edc1;
}

.order-PickedUp-icon {
color: #757575;
background-color: #d9d9d9;
}

.order-Cancelled-icon {
color: #b00020;
background-color: #ebbcbc;
}

.order-Returned-icon {
color: #757575;
background-color: #d9d9d9;
}

.order-Pending-icon {
color: #2b7bbc;
background-color: #c3e1ef;
}

.order-InProgress-icon {
color: #ffa000;
background-color: #ffe3b4;
}
17 changes: 17 additions & 0 deletions hackathon_site/dashboard/frontend/src/api/orders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import SubmittedIcon from "../assets/images/icons/statusIcons/unfulfilled-status.svg";
natapokie marked this conversation as resolved.
Show resolved Hide resolved
import ReadyForPickupIcon from "../assets/images/icons/statusIcons/readyforpickup-status.svg";
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";

export const statusIconMap: { [key: string]: string } = {
Submited: SubmittedIcon,
ReadyforPickup: ReadyForPickupIcon,
PickedUp: PickedUpIcon,
Cancelled: CancelledIcon,
Returned: ReturnedIcon,
Pending: PendingIcon,
InProgress: InProgressIcon,
};
4 changes: 3 additions & 1 deletion hackathon_site/dashboard/frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export type OrderStatus =
| "Ready for Pickup"
| "Picked Up"
| "Cancelled"
| "Returned";
| "Returned"
| "Pending"
| "In Progress";
export type PartReturnedHealth = "Healthy" | "Heavily Used" | "Broken" | "Lost";

export type ItemsInOrder = Omit<OrderItem, "order" | "time_occurred">;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "../../../assets/abstracts/mixins";
@import "../../../assets/abstracts/variables";

.container {
display: flex;
flex-direction: row;
align-content: center;
justify-content: start;

width: 100%;
padding: 4px;
border-radius: 50px;
}

.statusIcon {
width: 12px;
margin-left: 5px;
margin-right: 10px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import { render, within } from "testing/utils";
import { DataGrid, GridRowsProp, GridColDef } from "@mui/x-data-grid";
import { mockPendingOrders } from "testing/mockData";
import { OrdersTable } from "./OrdersTable";

describe("Orders Table", () => {
test("renders order table", () => {
const { container } = render(<OrdersTable ordersData={mockPendingOrders} />);
// find the rendered Data Grid
const dataGrid = container.querySelector(".MuiDataGrid-root");
expect(dataGrid).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React from "react";
import { DataGrid, GridColDef, GridEventListener } from "@mui/x-data-grid";
import { ItemsInOrder, Order } from "api/types";
import { format, parseISO } from "date-fns"; // to parse date
import { statusIconMap } from "api/orders";
import styles from "./OrdersTable.module.scss";

// status icons

interface OrdersTableProps {
ordersData: Order[];
}

interface OrderStateIcon {
status: string;
}

interface StatusIcon {
status: string;
}

const StatusIcon = ({ status }: StatusIcon) => {
const iconSrc = statusIconMap[status];
return <img src={iconSrc} className={styles.statusIcon} alt={`${status} icon`} />;
};

const OrderStateIcon = ({ status }: OrderStateIcon) => {
const filterState: string = status.replace(/\s+/g, "");
console.log(filterState);

return (
<div className={styles.container}>
<div className={`${styles.container} order-${filterState}-icon`}>
<StatusIcon status={filterState} />
{status}
</div>
</div>
);
};

const handleEvent: GridEventListener<"rowClick"> = (
params, // GridRowParams
event, // MuiEvent<React.MouseEvent<HTMLElement>>
details // GridCallbackDetails
) => {
console.log("clicked", params.row);
natapokie marked this conversation as resolved.
Show resolved Hide resolved
natapokie marked this conversation as resolved.
Show resolved Hide resolved
};

const OrdersTable = ({ ordersData }: OrdersTableProps) => {
const columns: GridColDef[] = [
{ field: "id", headerName: "ID", width: 25, flex: 1 },
{
field: "created_at",
headerName: "Time Ordered",
flex: 1,
valueFormatter: (params) => {
const time = params.value as string;
const date = parseISO(time);
const formattedTime = format(date, "MMM d, HH:mm");
return formattedTime;
},
},
{ field: "team_code", headerName: "Team", flex: 1 },
{
field: "items",
headerName: "Order Qty",
flex: 1,
valueGetter: (params) => {
natapokie marked this conversation as resolved.
Show resolved Hide resolved
let orderQty: number = 0;
const items = params?.value as ItemsInOrder[];
try {
orderQty = items.length;
} catch (err) {
return 0;
}
return orderQty;
},
},
{
field: "status",
headerName: "Status",
minWidth: 250,
renderCell: (params) => <OrderStateIcon status={params.value} />,
},
{ field: "team_id", headerName: "Team ID" },
{ field: "updated_at", headerName: "Updated At" },
{ field: "request", headerName: "Request" },
];

return (
<>
<div style={{ width: "100%", height: "700px" }}>
<DataGrid
rows={ordersData}
columns={columns}
// pageSize={10} // not available in free version
natapokie marked this conversation as resolved.
Show resolved Hide resolved
autoPageSize={true} // adjusts page size to fit available area
pageSizeOptions={[5, 10, 15]}
columnVisibilityModel={{
// hide specific columns
team_id: false,
natapokie marked this conversation as resolved.
Show resolved Hide resolved
updated_at: false,
request: false,
}}
initialState={{
pagination: {
paginationModel: { pageSize: 25, page: 0 },
natapokie marked this conversation as resolved.
Show resolved Hide resolved
},
}}
onRowDoubleClick={handleEvent}
/>
</div>
</>
);
};

export { OrdersTable };
7 changes: 5 additions & 2 deletions hackathon_site/dashboard/frontend/src/pages/Orders/Orders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
} from "slices/order/adminOrderSlice";
import { useHistory } from "react-router-dom";
import { clearFilters } from "slices/hardware/hardwareSlice";
import { OrdersTable } from "components/orders/OrdersTable/OrdersTable";
import { mockPendingOrders } from "testing/mockData";

const Orders = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -86,7 +88,8 @@ const Orders = () => {
</Grid>
<Grid item lg={12}>
<Grid container spacing={1} direction="row">
{allOrders.map((order, idx) => (
<OrdersTable ordersData={mockPendingOrders} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used mockPendingOrders for now, but will later be replaced with allOrders from redux

{/* {allOrders.map((order, idx) => (
<Grid
item
lg={3}
Expand Down Expand Up @@ -115,7 +118,7 @@ const Orders = () => {
/>
)}
</Grid>
))}
))} */}
</Grid>
</Grid>
</Grid>
Expand Down
Loading