import Button from "@material-ui/core/Button"; import Card from "@material-ui/core/Card"; import IconButton from "@material-ui/core/IconButton"; import { makeStyles } from "@material-ui/core/styles"; 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 DeleteIcon from "@material-ui/icons/Delete"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import Checkbox from "@saleor/components/Checkbox"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; import { maybe, renderCollection } from "../../../misc"; import { ListActions, ListProps } from "../../../types"; import { SaleDetails_sale } from "../../types/SaleDetails"; import { VoucherDetails_voucher } from "../../types/VoucherDetails"; export interface DiscountCollectionsProps extends ListProps, ListActions { discount: SaleDetails_sale | VoucherDetails_voucher; onCollectionAssign: () => void; onCollectionUnassign: (id: string) => void; } const useStyles = makeStyles(theme => ({ iconCell: { "&:last-child": { paddingRight: 0 }, width: 48 + theme.spacing(0.5) }, tableRow: { cursor: "pointer" }, textRight: { textAlign: "right" }, wideColumn: { width: "60%" } })); const numberOfColumns = 4; const DiscountCollections: React.FC = props => { const { discount: sale, disabled, pageInfo, onCollectionAssign, onCollectionUnassign, onRowClick, onPreviousPage, onNextPage, isChecked, selected, toggle, toggleAll, toolbar } = props; const classes = useStyles(props); const intl = useIntl(); return ( } /> sale.collections.edges.map(edge => edge.node))} toggleAll={toggleAll} toolbar={toolbar} > {renderCollection( maybe(() => sale.collections.edges.map(edge => edge.node)), collection => { const isSelected = collection ? isChecked(collection.id) : false; return ( toggle(collection.id)} /> {maybe( () => collection.name, )} {maybe( () => collection.products.totalCount, )} { event.stopPropagation(); onCollectionUnassign(collection.id); }} > ); }, () => ( ) )} ); }; DiscountCollections.displayName = "DiscountCollections"; export default DiscountCollections;