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 { CollectionListUrlSortField } from "@saleor/collections/urls"; import { ChannelsAvailabilityDropdown } from "@saleor/components/ChannelsAvailabilityDropdown"; import Checkbox from "@saleor/components/Checkbox"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import TableCellHeader from "@saleor/components/TableCellHeader"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; import { maybe, renderCollection } from "@saleor/misc"; import { ChannelProps, ListActions, ListProps, SortPage } from "@saleor/types"; import { getArrowDirection } from "@saleor/utils/sort"; import React from "react"; import { FormattedMessage } from "react-intl"; import { CollectionList_collections_edges_node } from "../../types/CollectionList"; const useStyles = makeStyles( theme => ({ [theme.breakpoints.up("lg")]: { colAvailability: { width: 240 }, colName: { paddingLeft: 0 }, colProducts: { width: 240 } }, colAvailability: {}, colName: {}, colProducts: { textAlign: "center" }, tableRow: { cursor: "pointer" as "pointer" } }), { name: "CollectionList" } ); interface CollectionListProps extends ListProps, ListActions, SortPage, ChannelProps { collections: CollectionList_collections_edges_node[]; channelsCount: number; } const numberOfColumns = 4; const CollectionList: React.FC = props => { const { channelsCount, collections, disabled, settings, sort, onNextPage, onPreviousPage, onUpdateListSettings, onRowClick, onSort, pageInfo, isChecked, selected, selectedChannelId, toggle, toggleAll, toolbar } = props; const classes = useStyles(props); return ( onSort(CollectionListUrlSortField.name)} className={classes.colName} > onSort(CollectionListUrlSortField.productCount)} className={classes.colProducts} > onSort(CollectionListUrlSortField.available)} className={classes.colAvailability} > {renderCollection( collections, collection => { const isSelected = collection ? isChecked(collection.id) : false; const channel = collection?.channelListings.find( listing => listing.channel.id === selectedChannelId ); return ( collection.id)} > toggle(collection.id)} /> {maybe(() => collection.name, )} {maybe( () => collection.products.totalCount, )} {collection && !collection?.channelListings?.length ? ( "-" ) : collection?.channelListings !== undefined ? ( ) : ( )} ); }, () => ( ) )} ); }; CollectionList.displayName = "CollectionList"; export default CollectionList;