From 755b43be7314e37e3514bd142ea7b9581a3d1be0 Mon Sep 17 00:00:00 2001 From: Victor Campos Date: Tue, 19 Dec 2023 10:09:51 -0600 Subject: [PATCH] fix: urgently fixing build --- apps/storefront/src/pages/quote/QuoteDraft.tsx | 3 ++- .../shoppingListDetails/components/AddToShoppingList.tsx | 3 ++- apps/storefront/src/utils/b3Callbacks.ts | 4 ++-- packages/hooks/index.d.ts | 1 - packages/hooks/useCustomCallbacks.ts | 5 +++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/storefront/src/pages/quote/QuoteDraft.tsx b/apps/storefront/src/pages/quote/QuoteDraft.tsx index 1df9f746..899c006c 100644 --- a/apps/storefront/src/pages/quote/QuoteDraft.tsx +++ b/apps/storefront/src/pages/quote/QuoteDraft.tsx @@ -41,6 +41,7 @@ import { snackbar, storeHash, } from '@/utils' +import { CallbackKey } from '@/utils/b3Callbacks' import { getProductOptionsFields } from '../../utils/b3Product/shared/config' import { convertBCToB2BAddress } from '../address/shared/config' @@ -403,7 +404,7 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) { } const handleSubmit = useCallbacks( - 'on-quote-create', + CallbackKey.onQuoteCreate, async (_e, handleEvent) => { setLoading(true) try { diff --git a/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx b/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx index 89712266..72c5be0d 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/AddToShoppingList.tsx @@ -11,6 +11,7 @@ import { addProductToShoppingList, } from '@/shared/service/b2b' import { B3SStorage, getValidOptionsList, snackbar } from '@/utils' +import { CallbackKey } from '@/utils/b3Callbacks' import { getAllModifierDefaultValue } from '../../../utils/b3Product/shared/config' import { ShoppingListDetailsContext } from '../context/ShoppingListDetailsContext' @@ -41,7 +42,7 @@ export default function AddToShoppingList(props: AddToListProps) { : addProductToBcShoppingList const addToList = useCallbacks( - 'on-add-to-shopping-list', + CallbackKey.onAddToShoppingList, async (products: CustomFieldItems[], handleEvent) => { try { if (!handleEvent(products)) { diff --git a/apps/storefront/src/utils/b3Callbacks.ts b/apps/storefront/src/utils/b3Callbacks.ts index 4ee15681..de1cbf32 100644 --- a/apps/storefront/src/utils/b3Callbacks.ts +++ b/apps/storefront/src/utils/b3Callbacks.ts @@ -2,7 +2,7 @@ type CallbackEvent = { data: CustomFieldItems preventDefault: () => void } -enum CallbackKey { +export enum CallbackKey { onQuoteCreate = 'on-quote-create', onAddToShoppingList = 'on-add-to-shopping-list', } @@ -21,7 +21,7 @@ export default class CallbackManager { * @param callback The callback function to register. * @returns A unique hash identifying the registered callback. */ - addEventListener(callbackKey: CallbackKey, callback: Callback): string { + addEventListener(callbackKey: CallbackKey, callback: Callback): void { if (!this.callbacks.has(callbackKey)) { this.callbacks.set(callbackKey, [callback]) } diff --git a/packages/hooks/index.d.ts b/packages/hooks/index.d.ts index cdd944b1..22209da8 100644 --- a/packages/hooks/index.d.ts +++ b/packages/hooks/index.d.ts @@ -1,4 +1,3 @@ -declare type Callback = (...args: any[]) => any declare enum CallbackKey { onQuoteCreate = 'on-quote-create', onAddToShoppingList = 'on-add-to-shopping-list', diff --git a/packages/hooks/useCustomCallbacks.ts b/packages/hooks/useCustomCallbacks.ts index 4a689fc3..ca0273e9 100644 --- a/packages/hooks/useCustomCallbacks.ts +++ b/packages/hooks/useCustomCallbacks.ts @@ -1,3 +1,8 @@ +enum CallbackKey { + onQuoteCreate = 'on-quote-create', + onAddToShoppingList = 'on-add-to-shopping-list', +} + const useCallbacks = ( callbacks: CallbackKey[] | CallbackKey, fn: (...args: any[]) => Promise | any