From abba4af8eb6f0cce014c9c49f9d701f97235028a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Mon, 8 Jan 2024 08:09:34 +0100 Subject: [PATCH 1/6] Stop send empty conditions --- src/discounts/models/Condition.test.ts | 6 ++++++ src/discounts/models/Condition.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/discounts/models/Condition.test.ts b/src/discounts/models/Condition.test.ts index 60bc6cef35d..9ff66e96edd 100644 --- a/src/discounts/models/Condition.test.ts +++ b/src/discounts/models/Condition.test.ts @@ -31,4 +31,10 @@ describe("Condition model", () => { }, }); }); + + it("should return undefined when transforming domian object to API and values array is empty", () => { + const condition = new Condition("product", "is", []); + + expect(condition.toAPI()).toBeUndefined(); + }); }); diff --git a/src/discounts/models/Condition.ts b/src/discounts/models/Condition.ts index d39a2cc6a75..6903cfd014e 100644 --- a/src/discounts/models/Condition.ts +++ b/src/discounts/models/Condition.ts @@ -11,7 +11,7 @@ export class Condition { ) {} public toAPI(): CataloguePredicateInput | undefined { - if (!this.type) { + if (!this.type || !this.values.length) { return undefined; } From dccc684e0dfcae6c35cbe7b007dcf63bfbc4d8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Tue, 9 Jan 2024 13:54:24 +0100 Subject: [PATCH 2/6] Bump macaw --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 98c6c7579bf..566506b843d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "@material-ui/styles": "^4.11.4", "@reach/auto-id": "^0.16.0", "@saleor/macaw-ui": "npm:@saleor/macaw-ui@0.7.4", - "@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.0.0-pre.16", + "@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.0.0-pre.18", "@saleor/sdk": "0.6.0", "@sentry/react": "^7.83.0", "@types/faker": "^5.1.6", @@ -9114,9 +9114,9 @@ }, "node_modules/@saleor/macaw-ui-next": { "name": "@saleor/macaw-ui", - "version": "1.0.0-pre.16", - "resolved": "https://registry.npmjs.org/@saleor/macaw-ui/-/macaw-ui-1.0.0-pre.16.tgz", - "integrity": "sha512-W6JaPkQpZ2iGjOIkIVXMWcLEmZ6kCBGzQCnDTkZHOYG8AP3chR9rKrjSYgcDLvabmr3Z7O3F2kMWl6eDjH+B0A==", + "version": "1.0.0-pre.18", + "resolved": "https://registry.npmjs.org/@saleor/macaw-ui/-/macaw-ui-1.0.0-pre.18.tgz", + "integrity": "sha512-NZY6tHjgwSeB8w2Y0IPuc3jfjeUe9L2PMZo6J48n7ZMPlD7szYaiSqRlahc0HL47BbfHQpzhAoN7ckHsneg56A==", "dependencies": { "@dessert-box/react": "^0.4.0", "@floating-ui/react-dom": "^2.0.2", @@ -50042,9 +50042,9 @@ } }, "@saleor/macaw-ui-next": { - "version": "npm:@saleor/macaw-ui@1.0.0-pre.16", - "resolved": "https://registry.npmjs.org/@saleor/macaw-ui/-/macaw-ui-1.0.0-pre.16.tgz", - "integrity": "sha512-W6JaPkQpZ2iGjOIkIVXMWcLEmZ6kCBGzQCnDTkZHOYG8AP3chR9rKrjSYgcDLvabmr3Z7O3F2kMWl6eDjH+B0A==", + "version": "npm:@saleor/macaw-ui@1.0.0-pre.18", + "resolved": "https://registry.npmjs.org/@saleor/macaw-ui/-/macaw-ui-1.0.0-pre.18.tgz", + "integrity": "sha512-NZY6tHjgwSeB8w2Y0IPuc3jfjeUe9L2PMZo6J48n7ZMPlD7szYaiSqRlahc0HL47BbfHQpzhAoN7ckHsneg56A==", "requires": { "@dessert-box/react": "^0.4.0", "@floating-ui/react-dom": "^2.0.2", diff --git a/package.json b/package.json index 481878c84f1..4c20e71cf1f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@material-ui/styles": "^4.11.4", "@reach/auto-id": "^0.16.0", "@saleor/macaw-ui": "npm:@saleor/macaw-ui@0.7.4", - "@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.0.0-pre.16", + "@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.0.0-pre.18", "@saleor/sdk": "0.6.0", "@sentry/react": "^7.83.0", "@types/faker": "^5.1.6", From 0d0cb7f67e868112fd7b4e00a0da4e0bc1cba082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Tue, 9 Jan 2024 13:54:48 +0100 Subject: [PATCH 3/6] Add NoOptions support to combobox and multiselect --- .../Combobox/components/Combobox.tsx | 14 +++++++++--- .../Combobox/components/Multiselect.tsx | 22 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/components/Combobox/components/Combobox.tsx b/src/components/Combobox/components/Combobox.tsx index 7429b5c7de7..fc3a97f5d7d 100644 --- a/src/components/Combobox/components/Combobox.tsx +++ b/src/components/Combobox/components/Combobox.tsx @@ -6,7 +6,7 @@ import { DynamicComboboxProps, Option, } from "@saleor/macaw-ui-next"; -import React, { useEffect, useRef, useState } from "react"; +import React, { ReactNode, useEffect, useRef, useState } from "react"; import { useIntl } from "react-intl"; import { useCombbobxCustomOption } from "../hooks/useCombbobxCustomOption"; @@ -18,6 +18,7 @@ type ComboboxProps = Omit< DynamicComboboxProps