import { Card, CardContent, TextField, Typography } from "@material-ui/core"; import { ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION } from "@saleor/attributes/utils/data"; import CardSpacer from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import ControlledSwitch from "@saleor/components/ControlledSwitch"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; import { AttributeErrorFragment, AttributeTypeEnum } from "@saleor/graphql"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getAttributeErrorMessage from "@saleor/utils/errors/attribute"; import React from "react"; import { defineMessages, FormattedMessage, useIntl } from "react-intl"; import { AttributePageFormData } from "../AttributePage"; const messages = defineMessages({ availableInGrid: { defaultMessage: "Add to Column Options", description: "add attribute as column in product list table" }, availableInGridCaption: { defaultMessage: "If enabled this attribute can be used as a column in product table.", description: "caption" }, dashboardPropertiesTitle: { defaultMessage: "Dashboard Properties", description: "attribute properties regarding dashboard" }, filterableInDashboard: { defaultMessage: "Use in Filtering", description: "use attribute in filtering" }, filterableInDashboardCaption: { defaultMessage: "If enabled, you’ll be able to use this attribute to filter products in product list.", description: "caption" }, filterableInStorefront: { defaultMessage: "Use in Faceted Navigation", description: "attribute is filterable in storefront" }, storefrontPropertiesTitle: { defaultMessage: "Storefront Properties", description: "attribute properties regarding storefront" }, storefrontSearchPosition: { defaultMessage: "Position in faceted navigation", description: "attribute position in storefront filters" }, visibleInStorefront: { defaultMessage: "Public", description: "attribute visibility in storefront" }, visibleInStorefrontCaption: { defaultMessage: "If enabled, attribute will be accessible to customers.", description: "caption" } }); export interface AttributePropertiesProps { data: AttributePageFormData; disabled: boolean; errors: AttributeErrorFragment[]; onChange: (event: React.ChangeEvent) => void; } const AttributeProperties: React.FC = ({ data, errors, disabled, onChange }) => { const intl = useIntl(); const formErrors = getFormErrors(["storefrontSearchPosition"], errors); const dashboardProperties = ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION.includes( data.inputType ); const storefrontFacetedNavigationProperties = ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION.includes( data.inputType ) && data.type === AttributeTypeEnum.PRODUCT_TYPE; return ( {/*
} onChange={onChange} /> */}
{storefrontFacetedNavigationProperties && ( <> {data.filterableInStorefront && ( <> )} )} } checked={data.visibleInStorefront} onChange={onChange} disabled={disabled} /> {dashboardProperties && ( <>
} checked={data.filterableInDashboard} onChange={onChange} disabled={disabled} /> } checked={data.availableInGrid} onChange={onChange} disabled={disabled} /> )}
); }; AttributeProperties.displayName = "AttributeProperties"; export default AttributeProperties;