
* Handle limit reached error * Update changelog * Move notifications to higher layer * Handle limits top-level * Remove unused imports * Add alert component * Fetch limits from API * Display limits in staff list * Fix disabled text button color * Display limits in products pages * Display limits in channel list * Display limits in warehouse list * Display limits in order list * Add stories for limits * Move alert to corresponding section * Update schema * Update changelog * Fetch only needed limitations * Fix types * Fix story * Display limits in variant creator * Improve type consistency * Update snapshots * Update limit counter after object deletion * Fix copy * Improve code readability * Lint files * Fix dark mode alerts * Improve contrast * Fix sku limit in product variant list * Update stories * Update messages * Extract messages
127 lines
3.7 KiB
TypeScript
127 lines
3.7 KiB
TypeScript
import Button from "@material-ui/core/Button";
|
|
import Card from "@material-ui/core/Card";
|
|
import Alert from "@saleor/components/Alert/Alert";
|
|
import CardMenu from "@saleor/components/CardMenu";
|
|
import Container from "@saleor/components/Container";
|
|
import FilterBar from "@saleor/components/FilterBar";
|
|
import PageHeader from "@saleor/components/PageHeader";
|
|
import { RefreshLimits_shop_limits } from "@saleor/components/Shop/types/RefreshLimits";
|
|
import { sectionNames } from "@saleor/intl";
|
|
import { OrderListUrlSortField } from "@saleor/orders/urls";
|
|
import { makeStyles } from "@saleor/theme";
|
|
import { FilterPageProps, PageListProps, SortPage } from "@saleor/types";
|
|
import { isLimitReached } from "@saleor/utils/limits";
|
|
import React from "react";
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
import { OrderList_orders_edges_node } from "../../types/OrderList";
|
|
import OrderList from "../OrderList";
|
|
import {
|
|
createFilterStructure,
|
|
OrderFilterKeys,
|
|
OrderListFilterOpts
|
|
} from "./filters";
|
|
|
|
export interface OrderListPageProps
|
|
extends PageListProps,
|
|
FilterPageProps<OrderFilterKeys, OrderListFilterOpts>,
|
|
SortPage<OrderListUrlSortField> {
|
|
limits: RefreshLimits_shop_limits;
|
|
orders: OrderList_orders_edges_node[];
|
|
onSettingsOpen: () => void;
|
|
}
|
|
|
|
const useStyles = makeStyles(
|
|
theme => ({
|
|
settings: {
|
|
marginRight: theme.spacing(2)
|
|
}
|
|
}),
|
|
{ name: "OrderListPage" }
|
|
);
|
|
|
|
const OrderListPage: React.FC<OrderListPageProps> = ({
|
|
currentTab,
|
|
initialSearch,
|
|
filterOpts,
|
|
limits,
|
|
tabs,
|
|
onAdd,
|
|
onAll,
|
|
onSearchChange,
|
|
onSettingsOpen,
|
|
onFilterChange,
|
|
onTabChange,
|
|
onTabDelete,
|
|
onTabSave,
|
|
...listProps
|
|
}) => {
|
|
const intl = useIntl();
|
|
const classes = useStyles({});
|
|
const filterStructure = createFilterStructure(intl, filterOpts);
|
|
|
|
return (
|
|
<Container>
|
|
<PageHeader title={intl.formatMessage(sectionNames.orders)}>
|
|
{!!onSettingsOpen && (
|
|
<CardMenu
|
|
className={classes.settings}
|
|
menuItems={[
|
|
{
|
|
label: intl.formatMessage({
|
|
defaultMessage: "Order Settings",
|
|
description: "button"
|
|
}),
|
|
onSelect: onSettingsOpen
|
|
}
|
|
]}
|
|
/>
|
|
)}
|
|
<Button
|
|
color="primary"
|
|
variant="contained"
|
|
onClick={onAdd}
|
|
data-test-id="create-order-button"
|
|
>
|
|
<FormattedMessage
|
|
defaultMessage="Create order"
|
|
description="button"
|
|
/>
|
|
</Button>
|
|
</PageHeader>
|
|
<Alert
|
|
show={isLimitReached(limits, "orders")}
|
|
title={intl.formatMessage({
|
|
defaultMessage: "Order limit reached",
|
|
description: "alert"
|
|
})}
|
|
>
|
|
<FormattedMessage defaultMessage="You have reached your order limit, you will be billed extra for orders above limit. If you would like to up your limit, contact your administration staff about raising your limits." />
|
|
</Alert>
|
|
<Card>
|
|
<FilterBar
|
|
currentTab={currentTab}
|
|
initialSearch={initialSearch}
|
|
onAll={onAll}
|
|
onFilterChange={onFilterChange}
|
|
onSearchChange={onSearchChange}
|
|
onTabChange={onTabChange}
|
|
onTabDelete={onTabDelete}
|
|
onTabSave={onTabSave}
|
|
tabs={tabs}
|
|
allTabLabel={intl.formatMessage({
|
|
defaultMessage: "All Orders",
|
|
description: "tab name"
|
|
})}
|
|
filterStructure={filterStructure}
|
|
searchPlaceholder={intl.formatMessage({
|
|
defaultMessage: "Search Orders..."
|
|
})}
|
|
/>
|
|
<OrderList {...listProps} />
|
|
</Card>
|
|
</Container>
|
|
);
|
|
};
|
|
OrderListPage.displayName = "OrderListPage";
|
|
export default OrderListPage;
|