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 TableHead from "@material-ui/core/TableHead"; import React from "react"; import { FormattedMessage } from "react-intl"; import IconButton from "@material-ui/core/IconButton"; import DeleteIcon from "@material-ui/icons/Delete"; import EditIcon from "@material-ui/icons/Edit"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import TablePagination from "@saleor/components/TablePagination"; import { maybe, renderCollection, stopPropagation } from "@saleor/misc"; import { ListProps, SortPage } from "@saleor/types"; import { WarehouseListUrlSortField } from "@saleor/warehouses/urls"; import TableCellHeader from "@saleor/components/TableCellHeader"; import { getArrowDirection } from "@saleor/utils/sort"; import { WarehouseWithShippingFragment } from "@saleor/warehouses/types/WarehouseWithShippingFragment"; const useStyles = makeStyles( theme => ({ [theme.breakpoints.up("lg")]: { colActions: { width: 160 }, colName: { width: 400 }, colZones: { width: "auto" } }, actions: { alignItems: "center", display: "flex", justifyContent: "flex-end", position: "relative", right: -theme.spacing(2) }, colActions: { textAlign: "right" }, colName: { paddingLeft: 0 }, colZones: { paddingLeft: 0 }, tableRow: { cursor: "pointer" } }), { name: "WarehouseList" } ); interface WarehouseListProps extends ListProps, SortPage { warehouses: WarehouseWithShippingFragment[]; onAdd: () => void; onRemove: (id: string) => void; } const numberOfColumns = 3; const WarehouseList: React.FC = props => { const { warehouses, disabled, settings, sort, pageInfo, onNextPage, onPreviousPage, onUpdateListSettings, onRemove, onRowClick, onSort } = props; const classes = useStyles(props); return ( onSort(WarehouseListUrlSortField.name)} > {renderCollection( warehouses, warehouse => ( warehouse.id)} > {maybe(() => warehouse.name, )} {maybe( () => warehouse.shippingZones.edges .map(edge => edge.node.name) .join(", "), )}
onRemove(warehouse.id))} >
), () => ( ) )}
); }; WarehouseList.displayName = "WarehouseList"; export default WarehouseList;