2019-06-19 14:40:52 +00:00
|
|
|
import Card from "@material-ui/core/Card";
|
|
|
|
import {
|
|
|
|
createStyles,
|
|
|
|
Theme,
|
|
|
|
withStyles,
|
|
|
|
WithStyles
|
|
|
|
} from "@material-ui/core/styles";
|
|
|
|
import Table from "@material-ui/core/Table";
|
|
|
|
import TableBody from "@material-ui/core/TableBody";
|
|
|
|
import TableCell from "@material-ui/core/TableCell";
|
|
|
|
import TableRow from "@material-ui/core/TableRow";
|
|
|
|
import Typography from "@material-ui/core/Typography";
|
|
|
|
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-27 09:35:54 +00:00
|
|
|
import { FormattedMessage } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-08 14:19:24 +00:00
|
|
|
import RequirePermissions from "@saleor/components/RequirePermissions";
|
2019-06-19 14:40:52 +00:00
|
|
|
import Skeleton from "@saleor/components/Skeleton";
|
2019-10-08 14:19:24 +00:00
|
|
|
import { UserPermissionProps } from "@saleor/types";
|
|
|
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-28 16:16:49 +00:00
|
|
|
const styles = theme =>
|
2019-06-19 14:40:52 +00:00
|
|
|
createStyles({
|
|
|
|
arrowIcon: {
|
2019-10-28 16:16:49 +00:00
|
|
|
width: theme.spacing(4)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
tableRow: {
|
|
|
|
cursor: "pointer"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-08 14:19:24 +00:00
|
|
|
interface HomeNotificationTableProps extends UserPermissionProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
ordersToCapture: number;
|
|
|
|
ordersToFulfill: number;
|
|
|
|
productsOutOfStock: number;
|
|
|
|
onOrdersToFulfillClick: () => void;
|
|
|
|
onOrdersToCaptureClick: () => void;
|
|
|
|
onProductsOutOfStockClick: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const HomeNotificationTable = withStyles(styles, {
|
|
|
|
name: "HomeNotificationTable"
|
|
|
|
})(
|
|
|
|
({
|
|
|
|
classes,
|
|
|
|
onOrdersToCaptureClick,
|
|
|
|
onOrdersToFulfillClick,
|
|
|
|
onProductsOutOfStockClick,
|
|
|
|
ordersToCapture,
|
|
|
|
ordersToFulfill,
|
2019-10-08 14:19:24 +00:00
|
|
|
productsOutOfStock,
|
|
|
|
userPermissions
|
|
|
|
}: HomeNotificationTableProps & WithStyles<typeof styles>) => (
|
2019-08-27 09:35:54 +00:00
|
|
|
<Card>
|
|
|
|
<Table>
|
|
|
|
<TableBody className={classes.tableRow}>
|
2019-10-08 14:19:24 +00:00
|
|
|
<RequirePermissions
|
|
|
|
userPermissions={userPermissions}
|
|
|
|
requiredPermissions={[PermissionEnum.MANAGE_ORDERS]}
|
|
|
|
>
|
|
|
|
<TableRow hover={true} onClick={onOrdersToFulfillClick}>
|
|
|
|
<TableCell>
|
|
|
|
{ordersToFulfill === undefined ? (
|
|
|
|
<Skeleton />
|
|
|
|
) : ordersToFulfill === 0 ? (
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="No orders ready to fulfill"
|
|
|
|
id="homeNotificationTableNoOrders"
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
) : (
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="{amount, plural,
|
2019-08-27 09:35:54 +00:00
|
|
|
one {One order}
|
|
|
|
other {{amount} Orders}
|
|
|
|
} are ready to fulfill"
|
2019-10-08 14:19:24 +00:00
|
|
|
id="homeNotificationTableOrders"
|
|
|
|
values={{
|
|
|
|
amount: <strong>{ordersToFulfill}</strong>
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
)}
|
|
|
|
</TableCell>
|
|
|
|
<TableCell className={classes.arrowIcon}>
|
|
|
|
<KeyboardArrowRight />
|
|
|
|
</TableCell>
|
|
|
|
</TableRow>
|
|
|
|
<TableRow hover={true} onClick={onOrdersToCaptureClick}>
|
|
|
|
<TableCell>
|
|
|
|
{ordersToCapture === undefined ? (
|
|
|
|
<Skeleton />
|
|
|
|
) : ordersToCapture === 0 ? (
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="No payments waiting for capture"
|
|
|
|
id="homeNotificationsNoPayments"
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
) : (
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="{amount, plural,
|
2019-08-27 09:35:54 +00:00
|
|
|
one {One payment}
|
|
|
|
other {{amount} Payments}
|
|
|
|
} to capture"
|
2019-10-08 14:19:24 +00:00
|
|
|
id="homeNotificationTablePayments"
|
|
|
|
values={{
|
|
|
|
amount: <strong>{ordersToCapture}</strong>
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
)}
|
|
|
|
</TableCell>
|
|
|
|
<TableCell className={classes.arrowIcon}>
|
|
|
|
<KeyboardArrowRight />
|
|
|
|
</TableCell>
|
|
|
|
</TableRow>
|
|
|
|
</RequirePermissions>
|
|
|
|
<RequirePermissions
|
|
|
|
userPermissions={userPermissions}
|
|
|
|
requiredPermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
|
|
|
>
|
|
|
|
<TableRow hover={true} onClick={onProductsOutOfStockClick}>
|
|
|
|
<TableCell>
|
|
|
|
{productsOutOfStock === undefined ? (
|
|
|
|
<Skeleton />
|
|
|
|
) : productsOutOfStock === 0 ? (
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="No products out of stock"
|
|
|
|
id="homeNotificationsTableNoProducts"
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
) : (
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="{amount, plural,
|
2019-08-27 09:35:54 +00:00
|
|
|
one {One product}
|
|
|
|
other {{amount} Products}
|
|
|
|
} out of stock"
|
2019-10-08 14:19:24 +00:00
|
|
|
id="homeNotificationTableProducts"
|
|
|
|
values={{
|
|
|
|
amount: <strong>{productsOutOfStock}</strong>
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
)}
|
|
|
|
</TableCell>
|
|
|
|
<TableCell className={classes.arrowIcon}>
|
|
|
|
<KeyboardArrowRight />
|
|
|
|
</TableCell>
|
|
|
|
</TableRow>
|
|
|
|
</RequirePermissions>
|
2019-08-27 09:35:54 +00:00
|
|
|
</TableBody>
|
|
|
|
</Table>
|
|
|
|
</Card>
|
|
|
|
)
|
2019-06-19 14:40:52 +00:00
|
|
|
);
|
|
|
|
HomeNotificationTable.displayName = "HomeNotificationTable";
|
|
|
|
export default HomeNotificationTable;
|