From 7519668b224e10522dc2252e185b52b2632f3335 Mon Sep 17 00:00:00 2001 From: Giuseppe Ciotola <30926550+gciotola@users.noreply.github.com> Date: Wed, 24 May 2023 15:28:31 +0200 Subject: [PATCH 1/4] fix(embedded): add order payload for update event --- packages/cart/@typing/global.d.ts | 12 +++++++++--- packages/cart/src/components/Cart/index.tsx | 7 +++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/cart/@typing/global.d.ts b/packages/cart/@typing/global.d.ts index 2280b84a..780a45bd 100644 --- a/packages/cart/@typing/global.d.ts +++ b/packages/cart/@typing/global.d.ts @@ -1,11 +1,17 @@ +import { Order } from "@commercelayer/sdk" import { IFrameObject as IframeResizerObject } from "iframe-resizer" type IframeEvent = "update" | "close" | "blur" type IframeReceivedEvent = "update" -type IframeMessagePayload = { - type: IframeEvent -} +type IframeMessagePayload = + | { + type: Exclude + } + | { + type: "update" + payload?: Order + } type IFrameObject = Omit & { sendMessage: (message: IframeMessagePayload, targetOrigin: string) => void diff --git a/packages/cart/src/components/Cart/index.tsx b/packages/cart/src/components/Cart/index.tsx index 89844136..8f03c79c 100644 --- a/packages/cart/src/components/Cart/index.tsx +++ b/packages/cart/src/components/Cart/index.tsx @@ -33,9 +33,12 @@ const Cart: FC = () => { attributes={{ cart_url: settings.cartUrl || window.location.href, }} - fetchOrder={() => { + fetchOrder={(order) => { // send update event to parent iframe if iframe-resizer is enabled - window.parentIFrame?.sendMessage({ type: "update" }, "*") + window.parentIFrame?.sendMessage( + { type: "update", payload: order }, + "*" + ) }} > From fbdb247046795ad3b6fb6d0c697156e635e9b48d Mon Sep 17 00:00:00 2001 From: Giuseppe Ciotola <30926550+gciotola@users.noreply.github.com> Date: Wed, 24 May 2023 15:28:51 +0200 Subject: [PATCH 2/4] v3.1.3-stg.0 --- lerna.json | 2 +- packages/cart/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index dd091931..752241a0 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.1.2", + "version": "3.1.3-stg.0", "$schema": "node_modules/lerna/schemas/lerna-schema.json", "useNx": false, "npmClient": "pnpm", diff --git a/packages/cart/package.json b/packages/cart/package.json index 98ab699a..5872d4b4 100644 --- a/packages/cart/package.json +++ b/packages/cart/package.json @@ -1,6 +1,6 @@ { "name": "commercelayer-cart", - "version": "3.1.2", + "version": "3.1.3-stg.0", "private": true, "author": { "name": "Giuseppe Ciotola", From 07958aa57389816e6c46af88ffdd875ffa620a49 Mon Sep 17 00:00:00 2001 From: Giuseppe Ciotola <30926550+gciotola@users.noreply.github.com> Date: Wed, 24 May 2023 15:48:47 +0200 Subject: [PATCH 3/4] chore: improve typings --- packages/cart/@typing/global.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cart/@typing/global.d.ts b/packages/cart/@typing/global.d.ts index 780a45bd..10479d12 100644 --- a/packages/cart/@typing/global.d.ts +++ b/packages/cart/@typing/global.d.ts @@ -5,13 +5,16 @@ type IframeEvent = "update" | "close" | "blur" type IframeReceivedEvent = "update" type IframeMessagePayload = - | { - type: Exclude - } | { type: "update" payload?: Order } + | { + type: "close" + } + | { + type: "blur" + } type IFrameObject = Omit & { sendMessage: (message: IframeMessagePayload, targetOrigin: string) => void From f7f7198bee405a6e1fb8c90212270568aba1923c Mon Sep 17 00:00:00 2001 From: Giuseppe Ciotola <30926550+gciotola@users.noreply.github.com> Date: Wed, 24 May 2023 15:49:02 +0200 Subject: [PATCH 4/4] v3.1.3 --- lerna.json | 2 +- packages/cart/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index 752241a0..ceb51c99 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.1.3-stg.0", + "version": "3.1.3", "$schema": "node_modules/lerna/schemas/lerna-schema.json", "useNx": false, "npmClient": "pnpm", diff --git a/packages/cart/package.json b/packages/cart/package.json index 5872d4b4..cd5b8812 100644 --- a/packages/cart/package.json +++ b/packages/cart/package.json @@ -1,6 +1,6 @@ { "name": "commercelayer-cart", - "version": "3.1.3-stg.0", + "version": "3.1.3", "private": true, "author": { "name": "Giuseppe Ciotola",