import { Card, TableBody, TableCell, TableRow, Typography } from "@material-ui/core"; import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; import RequirePermissions from "@saleor/components/RequirePermissions"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import { makeStyles } from "@saleor/macaw-ui"; import { UserPermissionProps } from "@saleor/types"; import { PermissionEnum } from "@saleor/types/globalTypes"; import React from "react"; import { defineMessages, useIntl } from "react-intl"; const messages = defineMessages({ createNewChannel: { defaultMessage: "Create new channel" }, noOrders: { defaultMessage: "No orders ready to fulfill", id: "homeNotificationTableNoOrders" }, noPaymentWaiting: { defaultMessage: "No payments waiting for capture", id: "homeNotificationsNoPayments" }, noProductsOut: { defaultMessage: "No products out of stock", id: "homeNotificationsTableNoProducts" }, orderReady: { defaultMessage: "{amount, plural,one {One order is ready to fulfill} other {{amount} Orders are ready to fulfill}}", id: "homeNotificationTableOrders" }, paymentCapture: { defaultMessage: "{amount, plural,one {One payment to capture}other {{amount} Payments to capture}}", id: "homeNotificationTablePayments" }, productOut: { defaultMessage: "{amount, plural,one {One product out of stock}other {{amount} Products out of stock}}", id: "homeNotificationTableProducts" } }); const useStyles = makeStyles( () => ({ arrowIcon: { textAlign: "right", width: "auto" }, tableCard: { overflow: "hidden" }, tableRow: { cursor: "pointer" } }), { name: "HomeNotificationTable" } ); interface HomeNotificationTableProps extends UserPermissionProps { ordersToCapture: number; ordersToFulfill: number; productsOutOfStock: number; onCreateNewChannelClick: () => void; onOrdersToFulfillClick: () => void; onOrdersToCaptureClick: () => void; onProductsOutOfStockClick: () => void; noChannel: boolean; } const HomeNotificationTable: React.FC = props => { const { onCreateNewChannelClick, onOrdersToCaptureClick, onOrdersToFulfillClick, onProductsOutOfStockClick, ordersToCapture, ordersToFulfill, productsOutOfStock, userPermissions, noChannel } = props; const classes = useStyles(props); const intl = useIntl(); return ( {noChannel && ( {intl.formatMessage(messages.createNewChannel)} )} {ordersToFulfill === undefined ? ( ) : ordersToFulfill === 0 ? ( {intl.formatMessage(messages.noOrders)} ) : ( {intl.formatMessage(messages.orderReady, { amount: {ordersToFulfill} })} )} {ordersToCapture === undefined ? ( ) : ordersToCapture === 0 ? ( {intl.formatMessage(messages.noPaymentWaiting)} ) : ( {intl.formatMessage(messages.paymentCapture, { amount: {ordersToCapture} })} )} {productsOutOfStock === undefined ? ( ) : productsOutOfStock === 0 ? ( {intl.formatMessage(messages.noProductsOut)} ) : ( {intl.formatMessage(messages.productOut, { amount: {productsOutOfStock} })} )} ); }; HomeNotificationTable.displayName = "HomeNotificationTable"; export default HomeNotificationTable;