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 TableFooter from "@material-ui/core/TableFooter"; import TableRow from "@material-ui/core/TableRow"; import React from "react"; import Checkbox from "@saleor/components/Checkbox"; import Date from "@saleor/components/Date"; import Money from "@saleor/components/Money"; import Percent from "@saleor/components/Percent"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; import i18n from "@saleor/i18n"; import { maybe, renderCollection } from "@saleor/misc"; import { ListActions, ListProps } from "@saleor/types"; import { SaleType } from "@saleor/types/globalTypes"; import { SaleList_sales_edges_node } from "../../types/SaleList"; export interface SaleListProps extends ListProps, ListActions { defaultCurrency: string; sales: SaleList_sales_edges_node[]; } const styles = (theme: Theme) => createStyles({ [theme.breakpoints.up("lg")]: { colEnd: { width: 250 }, colName: {}, colStart: { width: 250 }, colValue: { width: 200 } }, colEnd: { textAlign: "right" }, colName: {}, colStart: { textAlign: "right" }, colValue: { textAlign: "right" }, tableRow: { cursor: "pointer" } }); const numberOfColumns = 5; const SaleList = withStyles(styles, { name: "SaleList" })( ({ classes, settings, defaultCurrency, disabled, onNextPage, onPreviousPage, onUpdateListSettings, onRowClick, pageInfo, sales, isChecked, selected, toggle, toggleAll, toolbar }: SaleListProps & WithStyles) => ( {i18n.t("Name", { context: "sale list table header" })} {i18n.t("Starts", { context: "sale list table header" })} {i18n.t("Ends", { context: "sale list table header" })} {i18n.t("Value", { context: "sale list table header" })} {renderCollection( sales, sale => { const isSelected = sale ? isChecked(sale.id) : false; return ( toggle(sale.id)} /> {maybe(() => sale.name, )} {sale && sale.startDate ? ( ) : ( )} {sale && sale.endDate ? ( ) : sale && sale.endDate === null ? ( "-" ) : ( )} {sale && sale.type && sale.value ? ( sale.type === SaleType.FIXED ? ( ) : ( ) ) : ( )} ); }, () => ( {i18n.t("No sales found")} ) )}
) ); SaleList.displayName = "SaleList"; export default SaleList;