import { TableBody, TableCell, TableFooter } from "@material-ui/core"; import { AttributeListUrlSortField, attributeUrl, } from "@saleor/attributes/urls"; 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 { TablePaginationWithContext } from "@saleor/components/TablePagination"; import TableRowLink from "@saleor/components/TableRowLink"; import { AttributeFragment } from "@saleor/graphql"; import { translateBoolean } from "@saleor/intl"; import { makeStyles } from "@saleor/macaw-ui"; import { maybe, renderCollection } from "@saleor/misc"; import { ListActions, ListProps, SortPage } from "@saleor/types"; import { getArrowDirection } from "@saleor/utils/sort"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; export interface AttributeListProps extends ListProps, ListActions, SortPage { attributes: AttributeFragment[]; } const useStyles = makeStyles( theme => ({ [theme.breakpoints.up("lg")]: { colFaceted: { width: 180, }, colName: { width: "auto", }, colSearchable: { width: 180, }, colSlug: { width: 200, }, colVisible: { width: 180, }, }, colFaceted: { textAlign: "center", }, colName: {}, colSearchable: { textAlign: "center", }, colSlug: { paddingLeft: 0, }, colVisible: { textAlign: "center", }, link: { cursor: "pointer", }, }), { name: "AttributeList" }, ); const numberOfColumns = 6; const AttributeList: React.FC = ({ attributes, disabled, isChecked, selected, sort, toggle, toggleAll, toolbar, onSort, }) => { const classes = useStyles({}); const intl = useIntl(); return ( onSort(AttributeListUrlSortField.slug)} > onSort(AttributeListUrlSortField.name)} > onSort(AttributeListUrlSortField.visible)} > onSort(AttributeListUrlSortField.searchable)} > onSort(AttributeListUrlSortField.useInFacetedSearch)} > {renderCollection( attributes, attribute => { const isSelected = attribute ? isChecked(attribute.id) : false; return ( attribute.id)} > 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;