Skip to content

Commit

Permalink
fix: urgently fixing build
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-victor authored and libruce committed Dec 27, 2023
1 parent aef7b21 commit 755b43b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/storefront/src/pages/quote/QuoteDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -403,7 +404,7 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
}

const handleSubmit = useCallbacks(
'on-quote-create',
CallbackKey.onQuoteCreate,
async (_e, handleEvent) => {
setLoading(true)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/utils/b3Callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand All @@ -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])
}
Expand Down
1 change: 0 additions & 1 deletion packages/hooks/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
declare type Callback = (...args: any[]) => any
declare enum CallbackKey {
onQuoteCreate = 'on-quote-create',
onAddToShoppingList = 'on-add-to-shopping-list',
Expand Down
5 changes: 5 additions & 0 deletions packages/hooks/useCustomCallbacks.ts
Original file line number Diff line number Diff line change
@@ -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> | any
Expand Down

0 comments on commit 755b43b

Please sign in to comment.