From a0dce99b5d08a707d1516c37b89d58011a9d3563 Mon Sep 17 00:00:00 2001 From: Piotr Grundas Date: Sun, 20 Jun 2021 01:13:16 +0200 Subject: [PATCH] [SALEOR-3090] Boolean attribute (#1157) --- CHANGELOG.md | 1 + locale/defaultMessages.json | 4 + schema.graphql | 4 + .../AttributeDetails/AttributeDetails.tsx | 4 + .../components/AttributeDetails/messages.tsx | 4 + .../AttributeProperties.tsx | 9 +- src/attributes/fixtures.ts | 123 +++++++--- src/attributes/types/AttributeDetails.ts | 3 +- src/attributes/types/AttributeList.ts | 3 +- src/attributes/types/AttributeUpdate.ts | 2 +- src/attributes/types/AttributeValueCreate.ts | 1 + src/attributes/types/AttributeValueDelete.ts | 1 + src/attributes/types/AttributeValueUpdate.ts | 1 + src/attributes/utils/data.ts | 9 + src/attributes/utils/handlers.test.ts | 15 +- src/attributes/utils/handlers.ts | 95 +++++--- .../views/AttributeCreate/AttributeCreate.tsx | 1 + src/components/Attributes/AttributeRow.tsx | 23 ++ .../Attributes/BasicAttributeRow.tsx | 3 +- src/components/Attributes/fixtures.ts | 88 ++++--- src/components/Checkbox/Checkbox.tsx | 40 +++- .../RichTextEditor/RichTextEditor.tsx | 6 +- src/fragments/attributes.ts | 2 + .../types/AttributeDetailsFragment.ts | 2 +- src/fragments/types/AttributeFragment.ts | 3 +- src/fragments/types/AttributeValueFragment.ts | 1 + .../types/AttributeValueListFragment.ts | 1 + src/fragments/types/PageAttributesFragment.ts | 3 + src/fragments/types/PageDetailsFragment.ts | 3 + .../types/PageTypeDetailsFragment.ts | 3 +- src/fragments/types/Product.ts | 3 + .../types/ProductTypeDetailsFragment.ts | 4 +- src/fragments/types/ProductVariant.ts | 4 + .../types/ProductVariantAttributesFragment.ts | 3 + .../types/SelectedVariantAttributeFragment.ts | 2 + .../types/VariantAttributeFragment.ts | 1 + src/icons/ChevronDown.tsx | 4 +- src/pageTypes/fixtures.ts | 8 +- src/pageTypes/types/AssignPageAttribute.ts | 3 +- .../types/PageTypeAttributeReorder.ts | 3 +- src/pageTypes/types/PageTypeCreate.ts | 3 +- src/pageTypes/types/PageTypeDetails.ts | 3 +- src/pageTypes/types/PageTypeUpdate.ts | 3 +- src/pageTypes/types/UnassignPageAttribute.ts | 3 +- src/pages/fixtures.ts | 48 ++-- src/pages/types/PageDetails.ts | 3 + src/pages/types/PageType.ts | 1 + src/pages/types/PageUpdate.ts | 3 + src/productTypes/fixtures.ts | 108 ++++++--- .../types/AssignProductAttribute.ts | 4 +- .../types/ProductTypeAttributeReorder.ts | 4 +- src/productTypes/types/ProductTypeCreate.ts | 4 +- src/productTypes/types/ProductTypeDetails.ts | 4 +- src/productTypes/types/ProductTypeUpdate.ts | 4 +- .../types/UnassignProductAttribute.ts | 4 +- .../components/ProductListPage/filters.ts | 35 ++- .../__snapshots__/reducer.test.ts.snap | 48 ++++ .../ProductVariantCreatorPage/fixtures.ts | 12 +- .../index.tsx | 18 +- src/products/fixtures.ts | 123 ++++++---- src/products/queries.ts | 2 + .../types/CreateMultipleVariantsData.ts | 3 + .../types/InitialProductFilterAttributes.ts | 3 + src/products/types/ProductDetails.ts | 3 + src/products/types/ProductList.ts | 1 + src/products/types/ProductType.ts | 1 + src/products/types/ProductUpdate.ts | 3 + .../types/ProductVariantCreateData.ts | 2 + src/products/types/ProductVariantDetails.ts | 4 + src/products/types/SimpleProductUpdate.ts | 19 ++ src/products/types/VariantCreate.ts | 4 + src/products/types/VariantUpdate.ts | 8 + src/products/views/ProductList/filters.ts | 34 ++- src/products/views/ProductList/fixtures.ts | 1 + src/searches/types/SearchAttributeValues.ts | 1 + .../__snapshots__/Stories.test.ts.snap | 220 +++++++++++++++++- src/types/globalTypes.ts | 3 + src/utils/handlers/handleFormSubmit.ts | 2 +- 78 files changed, 971 insertions(+), 271 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35d203ed3..14098054e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -167,6 +167,7 @@ All notable, unreleased changes to this project will be documented in this file. - Update product stock management to newest design - #515 by @dominik-zeglen - Handle untracked products - #523 by @dominik-zeglen - Display correct error if there were no graphql errors - #525 by @dominik-zeglen +- Add boolean attributes - #1157 by @piotrgrundas ## 2.0.0 diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 66efe21e2..b2ebccf9b 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -953,6 +953,10 @@ "context": "attribute slug input field helper text", "string": "This is used internally. Make sure you don’t use spaces" }, + "src_dot_attributes_dot_components_dot_AttributeDetails_dot_boolean": { + "context": "boolean attribute type", + "string": "Boolean" + }, "src_dot_attributes_dot_components_dot_AttributeDetails_dot_distance": { "context": "distance units type", "string": "Distance" diff --git a/schema.graphql b/schema.graphql index 025370c5c..fa3f88d5e 100644 --- a/schema.graphql +++ b/schema.graphql @@ -519,6 +519,7 @@ input AttributeInput { slug: String! values: [String] valuesRange: IntRangeInput + boolean: Boolean } enum AttributeInputTypeEnum { @@ -528,6 +529,7 @@ enum AttributeInputTypeEnum { REFERENCE NUMERIC RICH_TEXT + BOOLEAN } type AttributeReorderValues { @@ -608,6 +610,7 @@ type AttributeValue implements Node { reference: ID file: File richText: JSONString + boolean: Boolean } type AttributeValueBulkDelete { @@ -658,6 +661,7 @@ input AttributeValueInput { contentType: String references: [ID!] richText: JSONString + boolean: Boolean } type AttributeValueTranslatableContent implements Node { diff --git a/src/attributes/components/AttributeDetails/AttributeDetails.tsx b/src/attributes/components/AttributeDetails/AttributeDetails.tsx index 59685c520..dd6bbf7b6 100644 --- a/src/attributes/components/AttributeDetails/AttributeDetails.tsx +++ b/src/attributes/components/AttributeDetails/AttributeDetails.tsx @@ -96,6 +96,10 @@ const AttributeDetails: React.FC = props => { { label: intl.formatMessage(inputTypeMessages.numeric), value: AttributeInputTypeEnum.NUMERIC + }, + { + label: intl.formatMessage(inputTypeMessages.boolean), + value: AttributeInputTypeEnum.BOOLEAN } ]; const entityTypeChoices = [ diff --git a/src/attributes/components/AttributeDetails/messages.tsx b/src/attributes/components/AttributeDetails/messages.tsx index ae7275913..02aa217d4 100644 --- a/src/attributes/components/AttributeDetails/messages.tsx +++ b/src/attributes/components/AttributeDetails/messages.tsx @@ -69,6 +69,10 @@ export const inputTypeMessages = defineMessages({ numeric: { defaultMessage: "Numeric", description: "numeric attribute type" + }, + boolean: { + defaultMessage: "Boolean", + description: "boolean attribute type" } }); diff --git a/src/attributes/components/AttributeProperties/AttributeProperties.tsx b/src/attributes/components/AttributeProperties/AttributeProperties.tsx index 1bd98386a..035583f1f 100644 --- a/src/attributes/components/AttributeProperties/AttributeProperties.tsx +++ b/src/attributes/components/AttributeProperties/AttributeProperties.tsx @@ -1,5 +1,5 @@ import { Card, CardContent, TextField, Typography } from "@material-ui/core"; -import { ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES } from "@saleor/attributes/utils/data"; +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"; @@ -78,13 +78,14 @@ const AttributeProperties: React.FC = ({ const formErrors = getFormErrors(["storefrontSearchPosition"], errors); - const dashboardProperties = ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES.includes( + const dashboardProperties = ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION.includes( data.inputType ); const storefrontFacetedNavigationProperties = - ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES.includes(data.inputType) && - data.type === AttributeTypeEnum.PRODUCT_TYPE; + ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION.includes( + data.inputType + ) && data.type === AttributeTypeEnum.PRODUCT_TYPE; return ( diff --git a/src/attributes/fixtures.ts b/src/attributes/fixtures.ts index 2083d3567..981d7d3c5 100644 --- a/src/attributes/fixtures.ts +++ b/src/attributes/fixtures.ts @@ -49,7 +49,8 @@ export const attribute: AttributeDetails_attribute = { name: "John Doe", reference: null, slug: "john-doe", - richText: null + richText: null, + boolean: null } }, { @@ -62,7 +63,8 @@ export const attribute: AttributeDetails_attribute = { name: "Milionare Pirate", reference: null, slug: "milionare-pirate", - richText: null + richText: null, + boolean: null } } ] @@ -81,6 +83,7 @@ export const attributes: Array value.slug); } diff --git a/src/attributes/utils/handlers.test.ts b/src/attributes/utils/handlers.test.ts index c1bb189ed..99bd3c605 100644 --- a/src/attributes/utils/handlers.test.ts +++ b/src/attributes/utils/handlers.test.ts @@ -16,7 +16,8 @@ const attributes: FormsetData = [ name: "Attribute 1 Value 1", reference: null, slug: "attr-1-v-1", - richText: null + richText: null, + boolean: null } ] }, @@ -36,7 +37,8 @@ const attributes: FormsetData = [ name: "Attribute 2 Value 1", reference: null, slug: "attr-2-v-1", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -45,7 +47,8 @@ const attributes: FormsetData = [ name: "Attribute 2 Value 2", reference: null, slug: "attr-2-v-2", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -54,7 +57,8 @@ const attributes: FormsetData = [ name: "Attribute 2 Value 3", reference: null, slug: "attr-2-v-3", - richText: null + richText: null, + boolean: null } ] }, @@ -78,7 +82,8 @@ const attributes: FormsetData = [ name: "File First Value", reference: null, slug: "file-first-value", - richText: null + richText: null, + boolean: null } ] }, diff --git a/src/attributes/utils/handlers.ts b/src/attributes/utils/handlers.ts index f8971dbd1..b2fd8f99f 100644 --- a/src/attributes/utils/handlers.ts +++ b/src/attributes/utils/handlers.ts @@ -177,44 +177,75 @@ interface AttributesArgs { updatedFileAttributes: AttributeValueInput[]; } +function getFileInput( + attribute: AttributeInput, + updatedFileAttributes: AttributeValueInput[] +) { + const updatedFileAttribute = updatedFileAttributes.find( + attributeWithNewFile => attribute.id === attributeWithNewFile.id + ); + + if (updatedFileAttribute) { + return { + file: updatedFileAttribute.file, + id: updatedFileAttribute.id + }; + } + return { + file: updatedFileAttribute.file, + id: updatedFileAttribute.id + }; +} + +function getReferenceInput(attribute: AttributeInput) { + return { + id: attribute.id, + references: attribute.value + }; +} + +function getRichTextInput(attribute: AttributeInput) { + return { + id: attribute.id, + richText: attribute.value[0] + }; +} + +function getBooleanInput(attribute: AttributeInput) { + return { + id: attribute.id, + boolean: JSON.parse(attribute.value[0] ?? "false") + }; +} + +function getDefaultInput(attribute: AttributeInput) { + return { + id: attribute.id, + values: attribute.value[0] === "" ? [] : attribute.value + }; +} + export const prepareAttributesInput = ({ attributes, updatedFileAttributes }: AttributesArgs): AttributeValueInput[] => attributes.map(attribute => { - if (attribute.data.inputType === AttributeInputTypeEnum.FILE) { - const updatedFileAttribute = updatedFileAttributes.find( - attributeWithNewFile => attribute.id === attributeWithNewFile.id - ); - if (updatedFileAttribute) { - return { - file: updatedFileAttribute.file, - id: updatedFileAttribute.id - }; - } - return { - file: - attribute.data.selectedValues && - attribute.data.selectedValues[0]?.file?.url, - id: attribute.id - }; + switch (attribute.data.inputType) { + case AttributeInputTypeEnum.FILE: + return getFileInput(attribute, updatedFileAttributes); + + case AttributeInputTypeEnum.REFERENCE: + return getReferenceInput(attribute); + + case AttributeInputTypeEnum.RICH_TEXT: + return getRichTextInput(attribute); + + case AttributeInputTypeEnum.BOOLEAN: + return getBooleanInput(attribute); + + default: + return getDefaultInput(attribute); } - if (attribute.data.inputType === AttributeInputTypeEnum.REFERENCE) { - return { - id: attribute.id, - references: attribute.value - }; - } - if (attribute.data.inputType === AttributeInputTypeEnum.RICH_TEXT) { - return { - id: attribute.id, - richText: attribute.value[0] - }; - } - return { - id: attribute.id, - values: attribute.value[0] === "" ? [] : attribute.value - }; }); export const handleUploadMultipleFiles = async ( diff --git a/src/attributes/views/AttributeCreate/AttributeCreate.tsx b/src/attributes/views/AttributeCreate/AttributeCreate.tsx index 17deff422..e3560232d 100644 --- a/src/attributes/views/AttributeCreate/AttributeCreate.tsx +++ b/src/attributes/views/AttributeCreate/AttributeCreate.tsx @@ -206,6 +206,7 @@ const AttributeDetails: React.FC = ({ params }) => { sortOrder: valueIndex, value: null, richText: null, + boolean: null, ...value } })) diff --git a/src/components/Attributes/AttributeRow.tsx b/src/components/Attributes/AttributeRow.tsx index 1b0884287..f684c1ecc 100644 --- a/src/components/Attributes/AttributeRow.tsx +++ b/src/components/Attributes/AttributeRow.tsx @@ -14,6 +14,7 @@ import { getSingleChoices, getSingleDisplayValue } from "@saleor/components/Attributes/utils"; +import Checkbox from "@saleor/components/Checkbox"; import FileUploadField from "@saleor/components/FileUploadField"; import MultiAutocompleteSelectField from "@saleor/components/MultiAutocompleteSelectField"; import RichTextEditor from "@saleor/components/RichTextEditor"; @@ -43,6 +44,10 @@ const useStyles = makeStyles( () => ({ fileField: { float: "right" + }, + pullRight: { + display: "flex", + justifyContent: "flex-end" } }), { name: "AttributeRow" } @@ -193,6 +198,24 @@ const AttributeRow: React.FC = ({ /> ); + case AttributeInputTypeEnum.BOOLEAN: + return ( + +
+ + onChange(attribute.id, JSON.stringify(event.target.checked)) + } + checked={JSON.parse(attribute.value[0] ?? "false")} + className={classes.pullRight} + helperText={getErrorMessage(error, intl)} + error={!!error} + /> +
+
+ ); default: return ( diff --git a/src/components/Attributes/BasicAttributeRow.tsx b/src/components/Attributes/BasicAttributeRow.tsx index 08d3a8deb..55cceea40 100644 --- a/src/components/Attributes/BasicAttributeRow.tsx +++ b/src/components/Attributes/BasicAttributeRow.tsx @@ -9,7 +9,8 @@ const useStyles = makeStyles( "&:last-of-type": { paddingBottom: 0 }, - padding: theme.spacing(2, 0) + padding: theme.spacing(2, 0), + wordBreak: "break-word" }, attributeSectionLabel: { alignItems: "center", diff --git a/src/components/Attributes/fixtures.ts b/src/components/Attributes/fixtures.ts index 21a175833..966f56dd1 100644 --- a/src/components/Attributes/fixtures.ts +++ b/src/components/Attributes/fixtures.ts @@ -1,6 +1,7 @@ import { AttributeEntityTypeEnum, - AttributeInputTypeEnum + AttributeInputTypeEnum, + MeasurementUnitsEnum } from "@saleor/types/globalTypes"; import { AttributeInput } from "./Attributes"; @@ -17,7 +18,8 @@ const DROPDOWN_ATTRIBUTE: AttributeInput = { name: "Dropdown First Value", reference: null, slug: "dropdown-first-value", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -26,7 +28,8 @@ const DROPDOWN_ATTRIBUTE: AttributeInput = { name: "Dropdown Second Value", reference: null, slug: "dropdown-second-value", - richText: null + richText: null, + boolean: null } ] }, @@ -47,7 +50,8 @@ const MULTISELECT_ATTRIBUTE: AttributeInput = { name: "Multiselect First Value", reference: null, slug: "multiselect-first-value", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -56,7 +60,8 @@ const MULTISELECT_ATTRIBUTE: AttributeInput = { name: "Multiselect Second Value", reference: null, slug: "multiselect-second-value", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -65,7 +70,8 @@ const MULTISELECT_ATTRIBUTE: AttributeInput = { name: "Multiselect Third Value", reference: null, slug: "multiselect-third-value", - richText: null + richText: null, + boolean: null } ] }, @@ -90,7 +96,8 @@ const FILE_ATTRIBUTE: AttributeInput = { name: "File First Value", reference: null, slug: "file-first-value", - richText: null + richText: null, + boolean: null } ] }, @@ -126,7 +133,8 @@ const REFERENCE_ATTRIBUTE: AttributeInput = { name: "References First Value", reference: null, slug: "references-first-value", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -135,7 +143,8 @@ const REFERENCE_ATTRIBUTE: AttributeInput = { name: "References Second Value", reference: null, slug: "references-second-value", - richText: null + richText: null, + boolean: null }, { __typename: "AttributeValue", @@ -144,7 +153,8 @@ const REFERENCE_ATTRIBUTE: AttributeInput = { name: "References Third Value", reference: null, slug: "references-third-value", - richText: null + richText: null, + boolean: null } ] }, @@ -169,24 +179,11 @@ const RICH_TEXT_ATTRIBUTE: AttributeInput = { time: 1617788754145, blocks: [{ data: { text: "Some cool text" }, type: "paragraph" }], version: "2.19.3" - }) + }), + boolean: null } ], - selectedValues: [ - { - __typename: "AttributeValue", - file: null, - id: "asdfafd", - name: "Some cool text", - reference: null, - slug: "text", - richText: JSON.stringify({ - time: 1617788754145, - blocks: [{ data: { text: "Some cool text" }, type: "paragraph" }], - version: "2.19.3" - }) - } - ] + selectedValues: [] }, id: "asdfafd", label: "Text Attribute", @@ -197,14 +194,16 @@ const NUMERIC_ATTRIBUTE: AttributeInput = { data: { inputType: AttributeInputTypeEnum.NUMERIC, isRequired: true, + unit: MeasurementUnitsEnum.CM, values: [ { __typename: "AttributeValue", file: null, id: "QXR0cmlidXRlVmFsdWU6MTAx", - name: "12cm", + name: "12", reference: null, richText: null, + boolean: null, slug: "319_35" } ] @@ -214,13 +213,36 @@ const NUMERIC_ATTRIBUTE: AttributeInput = { value: [] }; +const BOOLEAN_ATTRIBUTE: AttributeInput = { + data: { + inputType: AttributeInputTypeEnum.BOOLEAN, + isRequired: true, + values: [ + { + __typename: "AttributeValue", + file: null, + id: "asdfasdfasdfasdf", + name: "Boolean Attribute: Yes", + reference: null, + richText: null, + boolean: true, + slug: "319_True" + } + ] + }, + id: "QXR0cmlidXRlOjMasdfasdf1", + label: "Boolean Attribute", + value: [] +}; + export const ATTRIBUTES: AttributeInput[] = [ DROPDOWN_ATTRIBUTE, MULTISELECT_ATTRIBUTE, FILE_ATTRIBUTE, REFERENCE_ATTRIBUTE, RICH_TEXT_ATTRIBUTE, - NUMERIC_ATTRIBUTE + NUMERIC_ATTRIBUTE, + BOOLEAN_ATTRIBUTE ]; export const ATTRIBUTES_SELECTED: AttributeInput[] = [ @@ -249,10 +271,18 @@ export const ATTRIBUTES_SELECTED: AttributeInput[] = [ }, { ...RICH_TEXT_ATTRIBUTE, - value: [RICH_TEXT_ATTRIBUTE.data.values[0].richText] + data: { + ...RICH_TEXT_ATTRIBUTE.data, + selectedValues: [RICH_TEXT_ATTRIBUTE.data.values[0]] + }, + value: [] }, { ...NUMERIC_ATTRIBUTE, value: [NUMERIC_ATTRIBUTE.data.values[0].name] + }, + { + ...BOOLEAN_ATTRIBUTE, + value: [JSON.stringify(BOOLEAN_ATTRIBUTE.data.values[0].boolean)] } ]; diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx index 2761bcb7f..1149463db 100644 --- a/src/components/Checkbox/Checkbox.tsx +++ b/src/components/Checkbox/Checkbox.tsx @@ -1,24 +1,46 @@ -import { Checkbox as MuiCheckbox } from "@material-ui/core"; -import { CheckboxProps as MuiCheckboxProps } from "@material-ui/core/Checkbox"; +import MuiCheckbox, { + CheckboxProps as MuiCheckboxProps +} from "@material-ui/core/Checkbox"; +import FormHelperText from "@material-ui/core/FormHelperText"; +import { makeStyles } from "@saleor/theme"; import React from "react"; +const useStyles = makeStyles( + theme => ({ + error: { + color: theme.palette.error.main + } + }), + { name: "Checkbox" } +); + export type CheckboxProps = Omit< MuiCheckboxProps, "checkedIcon" | "color" | "icon" | "indeterminateIcon" | "classes" | "onClick" > & { disableClickPropagation?: boolean; + helperText?: string; + error?: boolean; }; -const Checkbox: React.FC = props => { +const Checkbox: React.FC = ({ helperText, error, ...props }) => { const { disableClickPropagation, ...rest } = props; + const classes = useStyles(); return ( - event.stopPropagation() : undefined - } - /> + <> + event.stopPropagation() : undefined + } + /> + {helperText && ( + + {helperText} + + )} + ); }; Checkbox.displayName = "Checkbox"; diff --git a/src/components/RichTextEditor/RichTextEditor.tsx b/src/components/RichTextEditor/RichTextEditor.tsx index 83f52608f..f7dc0c52c 100644 --- a/src/components/RichTextEditor/RichTextEditor.tsx +++ b/src/components/RichTextEditor/RichTextEditor.tsx @@ -42,8 +42,10 @@ const RichTextEditor: React.FC = ({ holder: editorContainer.current, logLevel: "ERROR" as LogLevels, onChange: async api => { - const savedData = await api.saver.save(); - onChange(savedData); + if (!api.readOnly) { + const savedData = await api.saver.save(); + onChange(savedData); + } }, onReady: () => { // FIXME: This throws an error and is not working diff --git a/src/fragments/attributes.ts b/src/fragments/attributes.ts index 1a1f56948..e409a0f99 100644 --- a/src/fragments/attributes.ts +++ b/src/fragments/attributes.ts @@ -15,6 +15,7 @@ export const attributeValueFragment = gql` } reference richText + boolean } `; @@ -28,6 +29,7 @@ export const attributeFragment = gql` filterableInDashboard filterableInStorefront unit + inputType } `; diff --git a/src/fragments/types/AttributeDetailsFragment.ts b/src/fragments/types/AttributeDetailsFragment.ts index a50f5e2d0..552af80ac 100644 --- a/src/fragments/types/AttributeDetailsFragment.ts +++ b/src/fragments/types/AttributeDetailsFragment.ts @@ -31,10 +31,10 @@ export interface AttributeDetailsFragment { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; metadata: (AttributeDetailsFragment_metadata | null)[]; privateMetadata: (AttributeDetailsFragment_privateMetadata | null)[]; availableInGrid: boolean; - inputType: AttributeInputTypeEnum | null; entityType: AttributeEntityTypeEnum | null; storefrontSearchPosition: number; valueRequired: boolean; diff --git a/src/fragments/types/AttributeFragment.ts b/src/fragments/types/AttributeFragment.ts index 4f580eeb7..8e34a9dad 100644 --- a/src/fragments/types/AttributeFragment.ts +++ b/src/fragments/types/AttributeFragment.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL fragment: AttributeFragment @@ -19,4 +19,5 @@ export interface AttributeFragment { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } diff --git a/src/fragments/types/AttributeValueFragment.ts b/src/fragments/types/AttributeValueFragment.ts index e0e0c94f9..bb0841b86 100644 --- a/src/fragments/types/AttributeValueFragment.ts +++ b/src/fragments/types/AttributeValueFragment.ts @@ -21,4 +21,5 @@ export interface AttributeValueFragment { file: AttributeValueFragment_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } diff --git a/src/fragments/types/AttributeValueListFragment.ts b/src/fragments/types/AttributeValueListFragment.ts index 9d634ed57..320b79609 100644 --- a/src/fragments/types/AttributeValueListFragment.ts +++ b/src/fragments/types/AttributeValueListFragment.ts @@ -29,6 +29,7 @@ export interface AttributeValueListFragment_edges_node { file: AttributeValueListFragment_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface AttributeValueListFragment_edges { diff --git a/src/fragments/types/PageAttributesFragment.ts b/src/fragments/types/PageAttributesFragment.ts index d01ce833d..c4bf17bb2 100644 --- a/src/fragments/types/PageAttributesFragment.ts +++ b/src/fragments/types/PageAttributesFragment.ts @@ -31,6 +31,7 @@ export interface PageAttributesFragment_attributes_attribute_choices_edges_node file: PageAttributesFragment_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageAttributesFragment_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface PageAttributesFragment_attributes_values { file: PageAttributesFragment_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageAttributesFragment_attributes { @@ -101,6 +103,7 @@ export interface PageAttributesFragment_pageType_attributes_choices_edges_node { file: PageAttributesFragment_pageType_attributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageAttributesFragment_pageType_attributes_choices_edges { diff --git a/src/fragments/types/PageDetailsFragment.ts b/src/fragments/types/PageDetailsFragment.ts index 8016910aa..3ba8f2171 100644 --- a/src/fragments/types/PageDetailsFragment.ts +++ b/src/fragments/types/PageDetailsFragment.ts @@ -31,6 +31,7 @@ export interface PageDetailsFragment_attributes_attribute_choices_edges_node { file: PageDetailsFragment_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageDetailsFragment_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface PageDetailsFragment_attributes_values { file: PageDetailsFragment_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageDetailsFragment_attributes { @@ -101,6 +103,7 @@ export interface PageDetailsFragment_pageType_attributes_choices_edges_node { file: PageDetailsFragment_pageType_attributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageDetailsFragment_pageType_attributes_choices_edges { diff --git a/src/fragments/types/PageTypeDetailsFragment.ts b/src/fragments/types/PageTypeDetailsFragment.ts index 5fe34537e..5d0f13879 100644 --- a/src/fragments/types/PageTypeDetailsFragment.ts +++ b/src/fragments/types/PageTypeDetailsFragment.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL fragment: PageTypeDetailsFragment @@ -31,6 +31,7 @@ export interface PageTypeDetailsFragment_attributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface PageTypeDetailsFragment { diff --git a/src/fragments/types/Product.ts b/src/fragments/types/Product.ts index d38de7247..575c8dc1b 100644 --- a/src/fragments/types/Product.ts +++ b/src/fragments/types/Product.ts @@ -31,6 +31,7 @@ export interface Product_attributes_attribute_choices_edges_node { file: Product_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface Product_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface Product_attributes_values { file: Product_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface Product_attributes { @@ -101,6 +103,7 @@ export interface Product_productType_variantAttributes_choices_edges_node { file: Product_productType_variantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface Product_productType_variantAttributes_choices_edges { diff --git a/src/fragments/types/ProductTypeDetailsFragment.ts b/src/fragments/types/ProductTypeDetailsFragment.ts index c4a28ea44..4a8909e27 100644 --- a/src/fragments/types/ProductTypeDetailsFragment.ts +++ b/src/fragments/types/ProductTypeDetailsFragment.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL fragment: ProductTypeDetailsFragment @@ -37,6 +37,7 @@ export interface ProductTypeDetailsFragment_productAttributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeDetailsFragment_variantAttributes { @@ -49,6 +50,7 @@ export interface ProductTypeDetailsFragment_variantAttributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeDetailsFragment_weight { diff --git a/src/fragments/types/ProductVariant.ts b/src/fragments/types/ProductVariant.ts index 46d61cd0e..70afef826 100644 --- a/src/fragments/types/ProductVariant.ts +++ b/src/fragments/types/ProductVariant.ts @@ -43,6 +43,7 @@ export interface ProductVariant_selectionAttributes_attribute_choices_edges_node file: ProductVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariant_selectionAttributes_attribute_choices_edges { @@ -83,6 +84,7 @@ export interface ProductVariant_selectionAttributes_values { file: ProductVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariant_selectionAttributes { @@ -113,6 +115,7 @@ export interface ProductVariant_nonSelectionAttributes_attribute_choices_edges_n file: ProductVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariant_nonSelectionAttributes_attribute_choices_edges { @@ -153,6 +156,7 @@ export interface ProductVariant_nonSelectionAttributes_values { file: ProductVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariant_nonSelectionAttributes { diff --git a/src/fragments/types/ProductVariantAttributesFragment.ts b/src/fragments/types/ProductVariantAttributesFragment.ts index 6e227c2ee..b09c02789 100644 --- a/src/fragments/types/ProductVariantAttributesFragment.ts +++ b/src/fragments/types/ProductVariantAttributesFragment.ts @@ -31,6 +31,7 @@ export interface ProductVariantAttributesFragment_attributes_attribute_choices_e file: ProductVariantAttributesFragment_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantAttributesFragment_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface ProductVariantAttributesFragment_attributes_values { file: ProductVariantAttributesFragment_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantAttributesFragment_attributes { @@ -101,6 +103,7 @@ export interface ProductVariantAttributesFragment_productType_variantAttributes_ file: ProductVariantAttributesFragment_productType_variantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantAttributesFragment_productType_variantAttributes_choices_edges { diff --git a/src/fragments/types/SelectedVariantAttributeFragment.ts b/src/fragments/types/SelectedVariantAttributeFragment.ts index 0ebf21329..bdf0efb30 100644 --- a/src/fragments/types/SelectedVariantAttributeFragment.ts +++ b/src/fragments/types/SelectedVariantAttributeFragment.ts @@ -31,6 +31,7 @@ export interface SelectedVariantAttributeFragment_attribute_choices_edges_node { file: SelectedVariantAttributeFragment_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SelectedVariantAttributeFragment_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface SelectedVariantAttributeFragment_values { file: SelectedVariantAttributeFragment_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SelectedVariantAttributeFragment { diff --git a/src/fragments/types/VariantAttributeFragment.ts b/src/fragments/types/VariantAttributeFragment.ts index 3675ec68d..4b32765a6 100644 --- a/src/fragments/types/VariantAttributeFragment.ts +++ b/src/fragments/types/VariantAttributeFragment.ts @@ -31,6 +31,7 @@ export interface VariantAttributeFragment_choices_edges_node { file: VariantAttributeFragment_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantAttributeFragment_choices_edges { diff --git a/src/icons/ChevronDown.tsx b/src/icons/ChevronDown.tsx index a8c3a2f8d..90242ae47 100644 --- a/src/icons/ChevronDown.tsx +++ b/src/icons/ChevronDown.tsx @@ -16,8 +16,8 @@ const ChevronDown: React.FC = () => { ); diff --git a/src/pageTypes/fixtures.ts b/src/pageTypes/fixtures.ts index 562f31375..bbe9e4bad 100644 --- a/src/pageTypes/fixtures.ts +++ b/src/pageTypes/fixtures.ts @@ -1,5 +1,8 @@ /* eslint-disable sort-keys */ -import { AttributeTypeEnum } from "@saleor/types/globalTypes"; +import { + AttributeInputTypeEnum, + AttributeTypeEnum +} from "@saleor/types/globalTypes"; import { PageTypeDetails_pageType } from "./types/PageTypeDetails"; import { PageTypeList_pageTypes_edges_node } from "./types/PageTypeList"; @@ -47,6 +50,7 @@ export const pageType: PageTypeDetails_pageType = { filterableInDashboard: true, filterableInStorefront: true, type: AttributeTypeEnum.PAGE_TYPE, + inputType: AttributeInputTypeEnum.DROPDOWN, unit: null }, { @@ -58,6 +62,7 @@ export const pageType: PageTypeDetails_pageType = { filterableInDashboard: true, filterableInStorefront: true, type: AttributeTypeEnum.PAGE_TYPE, + inputType: AttributeInputTypeEnum.DROPDOWN, unit: null }, { @@ -69,6 +74,7 @@ export const pageType: PageTypeDetails_pageType = { filterableInDashboard: true, filterableInStorefront: true, type: AttributeTypeEnum.PAGE_TYPE, + inputType: AttributeInputTypeEnum.DROPDOWN, unit: null } ], diff --git a/src/pageTypes/types/AssignPageAttribute.ts b/src/pageTypes/types/AssignPageAttribute.ts index 6aa92dbf6..ed797300a 100644 --- a/src/pageTypes/types/AssignPageAttribute.ts +++ b/src/pageTypes/types/AssignPageAttribute.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: AssignPageAttribute @@ -37,6 +37,7 @@ export interface AssignPageAttribute_pageAttributeAssign_pageType_attributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface AssignPageAttribute_pageAttributeAssign_pageType { diff --git a/src/pageTypes/types/PageTypeAttributeReorder.ts b/src/pageTypes/types/PageTypeAttributeReorder.ts index 5b7ecea62..1390dca6b 100644 --- a/src/pageTypes/types/PageTypeAttributeReorder.ts +++ b/src/pageTypes/types/PageTypeAttributeReorder.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ReorderInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { ReorderInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: PageTypeAttributeReorder @@ -37,6 +37,7 @@ export interface PageTypeAttributeReorder_pageTypeReorderAttributes_pageType_att filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface PageTypeAttributeReorder_pageTypeReorderAttributes_pageType { diff --git a/src/pageTypes/types/PageTypeCreate.ts b/src/pageTypes/types/PageTypeCreate.ts index ecd9622ac..962290b4c 100644 --- a/src/pageTypes/types/PageTypeCreate.ts +++ b/src/pageTypes/types/PageTypeCreate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { PageTypeCreateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { PageTypeCreateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: PageTypeCreate @@ -37,6 +37,7 @@ export interface PageTypeCreate_pageTypeCreate_pageType_attributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface PageTypeCreate_pageTypeCreate_pageType { diff --git a/src/pageTypes/types/PageTypeDetails.ts b/src/pageTypes/types/PageTypeDetails.ts index 095e36549..87f9e4ed0 100644 --- a/src/pageTypes/types/PageTypeDetails.ts +++ b/src/pageTypes/types/PageTypeDetails.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL query operation: PageTypeDetails @@ -31,6 +31,7 @@ export interface PageTypeDetails_pageType_attributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface PageTypeDetails_pageType { diff --git a/src/pageTypes/types/PageTypeUpdate.ts b/src/pageTypes/types/PageTypeUpdate.ts index 07692e7d2..2515c3ea8 100644 --- a/src/pageTypes/types/PageTypeUpdate.ts +++ b/src/pageTypes/types/PageTypeUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { PageTypeUpdateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { PageTypeUpdateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: PageTypeUpdate @@ -37,6 +37,7 @@ export interface PageTypeUpdate_pageTypeUpdate_pageType_attributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface PageTypeUpdate_pageTypeUpdate_pageType { diff --git a/src/pageTypes/types/UnassignPageAttribute.ts b/src/pageTypes/types/UnassignPageAttribute.ts index e1353d0bf..a2b4dc115 100644 --- a/src/pageTypes/types/UnassignPageAttribute.ts +++ b/src/pageTypes/types/UnassignPageAttribute.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes"; +import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UnassignPageAttribute @@ -37,6 +37,7 @@ export interface UnassignPageAttribute_pageAttributeUnassign_pageType_attributes filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface UnassignPageAttribute_pageAttributeUnassign_pageType { diff --git a/src/pages/fixtures.ts b/src/pages/fixtures.ts index a3f77b238..6cfb40444 100644 --- a/src/pages/fixtures.ts +++ b/src/pages/fixtures.ts @@ -69,7 +69,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -82,7 +83,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -95,7 +97,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } } ] @@ -110,7 +113,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } ], __typename: "SelectedAttribute" @@ -144,7 +148,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -157,7 +162,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -170,7 +176,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -183,7 +190,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } } ] @@ -198,7 +206,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } ], __typename: "SelectedAttribute" @@ -245,7 +254,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -258,7 +268,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -271,7 +282,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } } ] @@ -304,7 +316,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -317,7 +330,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -330,7 +344,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } }, { @@ -343,7 +358,8 @@ export const page: PageDetails_page = { reference: null, __typename: "AttributeValue", file: null, - richText: null + richText: null, + boolean: null } } ] diff --git a/src/pages/types/PageDetails.ts b/src/pages/types/PageDetails.ts index f625246b0..5fa3190ec 100644 --- a/src/pages/types/PageDetails.ts +++ b/src/pages/types/PageDetails.ts @@ -31,6 +31,7 @@ export interface PageDetails_page_attributes_attribute_choices_edges_node { file: PageDetails_page_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageDetails_page_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface PageDetails_page_attributes_values { file: PageDetails_page_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageDetails_page_attributes { @@ -101,6 +103,7 @@ export interface PageDetails_page_pageType_attributes_choices_edges_node { file: PageDetails_page_pageType_attributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageDetails_page_pageType_attributes_choices_edges { diff --git a/src/pages/types/PageType.ts b/src/pages/types/PageType.ts index 0db01e594..3db366420 100644 --- a/src/pages/types/PageType.ts +++ b/src/pages/types/PageType.ts @@ -31,6 +31,7 @@ export interface PageType_pageType_attributes_choices_edges_node { file: PageType_pageType_attributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageType_pageType_attributes_choices_edges { diff --git a/src/pages/types/PageUpdate.ts b/src/pages/types/PageUpdate.ts index 8c2395f5d..616217ff6 100644 --- a/src/pages/types/PageUpdate.ts +++ b/src/pages/types/PageUpdate.ts @@ -38,6 +38,7 @@ export interface PageUpdate_pageUpdate_page_attributes_attribute_choices_edges_n file: PageUpdate_pageUpdate_page_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageUpdate_pageUpdate_page_attributes_attribute_choices_edges { @@ -78,6 +79,7 @@ export interface PageUpdate_pageUpdate_page_attributes_values { file: PageUpdate_pageUpdate_page_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageUpdate_pageUpdate_page_attributes { @@ -108,6 +110,7 @@ export interface PageUpdate_pageUpdate_page_pageType_attributes_choices_edges_no file: PageUpdate_pageUpdate_page_pageType_attributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface PageUpdate_pageUpdate_page_pageType_attributes_choices_edges { diff --git a/src/productTypes/fixtures.ts b/src/productTypes/fixtures.ts index ede68182d..9a9e99252 100644 --- a/src/productTypes/fixtures.ts +++ b/src/productTypes/fixtures.ts @@ -46,7 +46,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -62,7 +63,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -102,7 +104,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -118,7 +121,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -134,7 +138,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 2, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -150,7 +155,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 3, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -190,7 +196,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -230,7 +237,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -246,7 +254,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -262,7 +271,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 2, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -302,7 +312,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -318,7 +329,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -358,7 +370,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -374,7 +387,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -390,7 +404,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 2, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -430,7 +445,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -446,7 +462,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -486,7 +503,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -502,7 +520,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -518,7 +537,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 2, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -534,7 +554,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 3, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -550,7 +571,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 4, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -566,7 +588,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 5, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -606,7 +629,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -622,7 +646,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -662,7 +687,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -678,7 +704,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -718,7 +745,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -734,7 +762,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -774,7 +803,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 0, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -790,7 +820,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 1, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -806,7 +837,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 2, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -822,7 +854,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 3, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -838,7 +871,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 4, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } }, { @@ -854,7 +888,8 @@ export const attributes: ProductType_productType_productAttributes[] = [ sortOrder: 5, type: "STRING", value: "", - richText: null + richText: null, + boolean: null } } ] @@ -976,6 +1011,7 @@ export const productType: ProductTypeDetails_productType = { name: "Author", slug: "author", type: AttributeTypeEnum.PRODUCT_TYPE, + inputType: AttributeInputTypeEnum.DROPDOWN, visibleInStorefront: true, unit: null }, @@ -987,6 +1023,7 @@ export const productType: ProductTypeDetails_productType = { name: "Language", slug: "language", type: AttributeTypeEnum.PRODUCT_TYPE, + inputType: AttributeInputTypeEnum.DROPDOWN, visibleInStorefront: true, unit: null }, @@ -998,6 +1035,7 @@ export const productType: ProductTypeDetails_productType = { name: "Publisher", slug: "publisher", type: AttributeTypeEnum.PRODUCT_TYPE, + inputType: AttributeInputTypeEnum.DROPDOWN, visibleInStorefront: true, unit: null } diff --git a/src/productTypes/types/AssignProductAttribute.ts b/src/productTypes/types/AssignProductAttribute.ts index 40f4a5d18..82a8f0f90 100644 --- a/src/productTypes/types/AssignProductAttribute.ts +++ b/src/productTypes/types/AssignProductAttribute.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ProductAttributeAssignInput, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { ProductAttributeAssignInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: AssignProductAttribute @@ -43,6 +43,7 @@ export interface AssignProductAttribute_productAttributeAssign_productType_produ filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface AssignProductAttribute_productAttributeAssign_productType_variantAttributes { @@ -55,6 +56,7 @@ export interface AssignProductAttribute_productAttributeAssign_productType_varia filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface AssignProductAttribute_productAttributeAssign_productType_weight { diff --git a/src/productTypes/types/ProductTypeAttributeReorder.ts b/src/productTypes/types/ProductTypeAttributeReorder.ts index d4ffedcfe..67e2c0d98 100644 --- a/src/productTypes/types/ProductTypeAttributeReorder.ts +++ b/src/productTypes/types/ProductTypeAttributeReorder.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ReorderInput, ProductAttributeType, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { ReorderInput, ProductAttributeType, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: ProductTypeAttributeReorder @@ -43,6 +43,7 @@ export interface ProductTypeAttributeReorder_productTypeReorderAttributes_produc filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_variantAttributes { @@ -55,6 +56,7 @@ export interface ProductTypeAttributeReorder_productTypeReorderAttributes_produc filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_weight { diff --git a/src/productTypes/types/ProductTypeCreate.ts b/src/productTypes/types/ProductTypeCreate.ts index 2bbf784c2..12b1510d5 100644 --- a/src/productTypes/types/ProductTypeCreate.ts +++ b/src/productTypes/types/ProductTypeCreate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: ProductTypeCreate @@ -43,6 +43,7 @@ export interface ProductTypeCreate_productTypeCreate_productType_productAttribut filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeCreate_productTypeCreate_productType_variantAttributes { @@ -55,6 +56,7 @@ export interface ProductTypeCreate_productTypeCreate_productType_variantAttribut filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeCreate_productTypeCreate_productType_weight { diff --git a/src/productTypes/types/ProductTypeDetails.ts b/src/productTypes/types/ProductTypeDetails.ts index c8e853acf..6897e6071 100644 --- a/src/productTypes/types/ProductTypeDetails.ts +++ b/src/productTypes/types/ProductTypeDetails.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL query operation: ProductTypeDetails @@ -37,6 +37,7 @@ export interface ProductTypeDetails_productType_productAttributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeDetails_productType_variantAttributes { @@ -49,6 +50,7 @@ export interface ProductTypeDetails_productType_variantAttributes { filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeDetails_productType_weight { diff --git a/src/productTypes/types/ProductTypeUpdate.ts b/src/productTypes/types/ProductTypeUpdate.ts index 12affe506..d365b9dd7 100644 --- a/src/productTypes/types/ProductTypeUpdate.ts +++ b/src/productTypes/types/ProductTypeUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: ProductTypeUpdate @@ -43,6 +43,7 @@ export interface ProductTypeUpdate_productTypeUpdate_productType_productAttribut filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeUpdate_productTypeUpdate_productType_variantAttributes { @@ -55,6 +56,7 @@ export interface ProductTypeUpdate_productTypeUpdate_productType_variantAttribut filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface ProductTypeUpdate_productTypeUpdate_productType_weight { diff --git a/src/productTypes/types/UnassignProductAttribute.ts b/src/productTypes/types/UnassignProductAttribute.ts index b8f52939d..0dd53aa36 100644 --- a/src/productTypes/types/UnassignProductAttribute.ts +++ b/src/productTypes/types/UnassignProductAttribute.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes"; +import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UnassignProductAttribute @@ -43,6 +43,7 @@ export interface UnassignProductAttribute_productAttributeUnassign_productType_p filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface UnassignProductAttribute_productAttributeUnassign_productType_variantAttributes { @@ -55,6 +56,7 @@ export interface UnassignProductAttribute_productAttributeUnassign_productType_v filterableInDashboard: boolean; filterableInStorefront: boolean; unit: MeasurementUnitsEnum | null; + inputType: AttributeInputTypeEnum | null; } export interface UnassignProductAttribute_productAttributeUnassign_productType_weight { diff --git a/src/products/components/ProductListPage/filters.ts b/src/products/components/ProductListPage/filters.ts index 8a30d5a75..78ec3b135 100644 --- a/src/products/components/ProductListPage/filters.ts +++ b/src/products/components/ProductListPage/filters.ts @@ -1,9 +1,13 @@ import { IFilter } from "@saleor/components/Filter"; -import { sectionNames } from "@saleor/intl"; +import { commonMessages, sectionNames } from "@saleor/intl"; import { AutocompleteFilterOpts, FilterOpts, MinMax } from "@saleor/types"; -import { StockAvailability } from "@saleor/types/globalTypes"; +import { + AttributeInputTypeEnum, + StockAvailability +} from "@saleor/types/globalTypes"; import { createAutocompleteField, + createBooleanField, createOptionsField, createPriceField } from "@saleor/utils/filters/fields"; @@ -24,6 +28,7 @@ export interface ProductListFilterOpts { id: string; name: string; slug: string; + inputType: AttributeInputTypeEnum; } >; attributeChoices: FilterOpts & AutocompleteFilterOpts; @@ -67,7 +72,14 @@ const messages = defineMessages({ export function createFilterStructure( intl: IntlShape, opts: ProductListFilterOpts -): IFilter { +): IFilter { + const booleanAttributes = opts.attributes.filter( + ({ inputType }) => inputType === AttributeInputTypeEnum.BOOLEAN + ); + const defaultAttributes = opts.attributes.filter( + ({ inputType }) => !inputType.includes(AttributeInputTypeEnum.BOOLEAN) + ); + return [ { ...createOptionsField( @@ -150,7 +162,22 @@ export function createFilterStructure( ), active: opts.productType.active }, - ...opts.attributes.map(attr => ({ + ...booleanAttributes.map(attr => ({ + ...createBooleanField( + attr.slug, + attr.name, + Array.isArray(attr.value) + ? undefined + : (attr.value as unknown) === "true", + { + positive: intl.formatMessage(commonMessages.yes), + negative: intl.formatMessage(commonMessages.no) + } + ), + active: attr.active, + group: ProductFilterKeys.attributes + })), + ...defaultAttributes.map(attr => ({ ...createAutocompleteField( attr.slug as any, attr.name, diff --git a/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap b/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap index 12c22fc2a..645de0c75 100644 --- a/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap +++ b/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap @@ -10,6 +10,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -22,6 +23,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -39,6 +41,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -51,6 +54,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -68,6 +72,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -80,6 +85,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -631,6 +637,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -643,6 +650,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -660,6 +668,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -672,6 +681,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -689,6 +699,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -701,6 +712,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -1252,6 +1264,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -1264,6 +1277,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -1281,6 +1295,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -1293,6 +1308,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -1310,6 +1326,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -1322,6 +1339,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -1373,6 +1391,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -1385,6 +1404,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -1402,6 +1422,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -1414,6 +1435,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -1431,6 +1453,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -1443,6 +1466,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -1945,6 +1969,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -1957,6 +1982,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -1974,6 +2000,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -1986,6 +2013,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -2003,6 +2031,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -2015,6 +2044,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -2472,6 +2502,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -2484,6 +2515,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -2501,6 +2533,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -2513,6 +2546,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -2530,6 +2564,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -2542,6 +2577,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -3044,6 +3080,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -3056,6 +3093,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -3073,6 +3111,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -3085,6 +3124,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -3102,6 +3142,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -3114,6 +3155,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", @@ -3533,6 +3575,7 @@ Object { "slug": "val-1-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-1", "name": "val-1-1", @@ -3545,6 +3588,7 @@ Object { "slug": "val-1-7", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-1-7", "name": "val-1-7", @@ -3562,6 +3606,7 @@ Object { "slug": "val-2-2", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-2", "name": "val-2-2", @@ -3574,6 +3619,7 @@ Object { "slug": "val-2-4", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-2-4", "name": "val-2-4", @@ -3591,6 +3637,7 @@ Object { "slug": "val-4-1", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-1", "name": "val-4-1", @@ -3603,6 +3650,7 @@ Object { "slug": "val-4-5", "value": Object { "__typename": "AttributeValue", + "boolean": null, "file": null, "id": "val-4-5", "name": "val-4-5", diff --git a/src/products/components/ProductVariantCreatorPage/fixtures.ts b/src/products/components/ProductVariantCreatorPage/fixtures.ts index 757dbe37b..b4ffc3409 100644 --- a/src/products/components/ProductVariantCreatorPage/fixtures.ts +++ b/src/products/components/ProductVariantCreatorPage/fixtures.ts @@ -29,7 +29,8 @@ export const attributes = [ slug: `val-1-${index + 1}`, file: null, reference: null, - richText: null + richText: null, + boolean: null } })) }, @@ -46,7 +47,8 @@ export const attributes = [ slug: `val-2-${index + 1}`, file: null, reference: null, - richText: null + richText: null, + boolean: null } })) }, @@ -63,7 +65,8 @@ export const attributes = [ slug: `val-3-${index + 1}`, file: null, reference: null, - richText: null + richText: null, + boolean: null } })) }, @@ -80,7 +83,8 @@ export const attributes = [ slug: `val-4-${index + 1}`, file: null, reference: null, - richText: null + richText: null, + boolean: null } })) } diff --git a/src/products/components/ProductVariantPage/VariantDetailsChannelsAvailabilityCard/index.tsx b/src/products/components/ProductVariantPage/VariantDetailsChannelsAvailabilityCard/index.tsx index 35a7558d3..eda3f6c0b 100644 --- a/src/products/components/ProductVariantPage/VariantDetailsChannelsAvailabilityCard/index.tsx +++ b/src/products/components/ProductVariantPage/VariantDetailsChannelsAvailabilityCard/index.tsx @@ -144,18 +144,16 @@ const VariantDetailsChannelsAvailabilityCard: React.FC - <> - - {intl.formatMessage(messages.subtitle, { - publishedInChannelsCount: publishedInChannelsListings.length, - availableChannelsCount: allAvailableChannelsListings.length - })} - - + + {intl.formatMessage(messages.subtitle, { + publishedInChannelsCount: publishedInChannelsListings.length, + availableChannelsCount: allAvailableChannelsListings.length + })} + {channelListings.map(({ channel }) => ( - <> + - + ))} diff --git a/src/products/fixtures.ts b/src/products/fixtures.ts index 7a478db57..ecf82a4a5 100644 --- a/src/products/fixtures.ts +++ b/src/products/fixtures.ts @@ -50,7 +50,8 @@ export const product: ( name: "portals", reference: null, slug: "portals", - richText: null + richText: null, + boolean: null } }, { @@ -63,7 +64,8 @@ export const product: ( name: "Baht", reference: null, slug: "Baht", - richText: null + richText: null, + boolean: null } } ] @@ -77,7 +79,8 @@ export const product: ( name: "portals", reference: null, slug: "portals", - richText: null + richText: null, + boolean: null } ] }, @@ -112,7 +115,8 @@ export const product: ( name: "payment", reference: null, slug: "payment", - richText: null + richText: null, + boolean: null } }, { @@ -125,7 +129,8 @@ export const product: ( name: "Auto Loan Account", reference: null, slug: "Auto-Loan-Account", - richText: null + richText: null, + boolean: null } }, { @@ -138,7 +143,8 @@ export const product: ( name: "Garden", reference: null, slug: "Garden", - richText: null + richText: null, + boolean: null } }, { @@ -151,7 +157,8 @@ export const product: ( name: "override", reference: null, slug: "override", - richText: null + richText: null, + boolean: null } } ] @@ -165,7 +172,8 @@ export const product: ( name: "Auto Loan Account", reference: null, slug: "Auto-Loan-Account", - richText: null + richText: null, + boolean: null } ] } @@ -360,7 +368,8 @@ export const product: ( name: "File First Value", reference: null, slug: "file-first-value", - richText: null + richText: null, + boolean: null } } ] @@ -397,7 +406,8 @@ export const product: ( name: "Black", reference: null, slug: "black", - richText: null + richText: null, + boolean: null } }, { @@ -410,7 +420,8 @@ export const product: ( name: "White", reference: null, slug: "white", - richText: null + richText: null, + boolean: null } } ] @@ -451,7 +462,8 @@ export const product: ( name: "File First Value", reference: null, slug: "file-first-value", - richText: null + richText: null, + boolean: null } } ] @@ -481,7 +493,8 @@ export const product: ( name: "Black", reference: null, slug: "black", - richText: null + richText: null, + boolean: null } }, { @@ -494,7 +507,8 @@ export const product: ( name: "White", reference: null, slug: "white", - richText: null + richText: null, + boolean: null } } ] @@ -953,7 +967,8 @@ export const products = ( name: "Pineapple", reference: null, slug: "pineapple", - richText: null + richText: null, + boolean: null } ] } @@ -1062,7 +1077,8 @@ export const products = ( name: "Coconut", reference: null, slug: "coconut", - richText: null + richText: null, + boolean: null } ] } @@ -1171,7 +1187,8 @@ export const products = ( name: "Apple", reference: null, slug: "apple", - richText: null + richText: null, + boolean: null } ] } @@ -1281,7 +1298,8 @@ export const products = ( name: "Orange", reference: null, slug: "orange", - richText: null + richText: null, + boolean: null } ] } @@ -1390,7 +1408,8 @@ export const products = ( name: "Banana", reference: null, slug: "banana", - richText: null + richText: null, + boolean: null } ] } @@ -1499,7 +1518,8 @@ export const products = ( name: "Bean", reference: null, slug: "bean", - richText: null + richText: null, + boolean: null } ] } @@ -1608,7 +1628,8 @@ export const products = ( name: "Carrot", reference: null, slug: "carrot", - richText: null + richText: null, + boolean: null } ] } @@ -1717,7 +1738,8 @@ export const products = ( name: "Sprouty", reference: null, slug: "sprouty", - richText: null + richText: null, + boolean: null } ] } @@ -1826,7 +1848,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -1935,7 +1958,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2044,7 +2068,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2153,7 +2178,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2262,7 +2288,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2371,7 +2398,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2480,7 +2508,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2589,7 +2618,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2698,7 +2728,8 @@ export const products = ( name: "Cotton", reference: null, slug: "cotton", - richText: null + richText: null, + boolean: null } ] } @@ -2909,7 +2940,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "File First Value", reference: null, slug: "file-first-value", - richText: null + richText: null, + boolean: null } } ] @@ -2927,7 +2959,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "File First Value", reference: null, slug: "file-first-value", - richText: null + richText: null, + boolean: null } ] } @@ -3188,7 +3221,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "portals", reference: null, slug: "portals", - richText: null + richText: null, + boolean: null } }, { @@ -3201,7 +3235,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "Baht", reference: null, slug: "Baht", - richText: null + richText: null, + boolean: null } } ] @@ -3215,7 +3250,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "portals", reference: null, slug: "portals", - richText: null + richText: null, + boolean: null } ] }, @@ -3250,7 +3286,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "payment", reference: null, slug: "payment", - richText: null + richText: null, + boolean: null } }, { @@ -3263,7 +3300,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "Auto Loan Account", reference: null, slug: "Auto-Loan-Account", - richText: null + richText: null, + boolean: null } }, { @@ -3276,7 +3314,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "Garden", reference: null, slug: "Garden", - richText: null + richText: null, + boolean: null } }, { @@ -3289,7 +3328,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "override", reference: null, slug: "override", - richText: null + richText: null, + boolean: null } } ] @@ -3303,7 +3343,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({ name: "Auto Loan Account", reference: null, slug: "Auto-Loan-Account", - richText: null + richText: null, + boolean: null } ] } diff --git a/src/products/queries.ts b/src/products/queries.ts index c38b92c8e..eac8de0a4 100644 --- a/src/products/queries.ts +++ b/src/products/queries.ts @@ -66,12 +66,14 @@ const initialProductFilterAttributesQuery = gql` node { id name + inputType slug } } } } `; + export const useInitialProductFilterAttributesQuery = makeQuery< InitialProductFilterAttributes, never diff --git a/src/products/types/CreateMultipleVariantsData.ts b/src/products/types/CreateMultipleVariantsData.ts index f5061c9df..21f3306a1 100644 --- a/src/products/types/CreateMultipleVariantsData.ts +++ b/src/products/types/CreateMultipleVariantsData.ts @@ -31,6 +31,7 @@ export interface CreateMultipleVariantsData_product_attributes_attribute_choices file: CreateMultipleVariantsData_product_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface CreateMultipleVariantsData_product_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface CreateMultipleVariantsData_product_attributes_values { file: CreateMultipleVariantsData_product_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface CreateMultipleVariantsData_product_attributes { @@ -101,6 +103,7 @@ export interface CreateMultipleVariantsData_product_productType_variantAttribute file: CreateMultipleVariantsData_product_productType_variantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface CreateMultipleVariantsData_product_productType_variantAttributes_choices_edges { diff --git a/src/products/types/InitialProductFilterAttributes.ts b/src/products/types/InitialProductFilterAttributes.ts index f99b942ae..013d2d664 100644 --- a/src/products/types/InitialProductFilterAttributes.ts +++ b/src/products/types/InitialProductFilterAttributes.ts @@ -3,6 +3,8 @@ // @generated // This file was automatically generated and should not be edited. +import { AttributeInputTypeEnum } from "./../../types/globalTypes"; + // ==================================================== // GraphQL query operation: InitialProductFilterAttributes // ==================================================== @@ -11,6 +13,7 @@ export interface InitialProductFilterAttributes_attributes_edges_node { __typename: "Attribute"; id: string; name: string | null; + inputType: AttributeInputTypeEnum | null; slug: string | null; } diff --git a/src/products/types/ProductDetails.ts b/src/products/types/ProductDetails.ts index 545e18043..de08c963a 100644 --- a/src/products/types/ProductDetails.ts +++ b/src/products/types/ProductDetails.ts @@ -31,6 +31,7 @@ export interface ProductDetails_product_attributes_attribute_choices_edges_node file: ProductDetails_product_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductDetails_product_attributes_attribute_choices_edges { @@ -71,6 +72,7 @@ export interface ProductDetails_product_attributes_values { file: ProductDetails_product_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductDetails_product_attributes { @@ -101,6 +103,7 @@ export interface ProductDetails_product_productType_variantAttributes_choices_ed file: ProductDetails_product_productType_variantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductDetails_product_productType_variantAttributes_choices_edges { diff --git a/src/products/types/ProductList.ts b/src/products/types/ProductList.ts index b759b4f39..593cd623f 100644 --- a/src/products/types/ProductList.ts +++ b/src/products/types/ProductList.ts @@ -91,6 +91,7 @@ export interface ProductList_products_edges_node_attributes_values { file: ProductList_products_edges_node_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductList_products_edges_node_attributes { diff --git a/src/products/types/ProductType.ts b/src/products/types/ProductType.ts index 1e22ce8c5..ac006f2f9 100644 --- a/src/products/types/ProductType.ts +++ b/src/products/types/ProductType.ts @@ -31,6 +31,7 @@ export interface ProductType_productType_productAttributes_choices_edges_node { file: ProductType_productType_productAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductType_productType_productAttributes_choices_edges { diff --git a/src/products/types/ProductUpdate.ts b/src/products/types/ProductUpdate.ts index 62f344544..130fef194 100644 --- a/src/products/types/ProductUpdate.ts +++ b/src/products/types/ProductUpdate.ts @@ -38,6 +38,7 @@ export interface ProductUpdate_productUpdate_product_attributes_attribute_choice file: ProductUpdate_productUpdate_product_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductUpdate_productUpdate_product_attributes_attribute_choices_edges { @@ -78,6 +79,7 @@ export interface ProductUpdate_productUpdate_product_attributes_values { file: ProductUpdate_productUpdate_product_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductUpdate_productUpdate_product_attributes { @@ -108,6 +110,7 @@ export interface ProductUpdate_productUpdate_product_productType_variantAttribut file: ProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges { diff --git a/src/products/types/ProductVariantCreateData.ts b/src/products/types/ProductVariantCreateData.ts index afbd6e022..a86d7b787 100644 --- a/src/products/types/ProductVariantCreateData.ts +++ b/src/products/types/ProductVariantCreateData.ts @@ -50,6 +50,7 @@ export interface ProductVariantCreateData_product_productType_selectionVariantAt file: ProductVariantCreateData_product_productType_selectionVariantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantCreateData_product_productType_selectionVariantAttributes_choices_edges { @@ -98,6 +99,7 @@ export interface ProductVariantCreateData_product_productType_nonSelectionVarian file: ProductVariantCreateData_product_productType_nonSelectionVariantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantCreateData_product_productType_nonSelectionVariantAttributes_choices_edges { diff --git a/src/products/types/ProductVariantDetails.ts b/src/products/types/ProductVariantDetails.ts index f150dc1f7..d41e07c15 100644 --- a/src/products/types/ProductVariantDetails.ts +++ b/src/products/types/ProductVariantDetails.ts @@ -43,6 +43,7 @@ export interface ProductVariantDetails_productVariant_selectionAttributes_attrib file: ProductVariantDetails_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantDetails_productVariant_selectionAttributes_attribute_choices_edges { @@ -83,6 +84,7 @@ export interface ProductVariantDetails_productVariant_selectionAttributes_values file: ProductVariantDetails_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantDetails_productVariant_selectionAttributes { @@ -113,6 +115,7 @@ export interface ProductVariantDetails_productVariant_nonSelectionAttributes_att file: ProductVariantDetails_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantDetails_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -153,6 +156,7 @@ export interface ProductVariantDetails_productVariant_nonSelectionAttributes_val file: ProductVariantDetails_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface ProductVariantDetails_productVariant_nonSelectionAttributes { diff --git a/src/products/types/SimpleProductUpdate.ts b/src/products/types/SimpleProductUpdate.ts index 6b35a55e7..ebd67067d 100644 --- a/src/products/types/SimpleProductUpdate.ts +++ b/src/products/types/SimpleProductUpdate.ts @@ -38,6 +38,7 @@ export interface SimpleProductUpdate_productUpdate_product_attributes_attribute_ file: SimpleProductUpdate_productUpdate_product_attributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productUpdate_product_attributes_attribute_choices_edges { @@ -78,6 +79,7 @@ export interface SimpleProductUpdate_productUpdate_product_attributes_values { file: SimpleProductUpdate_productUpdate_product_attributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productUpdate_product_attributes { @@ -108,6 +110,7 @@ export interface SimpleProductUpdate_productUpdate_product_productType_variantAt file: SimpleProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges { @@ -375,6 +378,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_selecti file: SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges { @@ -415,6 +419,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_selecti file: SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes { @@ -445,6 +450,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSele file: SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -485,6 +491,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSele file: SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes { @@ -706,6 +713,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_s file: SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes_attribute_choices_edges { @@ -746,6 +754,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_s file: SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes { @@ -776,6 +785,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_n file: SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -816,6 +826,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_n file: SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes { @@ -1036,6 +1047,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_s file: SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes_attribute_choices_edges { @@ -1076,6 +1088,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_s file: SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes { @@ -1106,6 +1119,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_n file: SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -1146,6 +1160,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_n file: SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes { @@ -1367,6 +1382,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_s file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges { @@ -1407,6 +1423,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_s file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes { @@ -1437,6 +1454,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_n file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -1477,6 +1495,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_n file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes { diff --git a/src/products/types/VariantCreate.ts b/src/products/types/VariantCreate.ts index 44f791bb1..75ed9ee82 100644 --- a/src/products/types/VariantCreate.ts +++ b/src/products/types/VariantCreate.ts @@ -50,6 +50,7 @@ export interface VariantCreate_productVariantCreate_productVariant_selectionAttr file: VariantCreate_productVariantCreate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantCreate_productVariantCreate_productVariant_selectionAttributes_attribute_choices_edges { @@ -90,6 +91,7 @@ export interface VariantCreate_productVariantCreate_productVariant_selectionAttr file: VariantCreate_productVariantCreate_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantCreate_productVariantCreate_productVariant_selectionAttributes { @@ -120,6 +122,7 @@ export interface VariantCreate_productVariantCreate_productVariant_nonSelectionA file: VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -160,6 +163,7 @@ export interface VariantCreate_productVariantCreate_productVariant_nonSelectionA file: VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes { diff --git a/src/products/types/VariantUpdate.ts b/src/products/types/VariantUpdate.ts index 395170d3a..fa6f8421b 100644 --- a/src/products/types/VariantUpdate.ts +++ b/src/products/types/VariantUpdate.ts @@ -50,6 +50,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttr file: VariantUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges { @@ -90,6 +91,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttr file: VariantUpdate_productVariantUpdate_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttributes { @@ -120,6 +122,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionA file: VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -160,6 +163,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionA file: VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes { @@ -381,6 +385,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_selecti file: VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges { @@ -421,6 +426,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_selecti file: VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes { @@ -451,6 +457,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSele file: VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges { @@ -491,6 +498,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSele file: VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_values_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes { diff --git a/src/products/views/ProductList/filters.ts b/src/products/views/ProductList/filters.ts index 9b0777769..600811f7c 100644 --- a/src/products/views/ProductList/filters.ts +++ b/src/products/views/ProductList/filters.ts @@ -83,6 +83,7 @@ export function getFilterOpts( id: attr.id, name: attr.name, slug: attr.slug, + inputType: attr.inputType, value: !!params.attributes && params.attributes[attr.slug] ? dedupeFilter(params.attributes[attr.slug]) @@ -198,20 +199,35 @@ export function getFilterOpts( }; } +function getFilteredAttributeValue( + params: ProductListUrlFilters +): Array<({ boolean: boolean } | { values: string[] }) & { slug: string }> { + return !!params.attributes + ? Object.keys(params.attributes).map(key => { + const value = params.attributes[key]; + const isMulti = isArray(params.attributes[key]); + const isBooleanValue = + !isMulti && ["true", "false"].includes((value as unknown) as string); + + return { + slug: key, + ...(isBooleanValue + ? { boolean: JSON.parse((value as unknown) as string) } + : { + // It is possible for qs to parse values not as string[] but string + values: isMulti ? value : (([value] as unknown) as string[]) + }) + }; + }) + : null; +} + export function getFilterVariables( params: ProductListUrlFilters, channel: string | undefined ): ProductFilterInput { return { - attributes: !!params.attributes - ? Object.keys(params.attributes).map(key => ({ - slug: key, - // It is possible for qs to parse values not as string[] but string - values: isArray(params.attributes[key]) - ? params.attributes[key] - : (([params.attributes[key]] as unknown) as string[]) - })) - : null, + attributes: getFilteredAttributeValue(params), categories: params.categories !== undefined ? params.categories : null, channel: channel || null, collections: params.collections !== undefined ? params.collections : null, diff --git a/src/products/views/ProductList/fixtures.ts b/src/products/views/ProductList/fixtures.ts index 3d8fd6d0f..dac49f17b 100644 --- a/src/products/views/ProductList/fixtures.ts +++ b/src/products/views/ProductList/fixtures.ts @@ -11,6 +11,7 @@ export const productListFilterOpts: ProductListFilterOpts = { attributes: attributes.map(attr => ({ id: attr.id, active: false, + inputType: attr.inputType, name: attr.name, slug: attr.slug, value: [ diff --git a/src/searches/types/SearchAttributeValues.ts b/src/searches/types/SearchAttributeValues.ts index 7b1f1e156..77abb7644 100644 --- a/src/searches/types/SearchAttributeValues.ts +++ b/src/searches/types/SearchAttributeValues.ts @@ -21,6 +21,7 @@ export interface SearchAttributeValues_attribute_choices_edges_node { file: SearchAttributeValues_attribute_choices_edges_node_file | null; reference: string | null; richText: any | null; + boolean: boolean | null; } export interface SearchAttributeValues_attribute_choices_edges { diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 819d7be67..ebb2c2533 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -61,7 +61,7 @@ exports[`Storyshots Attributes / Attributes default 1`] = `
- 6 Attributes + 7 Attributes