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

added order result and hardware info icons for order tables #44

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import React from "react";
import { render } from "@testing-library/react";
import OrdersFilter from "./OrdersCount";
import { makeStoreWithEntities } from "../../../testing/utils";
import { mockHardware, mockPendingOrders } from "../../../testing/mockData";
import { Provider } from "react-redux";
import OrdersCount from "./OrdersCount";

describe("<OrdersCount />", () => {
const store = makeStoreWithEntities({
hardware: mockHardware,
allOrders: mockPendingOrders,
});

it("Has necessary component elements", async () => {
const { getByText, getByTestId } = render(<OrdersFilter />);
const { getByText, getByTestId } = render(
<Provider store={store}>
{" "}
<OrdersCount />{" "}
</Provider>
);
expect(getByTestId("refreshOrders")).toBeInTheDocument();
expect(getByText("2 results")).toBeInTheDocument();
const expectedCount = mockPendingOrders.length;
expect(getByText(`${expectedCount} results`)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { IconButton, Typography } from "@material-ui/core";
import RefreshIcon from "@material-ui/icons/Refresh";
import styles from "pages/Orders/Orders.module.scss";
import { FormikValues } from "formik";
import { useSelector } from "react-redux";
import { adminOrderTotalSelector } from "../../../slices/order/adminOrderSlice";

const OrdersCount = ({ refreshOrders }: FormikValues) => {
const orderQuantity = useSelector(adminOrderTotalSelector);
return (
<div className={styles.ordersBodyToolbarRefresh}>
<Typography variant="body2">2 results</Typography>
<Typography variant="body2">{orderQuantity} results</Typography>
<IconButton
color="primary"
aria-label="Refresh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,9 @@ export const adminOrderNumStatusesSelector = createSelector(
(adminOrderSlice) => adminOrderSlice.numStatuses
);

export const adminOrderTotalSelector = createSelector(
[adminOrderSelectors.selectAll],
(orderItems) => orderItems.reduce((accum) => accum + 1, 0)
);

export const { setFilters, clearFilters } = actions;