import { Theme } 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 makeStyles from "@material-ui/styles/makeStyles"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import Checkbox from "@saleor/components/Checkbox"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; import { translateBoolean } from "@saleor/intl"; import { maybe, renderCollection } from "@saleor/misc"; import { ListActions, ListProps } from "@saleor/types"; import { AttributeList_attributes_edges_node } from "../../types/AttributeList"; export interface AttributeListProps extends ListProps, ListActions { attributes: AttributeList_attributes_edges_node[]; } const useStyles = makeStyles((theme: Theme) => ({ [theme.breakpoints.up("lg")]: { colFaceted: { width: 150 }, colName: { width: "auto" }, colSearchable: { width: 150 }, colSlug: { width: 200 }, colVisible: { width: 150 } }, colFaceted: { textAlign: "center" }, colName: {}, colSearchable: { textAlign: "center" }, colSlug: { paddingLeft: 0 }, colVisible: { textAlign: "center" }, link: { cursor: "pointer" } })); const numberOfColumns = 6; const AttributeList: React.StatelessComponent = ({ attributes, disabled, isChecked, onNextPage, onPreviousPage, onRowClick, pageInfo, selected, toggle, toggleAll, toolbar }) => { const classes = useStyles({}); const intl = useIntl(); return ( {renderCollection( attributes, attribute => { const isSelected = attribute ? isChecked(attribute.id) : false; return ( attribute.id)} data-tc-values={JSON.stringify( maybe(() => attribute.values, []) )} > toggle(attribute.id)} /> {attribute ? attribute.slug : } {attribute ? attribute.name : } attribute.visibleInStorefront)} > {attribute ? ( translateBoolean(attribute.visibleInStorefront, intl) ) : ( )} attribute.filterableInDashboard )} > {attribute ? ( translateBoolean(attribute.filterableInDashboard, intl) ) : ( )} attribute.filterableInStorefront )} > {attribute ? ( translateBoolean(attribute.filterableInStorefront, intl) ) : ( )} ); }, () => ( ) )}
); }; AttributeList.displayName = "AttributeList"; export default AttributeList;