@payloadcms/plugin-ecommerce 3.84.0-canary.3 → 3.84.0-canary.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ export declare const useCurrency: () => {
8
8
  currency: Currency;
9
9
  formatCurrency: (value?: null | number, options?: {
10
10
  currency?: Currency;
11
+ locale?: string;
11
12
  }) => string;
12
13
  setCurrency: (currency: string) => void;
13
14
  supportedCurrencies: Currency[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/provider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAa,MAAM,SAAS,CAAA;AAI/D,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAsD7B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAogCpD,CAAA;AAED,eAAO,MAAM,YAAY,4BAQxB,CAAA;AAED,eAAO,MAAM,kBAAkB,uBAI9B,CAAA;AAED,eAAO,MAAM,WAAW;;6BAIX,IAAI,GAAG,MAAM,YAAY;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,KAAG,MAAM;;;CAkCrE,CAAA;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,eAAe;;;;;UAkB/B,CAAC;;;;;;;EAQlB;AAED,eAAO,MAAM,WAAW;;;;;;;;;;CASvB,CAAA;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,mBAAmB;eAOvB,CAAC,EAAE;;;;;;;;;;EACrC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/provider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAa,MAAM,SAAS,CAAA;AAI/D,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAsD7B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAogCpD,CAAA;AAED,eAAO,MAAM,YAAY,4BAQxB,CAAA;AAED,eAAO,MAAM,kBAAkB,uBAI9B,CAAA;AAED,eAAO,MAAM,WAAW;;6BAIX,IAAI,GAAG,MAAM,YAAY;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAG,MAAM;;;CAmCtF,CAAA;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,eAAe;;;;;UAkB/B,CAAC;;;;;;;EAQlB;AAED,eAAO,MAAM,WAAW;;;;;;;;;;CASvB,CAAA;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,mBAAmB;eAOvB,CAAC,EAAE;;;;;;;;;;EACrC"}
@@ -1027,13 +1027,15 @@ export const useCurrency = ()=>{
1027
1027
  if (!currencyToUse) {
1028
1028
  return value.toString();
1029
1029
  }
1030
- if (value === 0) {
1031
- return `${currencyToUse.symbol}0.${'0'.repeat(currencyToUse.decimals)}`;
1032
- }
1033
- // Convert from base value (e.g., cents) to decimal value (e.g., dollars)
1034
- const decimalValue = value / Math.pow(10, currencyToUse.decimals);
1035
- // Format with the correct number of decimal places
1036
- return `${currencyToUse.symbol}${decimalValue.toFixed(currencyToUse.decimals)}`;
1030
+ const { code, decimals, symbolDisplay } = currencyToUse;
1031
+ const locale = options?.locale || 'en';
1032
+ return new Intl.NumberFormat(locale, {
1033
+ currency: code,
1034
+ currencyDisplay: symbolDisplay || 'symbol',
1035
+ maximumFractionDigits: decimals,
1036
+ minimumFractionDigits: decimals,
1037
+ style: 'currency'
1038
+ }).format(value / Math.pow(10, decimals));
1037
1039
  }, [
1038
1040
  currency
1039
1041
  ]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/react/provider/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultDocumentIDType, TypedUser } from 'payload'\n\nimport { deepMergeSimple, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type {\n AddressesCollection,\n CartsCollection,\n ContextProps,\n Currency,\n EcommerceConfig,\n EcommerceContextType,\n} from '../../types/index.js'\n\nconst defaultContext: EcommerceContextType = {\n addItem: async () => {},\n clearCart: async () => {},\n clearSession: () => {},\n config: {\n addressesSlug: 'addresses',\n api: {\n apiRoute: '/api',\n },\n cartsSlug: 'carts',\n customersSlug: 'users',\n },\n confirmOrder: async () => {},\n createAddress: async () => {},\n currenciesConfig: {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n currency: {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n decrementItem: async () => {},\n incrementItem: async () => {},\n initiatePayment: async () => {},\n isLoading: false,\n mergeCart: async () => {},\n onLogin: async () => {},\n onLogout: () => {},\n paymentMethods: [],\n refreshCart: async () => {},\n removeItem: async () => {},\n setCurrency: () => {},\n updateAddress: async () => {},\n user: null,\n}\n\nconst EcommerceContext = createContext<EcommerceContextType>(defaultContext)\n\nconst defaultLocalStorage = {\n key: 'cart',\n}\n\nexport const EcommerceProvider: React.FC<ContextProps> = ({\n addressesSlug = 'addresses',\n api,\n cartsSlug = 'carts',\n children,\n currenciesConfig = {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n customersSlug = 'users',\n debug = false,\n paymentMethods = [],\n syncLocalStorage = true,\n}) => {\n const localStorageConfig =\n syncLocalStorage && typeof syncLocalStorage === 'object'\n ? {\n ...defaultLocalStorage,\n ...syncLocalStorage,\n }\n : defaultLocalStorage\n\n const { apiRoute = '/api', cartsFetchQuery = {} } = api || {}\n const baseAPIURL = formatAdminURL({\n apiRoute,\n path: '',\n })\n\n const config = useMemo<EcommerceConfig>(\n () => ({\n addressesSlug,\n api: {\n apiRoute,\n },\n cartsSlug,\n customersSlug,\n }),\n [addressesSlug, apiRoute, cartsSlug, customersSlug],\n )\n\n const [isLoading, setIsLoading] = useState(false)\n\n const [user, setUser] = useState<null | TypedUser>(null)\n\n const [addresses, setAddresses] = useState<AddressesCollection[]>()\n\n const hasRendered = useRef(false)\n\n /**\n * The ID of the cart associated with the current session.\n * This is used to identify the cart in the database or local storage.\n * It can be null if no cart has been created yet.\n */\n const [cartID, setCartID] = useState<DefaultDocumentIDType>()\n /**\n * The secret for accessing guest carts without authentication.\n * This is generated when a guest user creates a cart.\n */\n const [cartSecret, setCartSecret] = useState<string | undefined>(undefined)\n const [cart, setCart] = useState<CartsCollection>()\n\n const [selectedCurrency, setSelectedCurrency] = useState<Currency>(\n () =>\n currenciesConfig.supportedCurrencies.find(\n (c) => c.code === currenciesConfig.defaultCurrency,\n )!,\n )\n\n const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<null | string>(null)\n\n const cartQuery = useMemo(() => {\n const priceField = `priceIn${selectedCurrency.code}`\n\n const baseQuery = {\n depth: 0,\n populate: {\n products: {\n [priceField]: true,\n },\n variants: {\n options: true,\n [priceField]: true,\n },\n },\n select: {\n items: true,\n subtotal: true,\n },\n }\n\n return deepMergeSimple(baseQuery, cartsFetchQuery)\n }, [selectedCurrency.code, cartsFetchQuery])\n\n const createCart = useCallback(\n async (initialData: Record<string, unknown>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}?${query}`, {\n body: JSON.stringify({\n ...initialData,\n currency: selectedCurrency.code,\n customer: user?.id,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to create cart: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Cart creation error: ${data.error}`)\n }\n\n // Store the secret for guest cart access\n if (!user && data.doc?.secret) {\n setCartSecret(data.doc.secret)\n }\n\n return data.doc as CartsCollection\n },\n [baseAPIURL, cartQuery, cartsSlug, selectedCurrency.code, user],\n )\n\n const getCart = useCallback(\n async (cartID: DefaultDocumentIDType, options?: { secret?: string }) => {\n const query = qs.stringify({\n ...cartQuery,\n ...(options?.secret ? { secret: options.secret } : {}),\n })\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch cart: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Cart fetch error: ${data.error}`)\n }\n\n return data as CartsCollection\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const refreshCart = useCallback<EcommerceContextType['refreshCart']>(async () => {\n if (!cartID) {\n return\n }\n const updatedCart = await getCart(cartID)\n setCart(updatedCart)\n }, [cartID, getCart])\n\n // Persist cart ID and secret to localStorage\n useEffect(() => {\n if (hasRendered.current) {\n if (syncLocalStorage) {\n if (cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n } else {\n localStorage.removeItem(localStorageConfig.key)\n }\n\n if (cartSecret) {\n localStorage.setItem(`${localStorageConfig.key}_secret`, cartSecret)\n } else {\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n }\n }\n }\n }, [cartID, cartSecret, localStorageConfig.key, syncLocalStorage])\n\n const addItem: EcommerceContextType['addItem'] = useCallback(\n async (item, quantity = 1) => {\n setIsLoading(true)\n try {\n if (cartID) {\n // Use server-side endpoint for adding items\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/add-item`, {\n body: JSON.stringify({\n item,\n quantity,\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to add item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } else {\n // If no cartID exists, create a new cart with the item\n const newCart = await createCart({ items: [{ ...item, quantity }] })\n\n setCartID(newCart.id)\n setCart(newCart)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error adding item to cart:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, createCart, debug, getCart],\n )\n\n const removeItem: EcommerceContextType['removeItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/remove-item`, {\n body: JSON.stringify({\n itemID: targetID,\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to remove item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error removing item from cart:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart],\n )\n\n const incrementItem: EcommerceContextType['incrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/update-item`, {\n body: JSON.stringify({\n itemID: targetID,\n quantity: { $inc: 1 },\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to increment item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error incrementing item quantity:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart],\n )\n\n const decrementItem: EcommerceContextType['decrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/update-item`, {\n body: JSON.stringify({\n itemID: targetID,\n quantity: { $inc: -1 },\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to decrement item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error decrementing item quantity:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart],\n )\n\n const clearCart: EcommerceContextType['clearCart'] = useCallback(async () => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/clear`, {\n body: JSON.stringify({\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to clear cart: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error clearing cart:', error)\n }\n } finally {\n setIsLoading(false)\n }\n }, [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart])\n\n const setCurrency: EcommerceContextType['setCurrency'] = useCallback(\n (currency) => {\n if (selectedCurrency.code === currency) {\n return\n }\n\n const foundCurrency = currenciesConfig.supportedCurrencies.find((c) => c.code === currency)\n if (!foundCurrency) {\n throw new Error(`Currency with code \"${currency}\" not found in config`)\n }\n\n setSelectedCurrency(foundCurrency)\n },\n [currenciesConfig.supportedCurrencies, selectedCurrency.code],\n )\n\n const initiatePayment = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n const paymentMethod = paymentMethods.find((method) => method.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (!cartID) {\n throw new Error(`No cart is provided.`)\n }\n\n setSelectedPaymentMethod(paymentMethodID)\n\n if (paymentMethod.initiatePayment) {\n try {\n const response = await fetch(`${baseAPIURL}/payments/${paymentMethodID}/initiate`, {\n body: JSON.stringify({\n cartID,\n currency: selectedCurrency.code,\n secret: cartSecret,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error initiating payment:', error)\n }\n throw new Error(error instanceof Error ? error.message : 'Failed to initiate payment')\n }\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support payment initiation`)\n }\n },\n [baseAPIURL, cartID, cartSecret, debug, paymentMethods, selectedCurrency.code],\n )\n\n const confirmOrder = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n if (!cartID) {\n throw new Error(`Cart is empty.`)\n }\n\n const paymentMethod = paymentMethods.find((pm) => pm.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (paymentMethod.confirmOrder) {\n const response = await fetch(`${baseAPIURL}/payments/${paymentMethodID}/confirm-order`, {\n body: JSON.stringify({\n cartID,\n currency: selectedCurrency.code,\n secret: cartSecret,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support order confirmation`)\n }\n },\n [baseAPIURL, cartID, cartSecret, paymentMethods, selectedCurrency.code],\n )\n\n const getUser = useCallback(async () => {\n try {\n const query = qs.stringify({\n depth: 0,\n select: {\n id: true,\n cart: true,\n },\n })\n\n const response = await fetch(`${baseAPIURL}/${customersSlug}/me?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch user: ${errorText}`)\n }\n\n const userData = await response.json()\n\n if (userData.error) {\n throw new Error(`User fetch error: ${userData.error}`)\n }\n\n if (userData.user) {\n setUser(userData.user as TypedUser)\n return userData.user as TypedUser\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user:', error)\n }\n setUser(null)\n throw new Error(\n `Failed to fetch user: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [baseAPIURL, customersSlug, debug])\n\n const getAddresses = useCallback(async () => {\n if (!user) {\n return\n }\n\n try {\n const query = qs.stringify({\n depth: 0,\n limit: 0,\n pagination: false,\n })\n\n const response = await fetch(`${baseAPIURL}/${addressesSlug}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n throw new Error(errorText)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address fetch error: ${data.error}`)\n }\n\n if (data.docs && data.docs.length > 0) {\n setAddresses(data.docs)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching addresses:', error)\n }\n setAddresses(undefined)\n throw new Error(\n `Failed to fetch addresses: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [user, baseAPIURL, addressesSlug, debug])\n\n const updateAddress = useCallback<EcommerceContextType['updateAddress']>(\n async (addressID, address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}/${addressID}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n const createAddress = useCallback<EcommerceContextType['createAddress']>(\n async (address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n /**\n * Clears all ecommerce session data from state and localStorage.\n * Used during logout to ensure no user data persists.\n */\n const clearSession = useCallback(() => {\n setCart(undefined)\n setCartID(undefined)\n setCartSecret(undefined)\n setAddresses(undefined)\n setUser(null)\n\n if (syncLocalStorage) {\n localStorage.removeItem(localStorageConfig.key)\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n }\n }, [localStorageConfig.key, syncLocalStorage])\n\n /**\n * Called during logout. Clears all session data.\n */\n const onLogout = useCallback(() => {\n clearSession()\n }, [clearSession])\n\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n const mergeCart = useCallback<EcommerceContextType['mergeCart']>(\n async (targetCartID, sourceCartID, sourceSecret) => {\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${targetCartID}/merge`, {\n body: JSON.stringify({\n sourceCartID,\n sourceSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to merge carts: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n throw new Error(result.message || 'Failed to merge carts')\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(targetCartID)\n setCart(refreshedCart)\n setCartID(targetCartID)\n\n return refreshedCart\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error merging carts:', error)\n }\n throw error\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartsSlug, debug, getCart],\n )\n\n /**\n * Called after login to properly set up cart state.\n * Handles merging guest cart with user's existing cart if applicable.\n */\n const onLogin = useCallback(async () => {\n // Store reference to any existing guest cart before fetching user\n const guestCartID = cartID\n const guestSecret = cartSecret\n\n // Fetch fresh user data\n const fetchedUser = await getUser()\n\n if (!fetchedUser) {\n // No user means login failed, keep current state\n return\n }\n\n // Clear the guest cart secret - authenticated users don't need it\n setCartSecret(undefined)\n if (syncLocalStorage) {\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n }\n\n // Check if user has an existing cart\n const userCartID =\n fetchedUser.cart?.docs && fetchedUser.cart.docs.length > 0\n ? typeof fetchedUser.cart.docs[0] === 'object'\n ? fetchedUser.cart.docs[0].id\n : fetchedUser.cart.docs[0]\n : undefined\n\n if (guestCartID && guestSecret) {\n // Guest had a cart - need to handle merge/transfer\n if (userCartID) {\n // User has existing cart - merge guest cart into user's cart\n try {\n await mergeCart(userCartID, guestCartID, guestSecret)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error merging carts:', error)\n }\n // Fall back to user's cart\n const userCart = await getCart(userCartID)\n setCart(userCart)\n setCartID(userCartID)\n }\n } else {\n // User has no existing cart - transfer guest cart to user\n try {\n const response = await fetch(\n `${baseAPIURL}/${cartsSlug}/${guestCartID}?secret=${guestSecret}`,\n {\n body: JSON.stringify({\n customer: fetchedUser.id,\n secret: null, // Clear the secret since it's now owned by user\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n },\n )\n\n if (response.ok) {\n // Fetch updated cart\n const updatedCart = await getCart(guestCartID)\n setCart(updatedCart)\n setCartID(guestCartID)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error transferring cart to user:', error)\n }\n }\n }\n } else if (userCartID) {\n // No guest cart, but user has a cart - fetch it\n const userCart = await getCart(userCartID)\n setCart(userCart)\n setCartID(userCartID)\n }\n\n // Update localStorage with user's cart ID (no secret needed)\n if (syncLocalStorage && cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n }\n }, [\n baseAPIURL,\n cartID,\n cartSecret,\n cartsSlug,\n debug,\n getCart,\n getUser,\n localStorageConfig.key,\n mergeCart,\n syncLocalStorage,\n ])\n\n // If localStorage is enabled, restore cart from storage\n useEffect(() => {\n if (!hasRendered.current) {\n if (syncLocalStorage) {\n const storedCartID = localStorage.getItem(localStorageConfig.key)\n const storedSecret = localStorage.getItem(`${localStorageConfig.key}_secret`)\n\n if (storedCartID) {\n getCart(storedCartID, { secret: storedSecret || undefined })\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(storedCartID as DefaultDocumentIDType)\n if (storedSecret) {\n setCartSecret(storedSecret)\n }\n })\n .catch((_) => {\n // console.error('Error fetching cart from localStorage:', error)\n // If there's an error fetching the cart, clear it from localStorage\n localStorage.removeItem(localStorageConfig.key)\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n })\n }\n }\n\n hasRendered.current = true\n\n void getUser().then((user) => {\n if (user && user.cart?.docs && user.cart.docs.length > 0) {\n // If the user has carts, we can set the cartID to the first cart\n const cartID =\n typeof user.cart.docs[0] === 'object' ? user.cart.docs[0].id : user.cart.docs[0]\n\n if (cartID) {\n getCart(cartID)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(cartID)\n })\n .catch((error) => {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user cart:', error)\n }\n\n setCart(undefined)\n setCartID(undefined)\n\n throw new Error(`Failed to fetch user cart: ${error.message}`)\n })\n }\n }\n })\n }\n }, [debug, getAddresses, getCart, getUser, localStorageConfig.key, syncLocalStorage])\n\n useEffect(() => {\n if (user) {\n // If the user is logged in, fetch their addresses\n void getAddresses()\n } else {\n // If no user is logged in, clear addresses\n setAddresses(undefined)\n }\n }, [getAddresses, user])\n\n return (\n <EcommerceContext\n value={{\n addItem,\n addresses,\n cart,\n clearCart,\n clearSession,\n config,\n confirmOrder,\n createAddress,\n currenciesConfig,\n currency: selectedCurrency,\n decrementItem,\n incrementItem,\n initiatePayment,\n isLoading,\n mergeCart,\n onLogin,\n onLogout,\n paymentMethods,\n refreshCart,\n removeItem,\n selectedPaymentMethod,\n setCurrency,\n updateAddress,\n user,\n }}\n >\n {children}\n </EcommerceContext>\n )\n}\n\nexport const useEcommerce = () => {\n const context = use(EcommerceContext)\n\n if (!context) {\n throw new Error('useEcommerce must be used within an EcommerceProvider')\n }\n\n return context\n}\n\nexport const useEcommerceConfig = () => {\n const { config } = useEcommerce()\n\n return config\n}\n\nexport const useCurrency = () => {\n const { currenciesConfig, currency, setCurrency } = useEcommerce()\n\n const formatCurrency = useCallback(\n (value?: null | number, options?: { currency?: Currency }): string => {\n if (value === undefined || value === null) {\n return ''\n }\n\n const currencyToUse = options?.currency || currency\n\n if (!currencyToUse) {\n return value.toString()\n }\n\n if (value === 0) {\n return `${currencyToUse.symbol}0.${'0'.repeat(currencyToUse.decimals)}`\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = value / Math.pow(10, currencyToUse.decimals)\n\n // Format with the correct number of decimal places\n return `${currencyToUse.symbol}${decimalValue.toFixed(currencyToUse.decimals)}`\n },\n [currency],\n )\n\n if (!currency) {\n throw new Error('useCurrency must be used within an EcommerceProvider')\n }\n\n return {\n currency,\n formatCurrency,\n setCurrency,\n supportedCurrencies: currenciesConfig.supportedCurrencies,\n }\n}\n\nexport function useCart<T extends CartsCollection>() {\n const {\n addItem,\n cart,\n clearCart,\n decrementItem,\n incrementItem,\n isLoading,\n refreshCart,\n removeItem,\n } = useEcommerce()\n\n if (!addItem) {\n throw new Error('useCart must be used within an EcommerceProvider')\n }\n\n return {\n addItem,\n cart: cart as T,\n clearCart,\n decrementItem,\n incrementItem,\n isLoading,\n refreshCart,\n removeItem,\n }\n}\n\nexport const usePayments = () => {\n const { confirmOrder, initiatePayment, isLoading, paymentMethods, selectedPaymentMethod } =\n useEcommerce()\n\n if (!initiatePayment) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { confirmOrder, initiatePayment, isLoading, paymentMethods, selectedPaymentMethod }\n}\n\nexport function useAddresses<T extends AddressesCollection>() {\n const { addresses, createAddress, isLoading, updateAddress } = useEcommerce()\n\n if (!createAddress) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { addresses: addresses as T[], createAddress, isLoading, updateAddress }\n}\n"],"names":["deepMergeSimple","formatAdminURL","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","defaultContext","addItem","clearCart","clearSession","config","addressesSlug","api","apiRoute","cartsSlug","customersSlug","confirmOrder","createAddress","currenciesConfig","defaultCurrency","supportedCurrencies","code","decimals","label","symbol","currency","decrementItem","incrementItem","initiatePayment","isLoading","mergeCart","onLogin","onLogout","paymentMethods","refreshCart","removeItem","setCurrency","updateAddress","user","EcommerceContext","defaultLocalStorage","key","EcommerceProvider","children","debug","syncLocalStorage","localStorageConfig","cartsFetchQuery","baseAPIURL","path","setIsLoading","setUser","addresses","setAddresses","hasRendered","cartID","setCartID","cartSecret","setCartSecret","undefined","cart","setCart","selectedCurrency","setSelectedCurrency","find","c","selectedPaymentMethod","setSelectedPaymentMethod","cartQuery","priceField","baseQuery","depth","populate","products","variants","options","select","items","subtotal","createCart","initialData","query","stringify","response","fetch","body","JSON","customer","id","credentials","headers","method","ok","errorText","text","Error","data","json","error","doc","secret","getCart","updatedCart","current","localStorage","setItem","item","quantity","result","success","refreshedCart","newCart","console","targetID","itemID","$inc","foundCurrency","paymentMethodID","paymentMethod","name","additionalData","responseError","responseData","message","pm","getUser","userData","getAddresses","limit","pagination","docs","length","addressID","address","targetCartID","sourceCartID","sourceSecret","guestCartID","guestSecret","fetchedUser","userCartID","userCart","storedCartID","getItem","storedSecret","then","fetchedCart","catch","_","value","useEcommerce","context","useEcommerceConfig","useCurrency","formatCurrency","currencyToUse","toString","repeat","decimalValue","Math","pow","toFixed","useCart","usePayments","useAddresses"],"mappings":"AAAA;;AAGA,SAASA,eAAe,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAWpG,MAAMC,iBAAuC;IAC3CC,SAAS,WAAa;IACtBC,WAAW,WAAa;IACxBC,cAAc,KAAO;IACrBC,QAAQ;QACNC,eAAe;QACfC,KAAK;YACHC,UAAU;QACZ;QACAC,WAAW;QACXC,eAAe;IACjB;IACAC,cAAc,WAAa;IAC3BC,eAAe,WAAa;IAC5BC,kBAAkB;QAChBC,iBAAiB;QACjBC,qBAAqB;YACnB;gBACEC,MAAM;gBACNC,UAAU;gBACVC,OAAO;gBACPC,QAAQ;YACV;SACD;IACH;IACAC,UAAU;QACRJ,MAAM;QACNC,UAAU;QACVC,OAAO;QACPC,QAAQ;IACV;IACAE,eAAe,WAAa;IAC5BC,eAAe,WAAa;IAC5BC,iBAAiB,WAAa;IA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/react/provider/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultDocumentIDType, TypedUser } from 'payload'\n\nimport { deepMergeSimple, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type {\n AddressesCollection,\n CartsCollection,\n ContextProps,\n Currency,\n EcommerceConfig,\n EcommerceContextType,\n} from '../../types/index.js'\n\nconst defaultContext: EcommerceContextType = {\n addItem: async () => {},\n clearCart: async () => {},\n clearSession: () => {},\n config: {\n addressesSlug: 'addresses',\n api: {\n apiRoute: '/api',\n },\n cartsSlug: 'carts',\n customersSlug: 'users',\n },\n confirmOrder: async () => {},\n createAddress: async () => {},\n currenciesConfig: {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n currency: {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n decrementItem: async () => {},\n incrementItem: async () => {},\n initiatePayment: async () => {},\n isLoading: false,\n mergeCart: async () => {},\n onLogin: async () => {},\n onLogout: () => {},\n paymentMethods: [],\n refreshCart: async () => {},\n removeItem: async () => {},\n setCurrency: () => {},\n updateAddress: async () => {},\n user: null,\n}\n\nconst EcommerceContext = createContext<EcommerceContextType>(defaultContext)\n\nconst defaultLocalStorage = {\n key: 'cart',\n}\n\nexport const EcommerceProvider: React.FC<ContextProps> = ({\n addressesSlug = 'addresses',\n api,\n cartsSlug = 'carts',\n children,\n currenciesConfig = {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n customersSlug = 'users',\n debug = false,\n paymentMethods = [],\n syncLocalStorage = true,\n}) => {\n const localStorageConfig =\n syncLocalStorage && typeof syncLocalStorage === 'object'\n ? {\n ...defaultLocalStorage,\n ...syncLocalStorage,\n }\n : defaultLocalStorage\n\n const { apiRoute = '/api', cartsFetchQuery = {} } = api || {}\n const baseAPIURL = formatAdminURL({\n apiRoute,\n path: '',\n })\n\n const config = useMemo<EcommerceConfig>(\n () => ({\n addressesSlug,\n api: {\n apiRoute,\n },\n cartsSlug,\n customersSlug,\n }),\n [addressesSlug, apiRoute, cartsSlug, customersSlug],\n )\n\n const [isLoading, setIsLoading] = useState(false)\n\n const [user, setUser] = useState<null | TypedUser>(null)\n\n const [addresses, setAddresses] = useState<AddressesCollection[]>()\n\n const hasRendered = useRef(false)\n\n /**\n * The ID of the cart associated with the current session.\n * This is used to identify the cart in the database or local storage.\n * It can be null if no cart has been created yet.\n */\n const [cartID, setCartID] = useState<DefaultDocumentIDType>()\n /**\n * The secret for accessing guest carts without authentication.\n * This is generated when a guest user creates a cart.\n */\n const [cartSecret, setCartSecret] = useState<string | undefined>(undefined)\n const [cart, setCart] = useState<CartsCollection>()\n\n const [selectedCurrency, setSelectedCurrency] = useState<Currency>(\n () =>\n currenciesConfig.supportedCurrencies.find(\n (c) => c.code === currenciesConfig.defaultCurrency,\n )!,\n )\n\n const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<null | string>(null)\n\n const cartQuery = useMemo(() => {\n const priceField = `priceIn${selectedCurrency.code}`\n\n const baseQuery = {\n depth: 0,\n populate: {\n products: {\n [priceField]: true,\n },\n variants: {\n options: true,\n [priceField]: true,\n },\n },\n select: {\n items: true,\n subtotal: true,\n },\n }\n\n return deepMergeSimple(baseQuery, cartsFetchQuery)\n }, [selectedCurrency.code, cartsFetchQuery])\n\n const createCart = useCallback(\n async (initialData: Record<string, unknown>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}?${query}`, {\n body: JSON.stringify({\n ...initialData,\n currency: selectedCurrency.code,\n customer: user?.id,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to create cart: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Cart creation error: ${data.error}`)\n }\n\n // Store the secret for guest cart access\n if (!user && data.doc?.secret) {\n setCartSecret(data.doc.secret)\n }\n\n return data.doc as CartsCollection\n },\n [baseAPIURL, cartQuery, cartsSlug, selectedCurrency.code, user],\n )\n\n const getCart = useCallback(\n async (cartID: DefaultDocumentIDType, options?: { secret?: string }) => {\n const query = qs.stringify({\n ...cartQuery,\n ...(options?.secret ? { secret: options.secret } : {}),\n })\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch cart: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Cart fetch error: ${data.error}`)\n }\n\n return data as CartsCollection\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const refreshCart = useCallback<EcommerceContextType['refreshCart']>(async () => {\n if (!cartID) {\n return\n }\n const updatedCart = await getCart(cartID)\n setCart(updatedCart)\n }, [cartID, getCart])\n\n // Persist cart ID and secret to localStorage\n useEffect(() => {\n if (hasRendered.current) {\n if (syncLocalStorage) {\n if (cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n } else {\n localStorage.removeItem(localStorageConfig.key)\n }\n\n if (cartSecret) {\n localStorage.setItem(`${localStorageConfig.key}_secret`, cartSecret)\n } else {\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n }\n }\n }\n }, [cartID, cartSecret, localStorageConfig.key, syncLocalStorage])\n\n const addItem: EcommerceContextType['addItem'] = useCallback(\n async (item, quantity = 1) => {\n setIsLoading(true)\n try {\n if (cartID) {\n // Use server-side endpoint for adding items\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/add-item`, {\n body: JSON.stringify({\n item,\n quantity,\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to add item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } else {\n // If no cartID exists, create a new cart with the item\n const newCart = await createCart({ items: [{ ...item, quantity }] })\n\n setCartID(newCart.id)\n setCart(newCart)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error adding item to cart:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, createCart, debug, getCart],\n )\n\n const removeItem: EcommerceContextType['removeItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/remove-item`, {\n body: JSON.stringify({\n itemID: targetID,\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to remove item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error removing item from cart:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart],\n )\n\n const incrementItem: EcommerceContextType['incrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/update-item`, {\n body: JSON.stringify({\n itemID: targetID,\n quantity: { $inc: 1 },\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to increment item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error incrementing item quantity:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart],\n )\n\n const decrementItem: EcommerceContextType['decrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/update-item`, {\n body: JSON.stringify({\n itemID: targetID,\n quantity: { $inc: -1 },\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to decrement item: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error decrementing item quantity:', error)\n }\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart],\n )\n\n const clearCart: EcommerceContextType['clearCart'] = useCallback(async () => {\n if (!cartID) {\n return\n }\n\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}/clear`, {\n body: JSON.stringify({\n secret: cartSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to clear cart: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n // Cart not found - reset state\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n return\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(cartID, { secret: cartSecret })\n setCart(refreshedCart)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error clearing cart:', error)\n }\n } finally {\n setIsLoading(false)\n }\n }, [baseAPIURL, cartID, cartSecret, cartsSlug, debug, getCart])\n\n const setCurrency: EcommerceContextType['setCurrency'] = useCallback(\n (currency) => {\n if (selectedCurrency.code === currency) {\n return\n }\n\n const foundCurrency = currenciesConfig.supportedCurrencies.find((c) => c.code === currency)\n if (!foundCurrency) {\n throw new Error(`Currency with code \"${currency}\" not found in config`)\n }\n\n setSelectedCurrency(foundCurrency)\n },\n [currenciesConfig.supportedCurrencies, selectedCurrency.code],\n )\n\n const initiatePayment = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n const paymentMethod = paymentMethods.find((method) => method.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (!cartID) {\n throw new Error(`No cart is provided.`)\n }\n\n setSelectedPaymentMethod(paymentMethodID)\n\n if (paymentMethod.initiatePayment) {\n try {\n const response = await fetch(`${baseAPIURL}/payments/${paymentMethodID}/initiate`, {\n body: JSON.stringify({\n cartID,\n currency: selectedCurrency.code,\n secret: cartSecret,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error initiating payment:', error)\n }\n throw new Error(error instanceof Error ? error.message : 'Failed to initiate payment')\n }\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support payment initiation`)\n }\n },\n [baseAPIURL, cartID, cartSecret, debug, paymentMethods, selectedCurrency.code],\n )\n\n const confirmOrder = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n if (!cartID) {\n throw new Error(`Cart is empty.`)\n }\n\n const paymentMethod = paymentMethods.find((pm) => pm.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (paymentMethod.confirmOrder) {\n const response = await fetch(`${baseAPIURL}/payments/${paymentMethodID}/confirm-order`, {\n body: JSON.stringify({\n cartID,\n currency: selectedCurrency.code,\n secret: cartSecret,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support order confirmation`)\n }\n },\n [baseAPIURL, cartID, cartSecret, paymentMethods, selectedCurrency.code],\n )\n\n const getUser = useCallback(async () => {\n try {\n const query = qs.stringify({\n depth: 0,\n select: {\n id: true,\n cart: true,\n },\n })\n\n const response = await fetch(`${baseAPIURL}/${customersSlug}/me?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch user: ${errorText}`)\n }\n\n const userData = await response.json()\n\n if (userData.error) {\n throw new Error(`User fetch error: ${userData.error}`)\n }\n\n if (userData.user) {\n setUser(userData.user as TypedUser)\n return userData.user as TypedUser\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user:', error)\n }\n setUser(null)\n throw new Error(\n `Failed to fetch user: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [baseAPIURL, customersSlug, debug])\n\n const getAddresses = useCallback(async () => {\n if (!user) {\n return\n }\n\n try {\n const query = qs.stringify({\n depth: 0,\n limit: 0,\n pagination: false,\n })\n\n const response = await fetch(`${baseAPIURL}/${addressesSlug}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n throw new Error(errorText)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address fetch error: ${data.error}`)\n }\n\n if (data.docs && data.docs.length > 0) {\n setAddresses(data.docs)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching addresses:', error)\n }\n setAddresses(undefined)\n throw new Error(\n `Failed to fetch addresses: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [user, baseAPIURL, addressesSlug, debug])\n\n const updateAddress = useCallback<EcommerceContextType['updateAddress']>(\n async (addressID, address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}/${addressID}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n const createAddress = useCallback<EcommerceContextType['createAddress']>(\n async (address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n /**\n * Clears all ecommerce session data from state and localStorage.\n * Used during logout to ensure no user data persists.\n */\n const clearSession = useCallback(() => {\n setCart(undefined)\n setCartID(undefined)\n setCartSecret(undefined)\n setAddresses(undefined)\n setUser(null)\n\n if (syncLocalStorage) {\n localStorage.removeItem(localStorageConfig.key)\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n }\n }, [localStorageConfig.key, syncLocalStorage])\n\n /**\n * Called during logout. Clears all session data.\n */\n const onLogout = useCallback(() => {\n clearSession()\n }, [clearSession])\n\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n const mergeCart = useCallback<EcommerceContextType['mergeCart']>(\n async (targetCartID, sourceCartID, sourceSecret) => {\n setIsLoading(true)\n try {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${targetCartID}/merge`, {\n body: JSON.stringify({\n sourceCartID,\n sourceSecret,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to merge carts: ${errorText}`)\n }\n\n const result = await response.json()\n\n if (!result.success) {\n throw new Error(result.message || 'Failed to merge carts')\n }\n\n // Refresh cart with proper depth/populate settings for UI\n const refreshedCart = await getCart(targetCartID)\n setCart(refreshedCart)\n setCartID(targetCartID)\n\n return refreshedCart\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error merging carts:', error)\n }\n throw error\n } finally {\n setIsLoading(false)\n }\n },\n [baseAPIURL, cartsSlug, debug, getCart],\n )\n\n /**\n * Called after login to properly set up cart state.\n * Handles merging guest cart with user's existing cart if applicable.\n */\n const onLogin = useCallback(async () => {\n // Store reference to any existing guest cart before fetching user\n const guestCartID = cartID\n const guestSecret = cartSecret\n\n // Fetch fresh user data\n const fetchedUser = await getUser()\n\n if (!fetchedUser) {\n // No user means login failed, keep current state\n return\n }\n\n // Clear the guest cart secret - authenticated users don't need it\n setCartSecret(undefined)\n if (syncLocalStorage) {\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n }\n\n // Check if user has an existing cart\n const userCartID =\n fetchedUser.cart?.docs && fetchedUser.cart.docs.length > 0\n ? typeof fetchedUser.cart.docs[0] === 'object'\n ? fetchedUser.cart.docs[0].id\n : fetchedUser.cart.docs[0]\n : undefined\n\n if (guestCartID && guestSecret) {\n // Guest had a cart - need to handle merge/transfer\n if (userCartID) {\n // User has existing cart - merge guest cart into user's cart\n try {\n await mergeCart(userCartID, guestCartID, guestSecret)\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error merging carts:', error)\n }\n // Fall back to user's cart\n const userCart = await getCart(userCartID)\n setCart(userCart)\n setCartID(userCartID)\n }\n } else {\n // User has no existing cart - transfer guest cart to user\n try {\n const response = await fetch(\n `${baseAPIURL}/${cartsSlug}/${guestCartID}?secret=${guestSecret}`,\n {\n body: JSON.stringify({\n customer: fetchedUser.id,\n secret: null, // Clear the secret since it's now owned by user\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n },\n )\n\n if (response.ok) {\n // Fetch updated cart\n const updatedCart = await getCart(guestCartID)\n setCart(updatedCart)\n setCartID(guestCartID)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error transferring cart to user:', error)\n }\n }\n }\n } else if (userCartID) {\n // No guest cart, but user has a cart - fetch it\n const userCart = await getCart(userCartID)\n setCart(userCart)\n setCartID(userCartID)\n }\n\n // Update localStorage with user's cart ID (no secret needed)\n if (syncLocalStorage && cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n }\n }, [\n baseAPIURL,\n cartID,\n cartSecret,\n cartsSlug,\n debug,\n getCart,\n getUser,\n localStorageConfig.key,\n mergeCart,\n syncLocalStorage,\n ])\n\n // If localStorage is enabled, restore cart from storage\n useEffect(() => {\n if (!hasRendered.current) {\n if (syncLocalStorage) {\n const storedCartID = localStorage.getItem(localStorageConfig.key)\n const storedSecret = localStorage.getItem(`${localStorageConfig.key}_secret`)\n\n if (storedCartID) {\n getCart(storedCartID, { secret: storedSecret || undefined })\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(storedCartID as DefaultDocumentIDType)\n if (storedSecret) {\n setCartSecret(storedSecret)\n }\n })\n .catch((_) => {\n // console.error('Error fetching cart from localStorage:', error)\n // If there's an error fetching the cart, clear it from localStorage\n localStorage.removeItem(localStorageConfig.key)\n localStorage.removeItem(`${localStorageConfig.key}_secret`)\n setCartID(undefined)\n setCart(undefined)\n setCartSecret(undefined)\n })\n }\n }\n\n hasRendered.current = true\n\n void getUser().then((user) => {\n if (user && user.cart?.docs && user.cart.docs.length > 0) {\n // If the user has carts, we can set the cartID to the first cart\n const cartID =\n typeof user.cart.docs[0] === 'object' ? user.cart.docs[0].id : user.cart.docs[0]\n\n if (cartID) {\n getCart(cartID)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(cartID)\n })\n .catch((error) => {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user cart:', error)\n }\n\n setCart(undefined)\n setCartID(undefined)\n\n throw new Error(`Failed to fetch user cart: ${error.message}`)\n })\n }\n }\n })\n }\n }, [debug, getAddresses, getCart, getUser, localStorageConfig.key, syncLocalStorage])\n\n useEffect(() => {\n if (user) {\n // If the user is logged in, fetch their addresses\n void getAddresses()\n } else {\n // If no user is logged in, clear addresses\n setAddresses(undefined)\n }\n }, [getAddresses, user])\n\n return (\n <EcommerceContext\n value={{\n addItem,\n addresses,\n cart,\n clearCart,\n clearSession,\n config,\n confirmOrder,\n createAddress,\n currenciesConfig,\n currency: selectedCurrency,\n decrementItem,\n incrementItem,\n initiatePayment,\n isLoading,\n mergeCart,\n onLogin,\n onLogout,\n paymentMethods,\n refreshCart,\n removeItem,\n selectedPaymentMethod,\n setCurrency,\n updateAddress,\n user,\n }}\n >\n {children}\n </EcommerceContext>\n )\n}\n\nexport const useEcommerce = () => {\n const context = use(EcommerceContext)\n\n if (!context) {\n throw new Error('useEcommerce must be used within an EcommerceProvider')\n }\n\n return context\n}\n\nexport const useEcommerceConfig = () => {\n const { config } = useEcommerce()\n\n return config\n}\n\nexport const useCurrency = () => {\n const { currenciesConfig, currency, setCurrency } = useEcommerce()\n\n const formatCurrency = useCallback(\n (value?: null | number, options?: { currency?: Currency; locale?: string }): string => {\n if (value === undefined || value === null) {\n return ''\n }\n\n const currencyToUse = options?.currency || currency\n if (!currencyToUse) {\n return value.toString()\n }\n\n const { code, decimals, symbolDisplay } = currencyToUse\n\n const locale = options?.locale || 'en'\n\n return new Intl.NumberFormat(locale, {\n currency: code,\n currencyDisplay: symbolDisplay || 'symbol',\n maximumFractionDigits: decimals,\n minimumFractionDigits: decimals,\n style: 'currency',\n }).format(value / Math.pow(10, decimals))\n },\n [currency],\n )\n\n if (!currency) {\n throw new Error('useCurrency must be used within an EcommerceProvider')\n }\n\n return {\n currency,\n formatCurrency,\n setCurrency,\n supportedCurrencies: currenciesConfig.supportedCurrencies,\n }\n}\n\nexport function useCart<T extends CartsCollection>() {\n const {\n addItem,\n cart,\n clearCart,\n decrementItem,\n incrementItem,\n isLoading,\n refreshCart,\n removeItem,\n } = useEcommerce()\n\n if (!addItem) {\n throw new Error('useCart must be used within an EcommerceProvider')\n }\n\n return {\n addItem,\n cart: cart as T,\n clearCart,\n decrementItem,\n incrementItem,\n isLoading,\n refreshCart,\n removeItem,\n }\n}\n\nexport const usePayments = () => {\n const { confirmOrder, initiatePayment, isLoading, paymentMethods, selectedPaymentMethod } =\n useEcommerce()\n\n if (!initiatePayment) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { confirmOrder, initiatePayment, isLoading, paymentMethods, selectedPaymentMethod }\n}\n\nexport function useAddresses<T extends AddressesCollection>() {\n const { addresses, createAddress, isLoading, updateAddress } = useEcommerce()\n\n if (!createAddress) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { addresses: addresses as T[], createAddress, isLoading, updateAddress }\n}\n"],"names":["deepMergeSimple","formatAdminURL","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","defaultContext","addItem","clearCart","clearSession","config","addressesSlug","api","apiRoute","cartsSlug","customersSlug","confirmOrder","createAddress","currenciesConfig","defaultCurrency","supportedCurrencies","code","decimals","label","symbol","currency","decrementItem","incrementItem","initiatePayment","isLoading","mergeCart","onLogin","onLogout","paymentMethods","refreshCart","removeItem","setCurrency","updateAddress","user","EcommerceContext","defaultLocalStorage","key","EcommerceProvider","children","debug","syncLocalStorage","localStorageConfig","cartsFetchQuery","baseAPIURL","path","setIsLoading","setUser","addresses","setAddresses","hasRendered","cartID","setCartID","cartSecret","setCartSecret","undefined","cart","setCart","selectedCurrency","setSelectedCurrency","find","c","selectedPaymentMethod","setSelectedPaymentMethod","cartQuery","priceField","baseQuery","depth","populate","products","variants","options","select","items","subtotal","createCart","initialData","query","stringify","response","fetch","body","JSON","customer","id","credentials","headers","method","ok","errorText","text","Error","data","json","error","doc","secret","getCart","updatedCart","current","localStorage","setItem","item","quantity","result","success","refreshedCart","newCart","console","targetID","itemID","$inc","foundCurrency","paymentMethodID","paymentMethod","name","additionalData","responseError","responseData","message","pm","getUser","userData","getAddresses","limit","pagination","docs","length","addressID","address","targetCartID","sourceCartID","sourceSecret","guestCartID","guestSecret","fetchedUser","userCartID","userCart","storedCartID","getItem","storedSecret","then","fetchedCart","catch","_","value","useEcommerce","context","useEcommerceConfig","useCurrency","formatCurrency","currencyToUse","toString","symbolDisplay","locale","Intl","NumberFormat","currencyDisplay","maximumFractionDigits","minimumFractionDigits","style","format","Math","pow","useCart","usePayments","useAddresses"],"mappings":"AAAA;;AAGA,SAASA,eAAe,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAWpG,MAAMC,iBAAuC;IAC3CC,SAAS,WAAa;IACtBC,WAAW,WAAa;IACxBC,cAAc,KAAO;IACrBC,QAAQ;QACNC,eAAe;QACfC,KAAK;YACHC,UAAU;QACZ;QACAC,WAAW;QACXC,eAAe;IACjB;IACAC,cAAc,WAAa;IAC3BC,eAAe,WAAa;IAC5BC,kBAAkB;QAChBC,iBAAiB;QACjBC,qBAAqB;YACnB;gBACEC,MAAM;gBACNC,UAAU;gBACVC,OAAO;gBACPC,QAAQ;YACV;SACD;IACH;IACAC,UAAU;QACRJ,MAAM;QACNC,UAAU;QACVC,OAAO;QACPC,QAAQ;IACV;IACAE,eAAe,WAAa;IAC5BC,eAAe,WAAa;IAC5BC,iBAAiB,WAAa;IAC9BC,WAAW;IACXC,WAAW,WAAa;IACxBC,SAAS,W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SAASnF,SAASmF,UAAU;QAElC,OAAO,IAAIC,KAAKC,YAAY,CAACF,QAAQ;YACnCrI,UAAUJ;YACV4I,iBAAiBJ,iBAAiB;YAClCK,uBAAuB5I;YACvB6I,uBAAuB7I;YACvB8I,OAAO;QACT,GAAGC,MAAM,CAAChB,QAAQiB,KAAKC,GAAG,CAAC,IAAIjJ;IACjC,GACA;QAACG;KAAS;IAGZ,IAAI,CAACA,UAAU;QACb,MAAM,IAAIsE,MAAM;IAClB;IAEA,OAAO;QACLtE;QACAiI;QACAtH;QACAhB,qBAAqBF,iBAAiBE,mBAAmB;IAC3D;AACF,EAAC;AAED,OAAO,SAASoJ;IACd,MAAM,EACJjK,OAAO,EACPqD,IAAI,EACJpD,SAAS,EACTkB,aAAa,EACbC,aAAa,EACbE,SAAS,EACTK,WAAW,EACXC,UAAU,EACX,GAAGmH;IAEJ,IAAI,CAAC/I,SAAS;QACZ,MAAM,IAAIwF,MAAM;IAClB;IAEA,OAAO;QACLxF;QACAqD,MAAMA;QACNpD;QACAkB;QACAC;QACAE;QACAK;QACAC;IACF;AACF;AAEA,OAAO,MAAMsI,cAAc;IACzB,MAAM,EAAEzJ,YAAY,EAAEY,eAAe,EAAEC,SAAS,EAAEI,cAAc,EAAEiC,qBAAqB,EAAE,GACvFoF;IAEF,IAAI,CAAC1H,iBAAiB;QACpB,MAAM,IAAImE,MAAM;IAClB;IAEA,OAAO;QAAE/E;QAAcY;QAAiBC;QAAWI;QAAgBiC;IAAsB;AAC3F,EAAC;AAED,OAAO,SAASwG;IACd,MAAM,EAAEtH,SAAS,EAAEnC,aAAa,EAAEY,SAAS,EAAEQ,aAAa,EAAE,GAAGiH;IAE/D,IAAI,CAACrI,eAAe;QAClB,MAAM,IAAI8E,MAAM;IAClB;IAEA,OAAO;QAAE3C,WAAWA;QAAkBnC;QAAeY;QAAWQ;IAAc;AAChF"}
@@ -204,7 +204,7 @@ export type PaymentAdapterClient = {
204
204
  export type Currency = {
205
205
  /**
206
206
  * The ISO 4217 currency code
207
- * @example 'usd'
207
+ * @example 'USD'
208
208
  */
209
209
  code: string;
210
210
  /**
@@ -223,6 +223,11 @@ export type Currency = {
223
223
  * @example '$'
224
224
  */
225
225
  symbol: string;
226
+ /**
227
+ * The display format for the currency symbol in formatted output.
228
+ * @example 'symbol'
229
+ */
230
+ symbolDisplay?: 'code' | 'symbol';
226
231
  };
227
232
  /**
228
233
  * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,eAAe,EACf,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,KAAK,EAAE,CAAA;AAE1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE;IACtC,iBAAiB,EAAE,gBAAgB,CAAA;CACpC,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;IAC5D,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;CAC9D,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE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AAA;IACrB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAA;IAClB;;;;;;;;OAQG;IACH,SAAS,EAAE,CACT,YAAY,EAAE,qBAAqB,EACnC,YAAY,EAAE,qBAAqB,EACnC,YAAY,CAAC,EAAE,MAAM,KAClB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/B;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,cAAc,EAAE,oBAAoB,EAAE,CAAA;IACtC;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC;;;OAGG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACrC;;;OAGG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC;;OAEG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACjG;;OAEG;IACH,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAo5BA,WAwIC"}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'USD'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n /**\n * The display format for the currency symbol in formatted output.\n * @example 'symbol'\n */\n symbolDisplay?: 'code' | 'symbol'\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAy5BA,WAwIC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceCell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAItE,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;CAC9C,GAAG,yBAAyB,CAAA;AAE7B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+BrC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceCell/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAItE,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;CAC9C,GAAG,yBAAyB,CAAA;AAE7B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0BrC,CAAA"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useTranslation } from '@payloadcms/ui';
4
- import { convertFromBaseValue } from '../utilities.js';
4
+ import { formatPrice } from '../utilities.js';
5
5
  export const PriceCell = (args)=>{
6
- const { t } = useTranslation();
6
+ const { i18n, t } = useTranslation();
7
7
  const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args;
8
8
  const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0];
9
9
  if (!currency) {
@@ -24,14 +24,12 @@ export const PriceCell = (args)=>{
24
24
  children: t('plugin-ecommerce:priceNotSet')
25
25
  });
26
26
  }
27
- return /*#__PURE__*/ _jsxs("span", {
28
- children: [
29
- currency.symbol,
30
- convertFromBaseValue({
31
- baseValue: cellData,
32
- currency
33
- })
34
- ]
27
+ return /*#__PURE__*/ _jsx("span", {
28
+ children: formatPrice({
29
+ baseValue: cellData,
30
+ currency,
31
+ locale: i18n.language
32
+ })
35
33
  });
36
34
  };
37
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/PriceCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps, TypedCollection } from 'payload'\n\nimport { useTranslation } from '@payloadcms/ui'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { convertFromBaseValue } from '../utilities.js'\n\ntype Props = {\n cellData?: number\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n rowData: Partial<TypedCollection['products']>\n} & DefaultCellComponentProps\n\nexport const PriceCell: React.FC<Props> = (args) => {\n const { t } = useTranslation()\n const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args\n\n const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0]\n\n if (!currency) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:currencyNotSet')}</span>\n }\n\n if (\n (cellData == null || typeof cellData !== 'number') &&\n 'enableVariants' in rowData &&\n rowData.enableVariants\n ) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceSetInVariants')}</span>\n }\n\n if (cellData == null) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceNotSet')}</span>\n }\n\n return (\n <span>\n {currency.symbol}\n {convertFromBaseValue({ baseValue: cellData, currency })}\n </span>\n )\n}\n"],"names":["useTranslation","convertFromBaseValue","PriceCell","args","t","cellData","currenciesConfig","currency","currencyFromProps","rowData","supportedCurrencies","span","enableVariants","symbol","baseValue"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,oBAAoB,QAAQ,kBAAiB;AAUtD,OAAO,MAAMC,YAA6B,CAACC;IACzC,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAM,EAAEK,QAAQ,EAAEC,gBAAgB,EAAEC,UAAUC,iBAAiB,EAAEC,OAAO,EAAE,GAAGN;IAE7E,MAAMI,WAAWC,qBAAqBF,iBAAiBI,mBAAmB,CAAC,EAAE;IAE7E,IAAI,CAACH,UAAU;QACb,2DAA2D;QAC3D,qBAAO,KAACI;sBAAMP,EAAE;;IAClB;IAEA,IACE,AAACC,CAAAA,YAAY,QAAQ,OAAOA,aAAa,QAAO,KAChD,oBAAoBI,WACpBA,QAAQG,cAAc,EACtB;QACA,2DAA2D;QAC3D,qBAAO,KAACD;sBAAMP,EAAE;;IAClB;IAEA,IAAIC,YAAY,MAAM;QACpB,2DAA2D;QAC3D,qBAAO,KAACM;sBAAMP,EAAE;;IAClB;IAEA,qBACE,MAACO;;YACEJ,SAASM,MAAM;YACfZ,qBAAqB;gBAAEa,WAAWT;gBAAUE;YAAS;;;AAG5D,EAAC"}
1
+ {"version":3,"sources":["../../../src/ui/PriceCell/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DefaultCellComponentProps, TypedCollection } from 'payload'\n\nimport { useTranslation } from '@payloadcms/ui'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { formatPrice } from '../utilities.js'\n\ntype Props = {\n cellData?: number\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n rowData: Partial<TypedCollection['products']>\n} & DefaultCellComponentProps\n\nexport const PriceCell: React.FC<Props> = (args) => {\n const { i18n, t } = useTranslation()\n const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args\n\n const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0]\n\n if (!currency) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:currencyNotSet')}</span>\n }\n\n if (\n (cellData == null || typeof cellData !== 'number') &&\n 'enableVariants' in rowData &&\n rowData.enableVariants\n ) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceSetInVariants')}</span>\n }\n\n if (cellData == null) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceNotSet')}</span>\n }\n\n return <span>{formatPrice({ baseValue: cellData, currency, locale: i18n.language })}</span>\n}\n"],"names":["useTranslation","formatPrice","PriceCell","args","i18n","t","cellData","currenciesConfig","currency","currencyFromProps","rowData","supportedCurrencies","span","enableVariants","baseValue","locale","language"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,WAAW,QAAQ,kBAAiB;AAU7C,OAAO,MAAMC,YAA6B,CAACC;IACzC,MAAM,EAAEC,IAAI,EAAEC,CAAC,EAAE,GAAGL;IACpB,MAAM,EAAEM,QAAQ,EAAEC,gBAAgB,EAAEC,UAAUC,iBAAiB,EAAEC,OAAO,EAAE,GAAGP;IAE7E,MAAMK,WAAWC,qBAAqBF,iBAAiBI,mBAAmB,CAAC,EAAE;IAE7E,IAAI,CAACH,UAAU;QACb,2DAA2D;QAC3D,qBAAO,KAACI;sBAAMP,EAAE;;IAClB;IAEA,IACE,AAACC,CAAAA,YAAY,QAAQ,OAAOA,aAAa,QAAO,KAChD,oBAAoBI,WACpBA,QAAQG,cAAc,EACtB;QACA,2DAA2D;QAC3D,qBAAO,KAACD;sBAAMP,EAAE;;IAClB;IAEA,IAAIC,YAAY,MAAM;QACpB,2DAA2D;QAC3D,qBAAO,KAACM;sBAAMP,EAAE;;IAClB;IAEA,qBAAO,KAACO;kBAAMX,YAAY;YAAEa,WAAWR;YAAUE;YAAUO,QAAQX,KAAKY,QAAQ;QAAC;;AACnF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceRowLabel/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,aAAa,CAAA;AAGpB,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAyCzC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceRowLabel/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,aAAa,CAAA;AAGpB,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuCzC,CAAA"}
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRowLabel } from '@payloadcms/ui';
3
+ import { useRowLabel, useTranslation } from '@payloadcms/ui';
4
4
  import { useMemo } from 'react';
5
5
  import './index.css';
6
- import { convertFromBaseValue } from '../utilities.js';
6
+ import { formatPrice } from '../utilities.js';
7
7
  export const PriceRowLabel = (props)=>{
8
8
  const { currenciesConfig } = props;
9
9
  const { defaultCurrency, supportedCurrencies } = currenciesConfig;
10
+ const { i18n } = useTranslation();
10
11
  const { data } = useRowLabel();
11
12
  const currency = useMemo(()=>{
12
13
  if (data.currency) {
@@ -22,17 +23,19 @@ export const PriceRowLabel = (props)=>{
22
23
  supportedCurrencies,
23
24
  defaultCurrency
24
25
  ]);
25
- const amount = useMemo(()=>{
26
- if (data.amount) {
27
- return convertFromBaseValue({
28
- baseValue: data.amount,
29
- currency: currency
30
- });
26
+ const formattedPrice = useMemo(()=>{
27
+ if (!currency) {
28
+ return '0';
31
29
  }
32
- return '0';
30
+ return formatPrice({
31
+ baseValue: data.amount ?? 0,
32
+ currency,
33
+ locale: i18n.language
34
+ });
33
35
  }, [
34
36
  currency,
35
- data.amount
37
+ data.amount,
38
+ i18n.language
36
39
  ]);
37
40
  return /*#__PURE__*/ _jsxs("div", {
38
41
  className: "priceRowLabel",
@@ -44,11 +47,8 @@ export const PriceRowLabel = (props)=>{
44
47
  /*#__PURE__*/ _jsxs("div", {
45
48
  className: "priceValue",
46
49
  children: [
47
- /*#__PURE__*/ _jsxs("span", {
48
- children: [
49
- currency?.symbol,
50
- amount
51
- ]
50
+ /*#__PURE__*/ _jsx("span", {
51
+ children: formattedPrice
52
52
  }),
53
53
  /*#__PURE__*/ _jsxs("span", {
54
54
  children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/PriceRowLabel/index.tsx"],"sourcesContent":["'use client'\n\nimport { useRowLabel } from '@payloadcms/ui'\nimport { useMemo } from 'react'\n\nimport type { CurrenciesConfig } from '../../types/index.js'\n\nimport './index.css'\nimport { convertFromBaseValue } from '../utilities.js'\n\ntype Props = {\n currenciesConfig: CurrenciesConfig\n}\n\nexport const PriceRowLabel: React.FC<Props> = (props) => {\n const { currenciesConfig } = props\n const { defaultCurrency, supportedCurrencies } = currenciesConfig\n\n const { data } = useRowLabel<{ amount: number; currency: string }>()\n\n const currency = useMemo(() => {\n if (data.currency) {\n return supportedCurrencies.find((c) => c.code === data.currency) ?? supportedCurrencies[0]\n }\n\n const fallbackCurrency = supportedCurrencies.find((c) => c.code === defaultCurrency)\n\n if (fallbackCurrency) {\n return fallbackCurrency\n }\n\n return supportedCurrencies[0]\n }, [data.currency, supportedCurrencies, defaultCurrency])\n\n const amount = useMemo(() => {\n if (data.amount) {\n return convertFromBaseValue({ baseValue: data.amount, currency: currency! })\n }\n\n return '0'\n }, [currency, data.amount])\n\n return (\n <div className=\"priceRowLabel\">\n <div className=\"priceLabel\">Price:</div>\n\n <div className=\"priceValue\">\n <span>\n {currency?.symbol}\n {amount}\n </span>\n <span>({data.currency})</span>\n </div>\n </div>\n )\n}\n"],"names":["useRowLabel","useMemo","convertFromBaseValue","PriceRowLabel","props","currenciesConfig","defaultCurrency","supportedCurrencies","data","currency","find","c","code","fallbackCurrency","amount","baseValue","div","className","span","symbol"],"mappings":"AAAA;;AAEA,SAASA,WAAW,QAAQ,iBAAgB;AAC5C,SAASC,OAAO,QAAQ,QAAO;AAI/B,OAAO,cAAa;AACpB,SAASC,oBAAoB,QAAQ,kBAAiB;AAMtD,OAAO,MAAMC,gBAAiC,CAACC;IAC7C,MAAM,EAAEC,gBAAgB,EAAE,GAAGD;IAC7B,MAAM,EAAEE,eAAe,EAAEC,mBAAmB,EAAE,GAAGF;IAEjD,MAAM,EAAEG,IAAI,EAAE,GAAGR;IAEjB,MAAMS,WAAWR,QAAQ;QACvB,IAAIO,KAAKC,QAAQ,EAAE;YACjB,OAAOF,oBAAoBG,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,KAAKC,QAAQ,KAAKF,mBAAmB,CAAC,EAAE;QAC5F;QAEA,MAAMM,mBAAmBN,oBAAoBG,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKN;QAEpE,IAAIO,kBAAkB;YACpB,OAAOA;QACT;QAEA,OAAON,mBAAmB,CAAC,EAAE;IAC/B,GAAG;QAACC,KAAKC,QAAQ;QAAEF;QAAqBD;KAAgB;IAExD,MAAMQ,SAASb,QAAQ;QACrB,IAAIO,KAAKM,MAAM,EAAE;YACf,OAAOZ,qBAAqB;gBAAEa,WAAWP,KAAKM,MAAM;gBAAEL,UAAUA;YAAU;QAC5E;QAEA,OAAO;IACT,GAAG;QAACA;QAAUD,KAAKM,MAAM;KAAC;IAE1B,qBACE,MAACE;QAAIC,WAAU;;0BACb,KAACD;gBAAIC,WAAU;0BAAa;;0BAE5B,MAACD;gBAAIC,WAAU;;kCACb,MAACC;;4BACET,UAAUU;4BACVL;;;kCAEH,MAACI;;4BAAK;4BAAEV,KAAKC,QAAQ;4BAAC;;;;;;;AAI9B,EAAC"}
1
+ {"version":3,"sources":["../../../src/ui/PriceRowLabel/index.tsx"],"sourcesContent":["'use client'\n\nimport { useRowLabel, useTranslation } from '@payloadcms/ui'\nimport { useMemo } from 'react'\n\nimport type { CurrenciesConfig } from '../../types/index.js'\n\nimport './index.css'\nimport { formatPrice } from '../utilities.js'\n\ntype Props = {\n currenciesConfig: CurrenciesConfig\n}\n\nexport const PriceRowLabel: React.FC<Props> = (props) => {\n const { currenciesConfig } = props\n const { defaultCurrency, supportedCurrencies } = currenciesConfig\n\n const { i18n } = useTranslation()\n const { data } = useRowLabel<{ amount: number; currency: string }>()\n\n const currency = useMemo(() => {\n if (data.currency) {\n return supportedCurrencies.find((c) => c.code === data.currency) ?? supportedCurrencies[0]\n }\n\n const fallbackCurrency = supportedCurrencies.find((c) => c.code === defaultCurrency)\n\n if (fallbackCurrency) {\n return fallbackCurrency\n }\n\n return supportedCurrencies[0]\n }, [data.currency, supportedCurrencies, defaultCurrency])\n\n const formattedPrice = useMemo(() => {\n if (!currency) {\n return '0'\n }\n\n return formatPrice({ baseValue: data.amount ?? 0, currency, locale: i18n.language })\n }, [currency, data.amount, i18n.language])\n\n return (\n <div className=\"priceRowLabel\">\n <div className=\"priceLabel\">Price:</div>\n\n <div className=\"priceValue\">\n <span>{formattedPrice}</span>\n <span>({data.currency})</span>\n </div>\n </div>\n )\n}\n"],"names":["useRowLabel","useTranslation","useMemo","formatPrice","PriceRowLabel","props","currenciesConfig","defaultCurrency","supportedCurrencies","i18n","data","currency","find","c","code","fallbackCurrency","formattedPrice","baseValue","amount","locale","language","div","className","span"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,cAAc,QAAQ,iBAAgB;AAC5D,SAASC,OAAO,QAAQ,QAAO;AAI/B,OAAO,cAAa;AACpB,SAASC,WAAW,QAAQ,kBAAiB;AAM7C,OAAO,MAAMC,gBAAiC,CAACC;IAC7C,MAAM,EAAEC,gBAAgB,EAAE,GAAGD;IAC7B,MAAM,EAAEE,eAAe,EAAEC,mBAAmB,EAAE,GAAGF;IAEjD,MAAM,EAAEG,IAAI,EAAE,GAAGR;IACjB,MAAM,EAAES,IAAI,EAAE,GAAGV;IAEjB,MAAMW,WAAWT,QAAQ;QACvB,IAAIQ,KAAKC,QAAQ,EAAE;YACjB,OAAOH,oBAAoBI,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,KAAKC,QAAQ,KAAKH,mBAAmB,CAAC,EAAE;QAC5F;QAEA,MAAMO,mBAAmBP,oBAAoBI,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKP;QAEpE,IAAIQ,kBAAkB;YACpB,OAAOA;QACT;QAEA,OAAOP,mBAAmB,CAAC,EAAE;IAC/B,GAAG;QAACE,KAAKC,QAAQ;QAAEH;QAAqBD;KAAgB;IAExD,MAAMS,iBAAiBd,QAAQ;QAC7B,IAAI,CAACS,UAAU;YACb,OAAO;QACT;QAEA,OAAOR,YAAY;YAAEc,WAAWP,KAAKQ,MAAM,IAAI;YAAGP;YAAUQ,QAAQV,KAAKW,QAAQ;QAAC;IACpF,GAAG;QAACT;QAAUD,KAAKQ,MAAM;QAAET,KAAKW,QAAQ;KAAC;IAEzC,qBACE,MAACC;QAAIC,WAAU;;0BACb,KAACD;gBAAIC,WAAU;0BAAa;;0BAE5B,MAACD;gBAAIC,WAAU;;kCACb,KAACC;kCAAMP;;kCACP,MAACO;;4BAAK;4BAAEb,KAAKC,QAAQ;4BAAC;;;;;;;AAI9B,EAAC"}
@@ -13,4 +13,15 @@ export declare const convertFromBaseValue: ({ baseValue, currency, }: {
13
13
  baseValue: number;
14
14
  currency: Currency;
15
15
  }) => string;
16
+ /**
17
+ * Format a base value as a locale-aware currency string using the Intl API.
18
+ *
19
+ * @example formatPrice({ baseValue: 2500, currency: USD }) // "$25.00"
20
+ * @example formatPrice({ baseValue: 2500, currency: EUR, locale: 'de' }) // "25,00 €"
21
+ */
22
+ export declare const formatPrice: ({ baseValue, currency, locale, }: {
23
+ baseValue: number;
24
+ currency: Currency;
25
+ locale?: string;
26
+ }) => string;
16
27
  //# sourceMappingURL=utilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/ui/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB,gCAG5B;IACD,QAAQ,EAAE,QAAQ,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,KAAG,MAaH,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,6BAG9B;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;CACnB,KAAG,MAUH,CAAA"}
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/ui/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB,gCAG5B;IACD,QAAQ,EAAE,QAAQ,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,KAAG,MAaH,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,6BAG9B;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;CACnB,KAAG,MAUH,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,qCAIrB;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KAAG,MAQH,CAAA"}
@@ -22,5 +22,19 @@
22
22
  // Format with the correct number of decimal places
23
23
  return decimalValue.toFixed(currency.decimals);
24
24
  };
25
+ /**
26
+ * Format a base value as a locale-aware currency string using the Intl API.
27
+ *
28
+ * @example formatPrice({ baseValue: 2500, currency: USD }) // "$25.00"
29
+ * @example formatPrice({ baseValue: 2500, currency: EUR, locale: 'de' }) // "25,00 €"
30
+ */ export const formatPrice = ({ baseValue, currency, locale = 'en' })=>{
31
+ return new Intl.NumberFormat(locale, {
32
+ currency: currency.code,
33
+ currencyDisplay: currency.symbolDisplay ?? 'symbol',
34
+ maximumFractionDigits: currency.decimals,
35
+ minimumFractionDigits: currency.decimals,
36
+ style: 'currency'
37
+ }).format(baseValue / Math.pow(10, currency.decimals));
38
+ };
25
39
 
26
40
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/utilities.ts"],"sourcesContent":["import type { Currency } from '../types/index.js'\n\n/**\n * Convert display value with decimal point to base value (e.g., $25.00 to 2500)\n */\nexport const convertToBaseValue = ({\n currency,\n displayValue,\n}: {\n currency: Currency\n displayValue: string\n}): number => {\n if (!currency) {\n return parseFloat(displayValue)\n }\n\n // Remove currency symbol and any non-numeric characters except decimal\n const cleanValue = displayValue.replace(currency.symbol, '').replace(/[^0-9.]/g, '')\n\n // Parse the clean value to a float\n const floatValue = parseFloat(cleanValue || '0')\n\n // Convert to the base value (e.g., cents for USD)\n return Math.round(floatValue * Math.pow(10, currency.decimals))\n}\n\n/**\n * Convert base value to display value with decimal point (e.g., 2500 to $25.00)\n */\nexport const convertFromBaseValue = ({\n baseValue,\n currency,\n}: {\n baseValue: number\n currency: Currency\n}): string => {\n if (!currency) {\n return baseValue.toString()\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = baseValue / Math.pow(10, currency.decimals)\n\n // Format with the correct number of decimal places\n return decimalValue.toFixed(currency.decimals)\n}\n"],"names":["convertToBaseValue","currency","displayValue","parseFloat","cleanValue","replace","symbol","floatValue","Math","round","pow","decimals","convertFromBaseValue","baseValue","toString","decimalValue","toFixed"],"mappings":"AAEA;;CAEC,GACD,OAAO,MAAMA,qBAAqB,CAAC,EACjCC,QAAQ,EACRC,YAAY,EAIb;IACC,IAAI,CAACD,UAAU;QACb,OAAOE,WAAWD;IACpB;IAEA,uEAAuE;IACvE,MAAME,aAAaF,aAAaG,OAAO,CAACJ,SAASK,MAAM,EAAE,IAAID,OAAO,CAAC,YAAY;IAEjF,mCAAmC;IACnC,MAAME,aAAaJ,WAAWC,cAAc;IAE5C,kDAAkD;IAClD,OAAOI,KAAKC,KAAK,CAACF,aAAaC,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;AAC/D,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,SAAS,EACTZ,QAAQ,EAIT;IACC,IAAI,CAACA,UAAU;QACb,OAAOY,UAAUC,QAAQ;IAC3B;IAEA,yEAAyE;IACzE,MAAMC,eAAeF,YAAYL,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;IAE/D,mDAAmD;IACnD,OAAOI,aAAaC,OAAO,CAACf,SAASU,QAAQ;AAC/C,EAAC"}
1
+ {"version":3,"sources":["../../src/ui/utilities.ts"],"sourcesContent":["import type { Currency } from '../types/index.js'\n\n/**\n * Convert display value with decimal point to base value (e.g., $25.00 to 2500)\n */\nexport const convertToBaseValue = ({\n currency,\n displayValue,\n}: {\n currency: Currency\n displayValue: string\n}): number => {\n if (!currency) {\n return parseFloat(displayValue)\n }\n\n // Remove currency symbol and any non-numeric characters except decimal\n const cleanValue = displayValue.replace(currency.symbol, '').replace(/[^0-9.]/g, '')\n\n // Parse the clean value to a float\n const floatValue = parseFloat(cleanValue || '0')\n\n // Convert to the base value (e.g., cents for USD)\n return Math.round(floatValue * Math.pow(10, currency.decimals))\n}\n\n/**\n * Convert base value to display value with decimal point (e.g., 2500 to $25.00)\n */\nexport const convertFromBaseValue = ({\n baseValue,\n currency,\n}: {\n baseValue: number\n currency: Currency\n}): string => {\n if (!currency) {\n return baseValue.toString()\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = baseValue / Math.pow(10, currency.decimals)\n\n // Format with the correct number of decimal places\n return decimalValue.toFixed(currency.decimals)\n}\n\n/**\n * Format a base value as a locale-aware currency string using the Intl API.\n *\n * @example formatPrice({ baseValue: 2500, currency: USD }) // \"$25.00\"\n * @example formatPrice({ baseValue: 2500, currency: EUR, locale: 'de' }) // \"25,00 €\"\n */\nexport const formatPrice = ({\n baseValue,\n currency,\n locale = 'en',\n}: {\n baseValue: number\n currency: Currency\n locale?: string\n}): string => {\n return new Intl.NumberFormat(locale, {\n currency: currency.code,\n currencyDisplay: currency.symbolDisplay ?? 'symbol',\n maximumFractionDigits: currency.decimals,\n minimumFractionDigits: currency.decimals,\n style: 'currency',\n }).format(baseValue / Math.pow(10, currency.decimals))\n}\n"],"names":["convertToBaseValue","currency","displayValue","parseFloat","cleanValue","replace","symbol","floatValue","Math","round","pow","decimals","convertFromBaseValue","baseValue","toString","decimalValue","toFixed","formatPrice","locale","Intl","NumberFormat","code","currencyDisplay","symbolDisplay","maximumFractionDigits","minimumFractionDigits","style","format"],"mappings":"AAEA;;CAEC,GACD,OAAO,MAAMA,qBAAqB,CAAC,EACjCC,QAAQ,EACRC,YAAY,EAIb;IACC,IAAI,CAACD,UAAU;QACb,OAAOE,WAAWD;IACpB;IAEA,uEAAuE;IACvE,MAAME,aAAaF,aAAaG,OAAO,CAACJ,SAASK,MAAM,EAAE,IAAID,OAAO,CAAC,YAAY;IAEjF,mCAAmC;IACnC,MAAME,aAAaJ,WAAWC,cAAc;IAE5C,kDAAkD;IAClD,OAAOI,KAAKC,KAAK,CAACF,aAAaC,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;AAC/D,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,SAAS,EACTZ,QAAQ,EAIT;IACC,IAAI,CAACA,UAAU;QACb,OAAOY,UAAUC,QAAQ;IAC3B;IAEA,yEAAyE;IACzE,MAAMC,eAAeF,YAAYL,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;IAE/D,mDAAmD;IACnD,OAAOI,aAAaC,OAAO,CAACf,SAASU,QAAQ;AAC/C,EAAC;AAED;;;;;CAKC,GACD,OAAO,MAAMM,cAAc,CAAC,EAC1BJ,SAAS,EACTZ,QAAQ,EACRiB,SAAS,IAAI,EAKd;IACC,OAAO,IAAIC,KAAKC,YAAY,CAACF,QAAQ;QACnCjB,UAAUA,SAASoB,IAAI;QACvBC,iBAAiBrB,SAASsB,aAAa,IAAI;QAC3CC,uBAAuBvB,SAASU,QAAQ;QACxCc,uBAAuBxB,SAASU,QAAQ;QACxCe,OAAO;IACT,GAAGC,MAAM,CAACd,YAAYL,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;AACtD,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-ecommerce",
3
- "version": "3.84.0-canary.3",
3
+ "version": "3.84.0-canary.5",
4
4
  "description": "Ecommerce plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -74,23 +74,23 @@
74
74
  ],
75
75
  "dependencies": {
76
76
  "qs-esm": "8.0.1",
77
- "@payloadcms/translations": "3.84.0-canary.3",
78
- "@payloadcms/ui": "3.84.0-canary.3"
77
+ "@payloadcms/translations": "3.84.0-canary.5",
78
+ "@payloadcms/ui": "3.84.0-canary.5"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@types/json-schema": "7.0.15",
82
82
  "@types/react": "19.2.9",
83
83
  "@types/react-dom": "19.2.3",
84
84
  "stripe": "18.3.0",
85
+ "@payloadcms/next": "3.84.0-canary.5",
86
+ "@payloadcms/translations": "3.84.0-canary.5",
85
87
  "@payloadcms/eslint-config": "3.28.0",
86
- "@payloadcms/translations": "3.84.0-canary.3",
87
- "@payloadcms/next": "3.84.0-canary.3",
88
- "payload": "3.84.0-canary.3"
88
+ "payload": "3.84.0-canary.5"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
92
92
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
93
- "payload": "3.84.0-canary.3"
93
+ "payload": "3.84.0-canary.5"
94
94
  },
95
95
  "publishConfig": {
96
96
  "registry": "https://registry.npmjs.org/"