@payloadcms/plugin-ecommerce 3.57.0-internal.d758c66 → 3.58.0-canary.4
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.
- package/dist/collections/addresses/createAddressesCollection.d.ts.map +1 -1
- package/dist/collections/addresses/createAddressesCollection.js +1 -0
- package/dist/collections/addresses/createAddressesCollection.js.map +1 -1
- package/dist/exports/types.d.ts +2 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/react/provider/index.d.ts.map +1 -1
- package/dist/react/provider/index.js.map +1 -1
- package/dist/translations/en.d.ts.map +1 -1
- package/dist/translations/en.js +1 -0
- package/dist/translations/en.js.map +1 -1
- package/dist/utilities/pushTypeScriptProperties.js +1 -4
- package/dist/utilities/pushTypeScriptProperties.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAddressesCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKrE,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,oBAAoB,EAAE,YAAY,CAAC,sBAAsB,CAAC,CAAA;QAC1D,iBAAiB,EAAE,WAAW,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAA;QACjE,uBAAuB,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAA;KACjE,CAAA;IACD;;OAEG;IACH,aAAa,EAAE,KAAK,EAAE,CAAA;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB,CAAC,EAAE,WAAW,EAAE,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"createAddressesCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKrE,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,oBAAoB,EAAE,YAAY,CAAC,sBAAsB,CAAC,CAAA;QAC1D,iBAAiB,EAAE,WAAW,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAA;QACjE,uBAAuB,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAA;KACjE,CAAA;IACD;;OAEG;IACH,aAAa,EAAE,KAAK,EAAE,CAAA;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB,CAAC,EAAE,WAAW,EAAE,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA6EzD,CAAA"}
|
|
@@ -45,6 +45,7 @@ export const createAddressesCollection = (props)=>{
|
|
|
45
45
|
description: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
46
46
|
t('plugin-ecommerce:addressesCollectionDescription'),
|
|
47
47
|
group: 'Ecommerce',
|
|
48
|
+
hidden: true,
|
|
48
49
|
useAsTitle: 'createdAt'
|
|
49
50
|
},
|
|
50
51
|
fields,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CountryType } from '../../types/index.js'\n\nimport { defaultCountries } from './defaultCountries.js'\nimport { beforeChange } from './hooks/beforeChange.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: AccessConfig['adminOrCustomerOwner']\n authenticatedOnly: NonNullable<AccessConfig['authenticatedOnly']>\n customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess']\n }\n /**\n * Array of fields used for capturing the address data. Use this over overrides to customise the fields here as it's reused across the plugin.\n */\n addressFields: Field[]\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n supportedCountries?: CountryType[]\n}\n\nexport const createAddressesCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, authenticatedOnly, customerOnlyFieldAccess },\n addressFields,\n customersSlug = 'users',\n } = props || {}\n\n const { supportedCountries: supportedCountriesFromProps } = props || {}\n const supportedCountries = supportedCountriesFromProps || defaultCountries\n const hasOnlyOneCountry = supportedCountries && supportedCountries.length === 1\n\n const fields: Field[] = [\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n ...addressFields.map((field) => {\n if ('name' in field && field.name === 'country') {\n return {\n name: 'country',\n type: 'select',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressCountry'),\n options: supportedCountries || defaultCountries,\n required: true,\n ...(supportedCountries && supportedCountries?.[0] && hasOnlyOneCountry\n ? {\n defaultValue: supportedCountries?.[0].value,\n }\n : {}),\n } as Field\n }\n\n return field\n }),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'addresses',\n access: {\n create: authenticatedOnly,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressesCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [beforeChange({ customerOnlyFieldAccess })],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addresses'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:address'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["defaultCountries","beforeChange","createAddressesCollection","props","access","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","addressFields","customersSlug","supportedCountries","supportedCountriesFromProps","hasOnlyOneCountry","length","fields","name","type","admin","position","label","t","relationTo","map","field","options","required","defaultValue","value","baseConfig","slug","create","delete","read","update","description","group","useAsTitle","hooks","labels","plural","singular","timestamps"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAmBtD,OAAO,MAAMC,4BAAgE,CAACC;IAC5E,MAAM,EACJC,QAAQ,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAE,EAC5EC,aAAa,EACbC,gBAAgB,OAAO,EACxB,GAAGN,SAAS,CAAC;IAEd,MAAM,EAAEO,oBAAoBC,2BAA2B,EAAE,GAAGR,SAAS,CAAC;IACtE,MAAMO,qBAAqBC,+BAA+BX;IAC1D,MAAMY,oBAAoBF,sBAAsBA,mBAAmBG,MAAM,KAAK;IAE9E,MAAMC,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gBAC/DA,EAAE;YACJC,YAAYZ;QACd;WACGD,cAAcc,GAAG,CAAC,CAACC;YACpB,IAAI,UAAUA,SAASA,MAAMR,IAAI,KAAK,WAAW;gBAC/C,OAAO;oBACLA,MAAM;oBACNC,MAAM;oBACNG,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;wBAC/DA,EAAE;oBACJI,SAASd,sBAAsBV;oBAC/ByB,UAAU;oBACV,GAAIf,sBAAsBA,oBAAoB,CAAC,EAAE,IAAIE,oBACjD;wBACEc,cAAchB,oBAAoB,CAAC,EAAE,CAACiB;oBACxC,IACA,CAAC,CAAC;gBACR;YACF;YAEA,OAAOJ;QACT;KACD;IAED,MAAMK,aAA+B;QACnCC,MAAM;QACNzB,QAAQ;YACN0B,QAAQxB;YACRyB,QAAQ1B;YACR2B,MAAM3B;YACN4B,QAAQ5B;QACV;QACAY,OAAO;YACLiB,aAAa,CAAC,EAAEd,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJe,OAAO;YACPC,YAAY;QACd;
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CountryType } from '../../types/index.js'\n\nimport { defaultCountries } from './defaultCountries.js'\nimport { beforeChange } from './hooks/beforeChange.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: AccessConfig['adminOrCustomerOwner']\n authenticatedOnly: NonNullable<AccessConfig['authenticatedOnly']>\n customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess']\n }\n /**\n * Array of fields used for capturing the address data. Use this over overrides to customise the fields here as it's reused across the plugin.\n */\n addressFields: Field[]\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n supportedCountries?: CountryType[]\n}\n\nexport const createAddressesCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, authenticatedOnly, customerOnlyFieldAccess },\n addressFields,\n customersSlug = 'users',\n } = props || {}\n\n const { supportedCountries: supportedCountriesFromProps } = props || {}\n const supportedCountries = supportedCountriesFromProps || defaultCountries\n const hasOnlyOneCountry = supportedCountries && supportedCountries.length === 1\n\n const fields: Field[] = [\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n ...addressFields.map((field) => {\n if ('name' in field && field.name === 'country') {\n return {\n name: 'country',\n type: 'select',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressCountry'),\n options: supportedCountries || defaultCountries,\n required: true,\n ...(supportedCountries && supportedCountries?.[0] && hasOnlyOneCountry\n ? {\n defaultValue: supportedCountries?.[0].value,\n }\n : {}),\n } as Field\n }\n\n return field\n }),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'addresses',\n access: {\n create: authenticatedOnly,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressesCollectionDescription'),\n group: 'Ecommerce',\n hidden: true,\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [beforeChange({ customerOnlyFieldAccess })],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addresses'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:address'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["defaultCountries","beforeChange","createAddressesCollection","props","access","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","addressFields","customersSlug","supportedCountries","supportedCountriesFromProps","hasOnlyOneCountry","length","fields","name","type","admin","position","label","t","relationTo","map","field","options","required","defaultValue","value","baseConfig","slug","create","delete","read","update","description","group","hidden","useAsTitle","hooks","labels","plural","singular","timestamps"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAmBtD,OAAO,MAAMC,4BAAgE,CAACC;IAC5E,MAAM,EACJC,QAAQ,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAE,EAC5EC,aAAa,EACbC,gBAAgB,OAAO,EACxB,GAAGN,SAAS,CAAC;IAEd,MAAM,EAAEO,oBAAoBC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ports/types.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { CollectionOverride, CollectionSlugMap, CountryType, CurrenciesConfig, Currency, EcommerceCollections, EcommerceContextType, EcommercePluginConfig, PaymentAdapter, PaymentAdapterArgs, PaymentAdapterClient, PaymentAdapterClientArgs, ProductsValidation, SanitizedEcommercePluginConfig, } from '../types/index.js';
|
|
2
|
+
export type { TypedEcommerce } from '../types/utilities.js';
|
|
2
3
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,8BAA8B,GAC/B,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n
|
|
1
|
+
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n CollectionOverride,\n CollectionSlugMap,\n CountryType,\n CurrenciesConfig,\n Currency,\n EcommerceCollections,\n EcommerceContextType,\n EcommercePluginConfig,\n PaymentAdapter,\n PaymentAdapterArgs,\n PaymentAdapterClient,\n PaymentAdapterClientArgs,\n ProductsValidation,\n SanitizedEcommercePluginConfig,\n} from '../types/index.js'\n\nexport type { TypedEcommerce } from '../types/utilities.js'\n"],"names":[],"mappings":"AAiBA,WAA2D"}
|
|
@@ -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,EAEnB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;
|
|
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,EAEnB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAuC7B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAwvBpD,CAAA;AAED,eAAO,MAAM,YAAY,4BAQxB,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;;;;;UAOf,CAAC;;;;;EAClC;AAED,eAAO,MAAM,WAAW;;;;;;;;;CAQvB,CAAA;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,mBAAmB;eAOvB,CAAC,EAAE;;;;;;;;;EACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/react/provider/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultDocumentIDType, TypedUser } from 'payload'\n\nimport { deepMergeSimple } 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 CartItem,\n CartsCollection,\n ContextProps,\n Currency,\n EcommerceContextType,\n} from '../../types/index.js'\nimport type { TypedEcommerce } from '../../types/utilities.js'\n\nconst defaultContext: EcommerceContextType = {\n addItem: async () => {},\n clearCart: async () => {},\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 paymentMethods: [],\n removeItem: async () => {},\n setCurrency: () => {},\n updateAddress: async () => {},\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 = {}, serverURL = '' } = api || {}\n const baseAPIURL = `${serverURL}${apiRoute}`\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 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 return data.doc as CartsCollection\n },\n [baseAPIURL, cartQuery, cartsSlug, selectedCurrency.code, user?.id],\n )\n\n const getCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const query = qs.stringify(cartQuery)\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 if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch cart: ${errorText}`)\n }\n const data = await response.json()\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 updateCart = useCallback(\n async (cartID: DefaultDocumentIDType, data: Partial<CartsCollection>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n body: JSON.stringify(data),\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 cart: ${errorText}`)\n }\n\n const updatedCart = await response.json()\n\n setCart(updatedCart.doc as CartsCollection)\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const deleteCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'DELETE',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update cart: ${errorText}`)\n }\n\n setCart(undefined)\n setCartID(undefined)\n },\n [baseAPIURL, cartsSlug],\n )\n\n useEffect(() => {\n if (hasRendered.current) {\n if (syncLocalStorage && cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n }\n }\n }, [cartID, localStorageConfig.key, syncLocalStorage])\n\n const addItem: EcommerceContextType['addItem'] = useCallback(\n async (item, quantity = 1) => {\n if (cartID) {\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => {\n const productID =\n typeof cartItem.product === 'object' ? cartItem.product.id : item.product\n const variantID =\n cartItem.variant && typeof cartItem.variant === 'object'\n ? cartItem.variant.id\n : item.variant\n\n return (\n productID === item.product &&\n (item.variant && variantID ? variantID === item.variant : true)\n )\n }) ?? -1\n\n let updatedItems = existingCart.items ? [...existingCart.items] : []\n\n if (existingItemIndex !== -1) {\n // If the item exists, update its quantity\n updatedItems[existingItemIndex].quantity =\n updatedItems[existingItemIndex].quantity + quantity\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart\n updatedItems = [...(existingCart.items ?? []), { ...item, quantity }]\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If no cartID exists, create a new cart\n const newCart = await createCart({ items: [{ ...item, quantity }] })\n\n setCartID(newCart.id)\n setCart(newCart)\n }\n },\n [cartID, createCart, getCart, updateCart],\n )\n\n const removeItem: EcommerceContextType['removeItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => cartItem.id === targetID) ?? -1\n\n if (existingItemIndex !== -1) {\n // If the item exists, remove it from the cart\n const updatedItems = existingCart.items ? [...existingCart.items] : []\n updatedItems.splice(existingItemIndex, 1)\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const incrementItem: EcommerceContextType['incrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => cartItem.id === targetID) ?? -1\n\n let updatedItems = existingCart.items ? [...existingCart.items] : []\n\n if (existingItemIndex !== -1) {\n // If the item exists, increment its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity + 1 // Increment by 1\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart with quantity 1\n updatedItems = [...(existingCart.items ?? []), { product: targetID, quantity: 1 }]\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const decrementItem: EcommerceContextType['decrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => cartItem.id === targetID) ?? -1\n\n const updatedItems = existingCart.items ? [...existingCart.items] : []\n\n if (existingItemIndex !== -1) {\n // If the item exists, decrement its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity - 1 // Decrement by 1\n\n // If the quantity reaches 0, remove the item from the cart\n if (updatedItems[existingItemIndex].quantity <= 0) {\n updatedItems.splice(existingItemIndex, 1)\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const clearCart: EcommerceContextType['clearCart'] = useCallback(async () => {\n if (cartID) {\n await deleteCart(cartID)\n }\n }, [cartID, deleteCart])\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 const fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/initiate`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n try {\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\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, 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 fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/confirm-order`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\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, 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 carts: 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 // If localStorage is enabled, we can add logic to persist the cart state\n useEffect(() => {\n if (!hasRendered.current) {\n if (syncLocalStorage) {\n const storedCart = localStorage.getItem(localStorageConfig.key)\n if (storedCart) {\n getCart(storedCart)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(storedCart as DefaultDocumentIDType)\n })\n .catch((_) => {\n // console.error('Error fetching cart from localStorage:', error)\n // If there's an error fetching the cart, we can clear it from localStorage\n localStorage.removeItem(localStorageConfig.key)\n setCartID(undefined)\n setCart(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 confirmOrder,\n createAddress,\n currenciesConfig,\n currency: selectedCurrency,\n decrementItem,\n incrementItem,\n initiatePayment,\n paymentMethods,\n removeItem,\n selectedPaymentMethod,\n setCurrency,\n updateAddress,\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 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 { addItem, cart, clearCart, decrementItem, incrementItem, removeItem } = useEcommerce()\n\n if (!addItem) {\n throw new Error('useCart must be used within an EcommerceProvider')\n }\n\n return { addItem, cart: cart as T, clearCart, decrementItem, incrementItem, removeItem }\n}\n\nexport const usePayments = () => {\n const { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod } = useEcommerce()\n\n if (!initiatePayment) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod }\n}\n\nexport function useAddresses<T extends AddressesCollection>() {\n const { addresses, createAddress, 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, updateAddress }\n}\n"],"names":["deepMergeSimple","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","defaultContext","addItem","clearCart","confirmOrder","createAddress","currenciesConfig","defaultCurrency","supportedCurrencies","code","decimals","label","symbol","currency","decrementItem","incrementItem","initiatePayment","paymentMethods","removeItem","setCurrency","updateAddress","EcommerceContext","defaultLocalStorage","key","EcommerceProvider","addressesSlug","api","cartsSlug","children","customersSlug","debug","syncLocalStorage","localStorageConfig","apiRoute","cartsFetchQuery","serverURL","baseAPIURL","user","setUser","addresses","setAddresses","hasRendered","cartID","setCartID","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","getCart","updateCart","updatedCart","deleteCart","undefined","current","localStorage","setItem","item","quantity","existingCart","existingItemIndex","findIndex","cartItem","productID","product","variantID","variant","updatedItems","newCart","targetID","splice","foundCurrency","paymentMethodID","paymentMethod","name","fetchURL","additionalData","responseError","responseData","console","message","pm","getUser","carts","userData","getAddresses","limit","pagination","docs","length","addressID","address","storedCart","getItem","then","fetchedCart","catch","_","value","useEcommerce","context","useCurrency","formatCurrency","currencyToUse","toString","repeat","decimalValue","Math","pow","toFixed","useCart","usePayments","useAddresses"],"mappings":"AAAA;;AAGA,SAASA,eAAe,QAAQ,iBAAgB;AAChD,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAYpG,MAAMC,iBAAuC;IAC3CC,SAAS,WAAa;IACtBC,WAAW,WAAa;IACxBC,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,gBAAgB,EAAE;IAClBC,YAAY,WAAa;IACzBC,aAAa,KAAO;IACpBC,eAAe,WAAa;AAC9B;AAEA,MAAMC,iCAAmB3B,cAAoCO;AAE7D,MAAMqB,sBAAsB;IAC1BC,KAAK;AACP;AAEA,OAAO,MAAMC,oBAA4C,CAAC,EACxDC,gBAAgB,WAAW,EAC3BC,GAAG,EACHC,YAAY,OAAO,EACnBC,QAAQ,EACRtB,mBAAmB;IACjBC,iBAAiB;IACjBC,qBAAqB;QACnB;YACEC,MAAM;YACNC,UAAU;YACVC,OAAO;YACPC,QAAQ;QACV;KACD;AACH,CAAC,EACDiB,gBAAgB,OAAO,EACv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I,QAAQ,GAAG;IACjF,GACA;QAACG;KAAS;IAGZ,IAAI,CAACA,UAAU;QACb,MAAM,IAAIkE,MAAM;IAClB;IAEA,OAAO;QACLlE;QACA4H;QACAtH;QACAX,qBAAqBF,iBAAiBE,mBAAmB;IAC3D;AACF,EAAC;AAED,OAAO,SAASyI;IACd,MAAM,EAAE/I,OAAO,EAAE0C,IAAI,EAAEzC,SAAS,EAAEW,aAAa,EAAEC,aAAa,EAAEG,UAAU,EAAE,GAAGoH;IAE/E,IAAI,CAACpI,SAAS;QACZ,MAAM,IAAI6E,MAAM;IAClB;IAEA,OAAO;QAAE7E;QAAS0C,MAAMA;QAAWzC;QAAWW;QAAeC;QAAeG;IAAW;AACzF;AAEA,OAAO,MAAMgI,cAAc;IACzB,MAAM,EAAE9I,YAAY,EAAEY,eAAe,EAAEC,cAAc,EAAEiC,qBAAqB,EAAE,GAAGoF;IAEjF,IAAI,CAACtH,iBAAiB;QACpB,MAAM,IAAI+D,MAAM;IAClB;IAEA,OAAO;QAAE3E;QAAcY;QAAiBC;QAAgBiC;IAAsB;AAChF,EAAC;AAED,OAAO,SAASiG;IACd,MAAM,EAAE5G,SAAS,EAAElC,aAAa,EAAEe,aAAa,EAAE,GAAGkH;IAEpD,IAAI,CAACjI,eAAe;QAClB,MAAM,IAAI0E,MAAM;IAClB;IAEA,OAAO;QAAExC,WAAWA;QAAkBlC;QAAee;IAAc;AACrE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/react/provider/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultDocumentIDType, TypedUser } from 'payload'\n\nimport { deepMergeSimple } 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 CartItem,\n CartsCollection,\n ContextProps,\n Currency,\n EcommerceContextType,\n} from '../../types/index.js'\n\nconst defaultContext: EcommerceContextType = {\n addItem: async () => {},\n clearCart: async () => {},\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 paymentMethods: [],\n removeItem: async () => {},\n setCurrency: () => {},\n updateAddress: async () => {},\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 = {}, serverURL = '' } = api || {}\n const baseAPIURL = `${serverURL}${apiRoute}`\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 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 return data.doc as CartsCollection\n },\n [baseAPIURL, cartQuery, cartsSlug, selectedCurrency.code, user?.id],\n )\n\n const getCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const query = qs.stringify(cartQuery)\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 if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch cart: ${errorText}`)\n }\n const data = await response.json()\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 updateCart = useCallback(\n async (cartID: DefaultDocumentIDType, data: Partial<CartsCollection>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n body: JSON.stringify(data),\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 cart: ${errorText}`)\n }\n\n const updatedCart = await response.json()\n\n setCart(updatedCart.doc as CartsCollection)\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const deleteCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'DELETE',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update cart: ${errorText}`)\n }\n\n setCart(undefined)\n setCartID(undefined)\n },\n [baseAPIURL, cartsSlug],\n )\n\n useEffect(() => {\n if (hasRendered.current) {\n if (syncLocalStorage && cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n }\n }\n }, [cartID, localStorageConfig.key, syncLocalStorage])\n\n const addItem: EcommerceContextType['addItem'] = useCallback(\n async (item, quantity = 1) => {\n if (cartID) {\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => {\n const productID =\n typeof cartItem.product === 'object' ? cartItem.product.id : item.product\n const variantID =\n cartItem.variant && typeof cartItem.variant === 'object'\n ? cartItem.variant.id\n : item.variant\n\n return (\n productID === item.product &&\n (item.variant && variantID ? variantID === item.variant : true)\n )\n }) ?? -1\n\n let updatedItems = existingCart.items ? [...existingCart.items] : []\n\n if (existingItemIndex !== -1) {\n // If the item exists, update its quantity\n updatedItems[existingItemIndex].quantity =\n updatedItems[existingItemIndex].quantity + quantity\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart\n updatedItems = [...(existingCart.items ?? []), { ...item, quantity }]\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If no cartID exists, create a new cart\n const newCart = await createCart({ items: [{ ...item, quantity }] })\n\n setCartID(newCart.id)\n setCart(newCart)\n }\n },\n [cartID, createCart, getCart, updateCart],\n )\n\n const removeItem: EcommerceContextType['removeItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => cartItem.id === targetID) ?? -1\n\n if (existingItemIndex !== -1) {\n // If the item exists, remove it from the cart\n const updatedItems = existingCart.items ? [...existingCart.items] : []\n updatedItems.splice(existingItemIndex, 1)\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const incrementItem: EcommerceContextType['incrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => cartItem.id === targetID) ?? -1\n\n let updatedItems = existingCart.items ? [...existingCart.items] : []\n\n if (existingItemIndex !== -1) {\n // If the item exists, increment its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity + 1 // Increment by 1\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart with quantity 1\n updatedItems = [...(existingCart.items ?? []), { product: targetID, quantity: 1 }]\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const decrementItem: EcommerceContextType['decrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex =\n existingCart.items?.findIndex((cartItem: CartItem) => cartItem.id === targetID) ?? -1\n\n const updatedItems = existingCart.items ? [...existingCart.items] : []\n\n if (existingItemIndex !== -1) {\n // If the item exists, decrement its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity - 1 // Decrement by 1\n\n // If the quantity reaches 0, remove the item from the cart\n if (updatedItems[existingItemIndex].quantity <= 0) {\n updatedItems.splice(existingItemIndex, 1)\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const clearCart: EcommerceContextType['clearCart'] = useCallback(async () => {\n if (cartID) {\n await deleteCart(cartID)\n }\n }, [cartID, deleteCart])\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 const fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/initiate`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n try {\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\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, 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 fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/confirm-order`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\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, 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 carts: 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 // If localStorage is enabled, we can add logic to persist the cart state\n useEffect(() => {\n if (!hasRendered.current) {\n if (syncLocalStorage) {\n const storedCart = localStorage.getItem(localStorageConfig.key)\n if (storedCart) {\n getCart(storedCart)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(storedCart as DefaultDocumentIDType)\n })\n .catch((_) => {\n // console.error('Error fetching cart from localStorage:', error)\n // If there's an error fetching the cart, we can clear it from localStorage\n localStorage.removeItem(localStorageConfig.key)\n setCartID(undefined)\n setCart(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 confirmOrder,\n createAddress,\n currenciesConfig,\n currency: selectedCurrency,\n decrementItem,\n incrementItem,\n initiatePayment,\n paymentMethods,\n removeItem,\n selectedPaymentMethod,\n setCurrency,\n updateAddress,\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 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 { addItem, cart, clearCart, decrementItem, incrementItem, removeItem } = useEcommerce()\n\n if (!addItem) {\n throw new Error('useCart must be used within an EcommerceProvider')\n }\n\n return { addItem, cart: cart as T, clearCart, decrementItem, incrementItem, removeItem }\n}\n\nexport const usePayments = () => {\n const { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod } = useEcommerce()\n\n if (!initiatePayment) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod }\n}\n\nexport function useAddresses<T extends AddressesCollection>() {\n const { addresses, createAddress, 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, updateAddress }\n}\n"],"names":["deepMergeSimple","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","defaultContext","addItem","clearCart","confirmOrder","createAddress","currenciesConfig","defaultCurrency","supportedCurrencies","code","decimals","label","symbol","currency","decrementItem","incrementItem","initiatePayment","paymentMethods","removeItem","setCurrency","updateAddress","EcommerceContext","defaultLocalStorage","key","EcommerceProvider","addressesSlug","api","cartsSlug","children","customersSlug","debug","syncLocalStorage","localStorageConfig","apiRoute","cartsFetchQuery","serverURL","baseAPIURL","user","setUser","addresses","setAddresses","hasRendered","cartID","setCartID","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","getCart","updateCart","updatedCart","deleteCart","undefined","current","localStorage","setItem","item","quantity","existingCart","existingItemIndex","findIndex","cartItem","productID","product","variantID","variant","updatedItems","newCart","targetID","splice","foundCurrency","paymentMethodID","paymentMethod","name","fetchURL","additionalData","responseError","responseData","console","message","pm","getUser","carts","userData","getAddresses","limit","pagination","docs","length","addressID","address","storedCart","getItem","then","fetchedCart","catch","_","value","useEcommerce","context","useCurrency","formatCurrency","currencyToUse","toString","repeat","decimalValue","Math","pow","toFixed","useCart","usePayments","useAddresses"],"mappings":"AAAA;;AAGA,SAASA,eAAe,QAAQ,iBAAgB;AAChD,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,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,gBAAgB,EAAE;IAClBC,YAAY,WAAa;IACzBC,aAAa,KAAO;IACpBC,eAAe,WAAa;AAC9B;AAEA,MAAMC,iCAAmB3B,cAAoCO;AAE7D,MAAMqB,sBAAsB;IAC1BC,KAAK;AACP;AAEA,OAAO,MAAMC,oBAA4C,CAAC,EACxDC,gBAAgB,WAAW,EAC3BC,GAAG,EACHC,YAAY,OAAO,EACnBC,QAAQ,EACRtB,mBAAmB;IACjBC,iBAAiB;IACjBC,qBAAqB;QACnB;YACEC,MAAM;YACNC,UAAU;YACVC,OAAO;YACPC,QAAQ;QACV;KACD;AACH,CAAC,EACDiB,gBAAgB,OAAO,EACvBC,QAAQ,KAAK,EACbb,iBAAiB,EAAE,EACnBc,mBAAmB,IAAI,EACxB;IACC,MAAMC,qBACJD,oBAAoB,OAAOA,qBAAqB,WAC5C;QACE,GAAGT,mBAAmB;QACtB,GAAGS,gBAAgB;IACrB,IACAT;IAEN,MAAM,EAAEW,WAAW,MAAM,EAA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AAM,EAAE/I,OAAO,EAAE0C,IAAI,EAAEzC,SAAS,EAAEW,aAAa,EAAEC,aAAa,EAAEG,UAAU,EAAE,GAAGoH;IAE/E,IAAI,CAACpI,SAAS;QACZ,MAAM,IAAI6E,MAAM;IAClB;IAEA,OAAO;QAAE7E;QAAS0C,MAAMA;QAAWzC;QAAWW;QAAeC;QAAeG;IAAW;AACzF;AAEA,OAAO,MAAMgI,cAAc;IACzB,MAAM,EAAE9I,YAAY,EAAEY,eAAe,EAAEC,cAAc,EAAEiC,qBAAqB,EAAE,GAAGoF;IAEjF,IAAI,CAACtH,iBAAiB;QACpB,MAAM,IAAI+D,MAAM;IAClB;IAEA,OAAO;QAAE3E;QAAcY;QAAiBC;QAAgBiC;IAAsB;AAChF,EAAC;AAED,OAAO,SAASiG;IACd,MAAM,EAAE5G,SAAS,EAAElC,aAAa,EAAEe,aAAa,EAAE,GAAGkH;IAEpD,IAAI,CAACjI,eAAe;QAClB,MAAM,IAAI0E,MAAM;IAClB;IAEA,OAAO;QAAExC,WAAWA;QAAkBlC;QAAee;IAAc;AACrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/translations/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEzE,eAAO,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/translations/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEzE,eAAO,MAAM,EAAE,EAAE,yBA6FhB,CAAA"}
|
package/dist/translations/en.js
CHANGED
|
@@ -8,6 +8,7 @@ export const en = {
|
|
|
8
8
|
addressCompany: 'Company',
|
|
9
9
|
addressCountry: 'Country',
|
|
10
10
|
addresses: 'Addresses',
|
|
11
|
+
addressesCollectionDescription: 'Addresses are associated with customers are used to prefill shipping and billing when placing orders.',
|
|
11
12
|
addressFirstName: 'First name',
|
|
12
13
|
addressLastName: 'Last name',
|
|
13
14
|
addressLine1: 'Address 1',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/translations/en.ts"],"sourcesContent":["import type { GenericTranslationsObject } from '@payloadcms/translations'\n\nexport const en: GenericTranslationsObject = {\n $schema: './translation-schema.json',\n 'plugin-ecommerce': {\n abandoned: 'Abandoned',\n active: 'Active',\n address: 'Address',\n addressCity: 'City',\n addressCompany: 'Company',\n addressCountry: 'Country',\n addresses: 'Addresses',\n addressFirstName: 'First name',\n addressLastName: 'Last name',\n addressLine1: 'Address 1',\n addressLine2: 'Address 2',\n addressPhone: 'Phone',\n addressPostalCode: 'Postal code',\n addressState: 'State',\n addressTitle: 'Title',\n amount: 'Amount',\n availableVariants: 'Available variants',\n billing: 'Billing',\n billingAddress: 'Billing address',\n cancelled: 'Cancelled',\n cart: 'Cart',\n carts: 'Carts',\n cartsCollectionDescription:\n \"Carts represent a customer's selection of products they intend to purchase. They are related to a customer where possible and guest users do not have a customer attached.\",\n completed: 'Completed',\n currency: 'Currency',\n currencyNotSet: 'Currency not set.',\n customer: 'Customer',\n customerEmail: 'Customer email',\n customers: 'Customers',\n enableCurrencyPrice: `Enable {{currency}} price`,\n enableVariants: 'Enable variants',\n expired: 'Expired',\n failed: 'Failed',\n inventory: 'Inventory',\n item: 'Item',\n items: 'Items',\n open: 'Open',\n order: 'Order',\n orderDetails: 'Order Details',\n orders: 'Orders',\n ordersCollectionDescription:\n \"Orders represent a customer's intent to purchase products from your store. They include details such as the products ordered, quantities, prices, customer information, and order status.\",\n paymentMethod: 'Payment method',\n paymentMethods: 'Payment methods',\n pending: 'Pending',\n price: 'Price',\n priceIn: 'Price ({{currency}})',\n priceNotSet: 'Price not set.',\n prices: 'Prices',\n priceSetInVariants: 'Price set in variants.',\n processing: 'Processing',\n product: 'Product',\n productPriceDescription:\n 'This price will also be used for sorting and filtering products. If you have variants enabled then you can enter the lowest or average price to help with search and filtering, but this price will not be used for checkout.',\n productRequired: 'A product is required.',\n products: 'Products',\n purchased: 'Purchased',\n purchasedAt: 'Purchased at',\n quantity: 'Quantity',\n refunded: 'Refunded',\n shipping: 'Shipping',\n shippingAddress: 'Shipping address',\n status: 'Status',\n subtotal: 'Subtotal',\n succeeded: 'Succeeded',\n transaction: 'Transaction',\n transactionDetails: 'Transaction Details',\n transactions: 'Transactions',\n transactionsCollectionDescription:\n 'Transactions represent payment attempts made for an order. An order can have multiple transactions associated with it, such as an initial payment attempt and subsequent refunds or adjustments.',\n variant: 'Variant',\n variantOption: 'Variant Option',\n variantOptions: 'Variant Options',\n variantOptionsAlreadyExists:\n 'This variant combo is already in use by another variant. Please select different options.',\n variantOptionsCollectionDescription:\n 'Variant options define the options a variant type can have, such as red or white for colors.',\n variantOptionsRequired: 'Variant options are required.',\n variantOptionsRequiredAll: 'All variant options are required.',\n variants: 'Variants',\n variantsCollectionDescription:\n \"Product variants allow you to offer different versions of a product, such as size or color variations. They refrence a product's variant options based on the variant types approved.\",\n variantType: 'Variant Type',\n variantTypes: 'Variant Types',\n variantTypesCollectionDescription:\n 'Variant types are used to define the different types of variants your products can have, such as size or color. Each variant type can have multiple options associated with it.',\n },\n}\n"],"names":["en","$schema","abandoned","active","address","addressCity","addressCompany","addressCountry","addresses","addressFirstName","addressLastName","addressLine1","addressLine2","addressPhone","addressPostalCode","addressState","addressTitle","amount","availableVariants","billing","billingAddress","cancelled","cart","carts","cartsCollectionDescription","completed","currency","currencyNotSet","customer","customerEmail","customers","enableCurrencyPrice","enableVariants","expired","failed","inventory","item","items","open","order","orderDetails","orders","ordersCollectionDescription","paymentMethod","paymentMethods","pending","price","priceIn","priceNotSet","prices","priceSetInVariants","processing","product","productPriceDescription","productRequired","products","purchased","purchasedAt","quantity","refunded","shipping","shippingAddress","status","subtotal","succeeded","transaction","transactionDetails","transactions","transactionsCollectionDescription","variant","variantOption","variantOptions","variantOptionsAlreadyExists","variantOptionsCollectionDescription","variantOptionsRequired","variantOptionsRequiredAll","variants","variantsCollectionDescription","variantType","variantTypes","variantTypesCollectionDescription"],"mappings":"AAEA,OAAO,MAAMA,KAAgC;IAC3CC,SAAS;IACT,oBAAoB;QAClBC,WAAW;QACXC,QAAQ;QACRC,SAAS;QACTC,aAAa;QACbC,gBAAgB;QAChBC,gBAAgB;QAChBC,WAAW;QACXC,kBAAkB;QAClBC,iBAAiB;QACjBC,cAAc;QACdC,cAAc;QACdC,cAAc;QACdC,mBAAmB;QACnBC,cAAc;QACdC,cAAc;QACdC,QAAQ;QACRC,mBAAmB;QACnBC,SAAS;QACTC,gBAAgB;QAChBC,WAAW;QACXC,MAAM;QACNC,OAAO;QACPC,4BACE;QACFC,WAAW;QACXC,UAAU;QACVC,gBAAgB;QAChBC,UAAU;QACVC,eAAe;QACfC,WAAW;QACXC,qBAAqB,CAAC,yBAAyB,CAAC;QAChDC,gBAAgB;QAChBC,SAAS;QACTC,QAAQ;QACRC,WAAW;QACXC,MAAM;QACNC,OAAO;QACPC,MAAM;QACNC,OAAO;QACPC,cAAc;QACdC,QAAQ;QACRC,6BACE;QACFC,eAAe;QACfC,gBAAgB;QAChBC,SAAS;QACTC,OAAO;QACPC,SAAS;QACTC,aAAa;QACbC,QAAQ;QACRC,oBAAoB;QACpBC,YAAY;QACZC,SAAS;QACTC,yBACE;QACFC,iBAAiB;QACjBC,UAAU;QACVC,WAAW;QACXC,aAAa;QACbC,UAAU;QACVC,UAAU;QACVC,UAAU;QACVC,iBAAiB;QACjBC,QAAQ;QACRC,UAAU;QACVC,WAAW;QACXC,aAAa;QACbC,oBAAoB;QACpBC,cAAc;QACdC,mCACE;QACFC,SAAS;QACTC,eAAe;QACfC,gBAAgB;QAChBC,6BACE;QACFC,qCACE;QACFC,wBAAwB;QACxBC,2BAA2B;QAC3BC,UAAU;QACVC,+BACE;QACFC,aAAa;QACbC,cAAc;QACdC,mCACE;IACJ;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/translations/en.ts"],"sourcesContent":["import type { GenericTranslationsObject } from '@payloadcms/translations'\n\nexport const en: GenericTranslationsObject = {\n $schema: './translation-schema.json',\n 'plugin-ecommerce': {\n abandoned: 'Abandoned',\n active: 'Active',\n address: 'Address',\n addressCity: 'City',\n addressCompany: 'Company',\n addressCountry: 'Country',\n addresses: 'Addresses',\n addressesCollectionDescription:\n 'Addresses are associated with customers are used to prefill shipping and billing when placing orders.',\n addressFirstName: 'First name',\n addressLastName: 'Last name',\n addressLine1: 'Address 1',\n addressLine2: 'Address 2',\n addressPhone: 'Phone',\n addressPostalCode: 'Postal code',\n addressState: 'State',\n addressTitle: 'Title',\n amount: 'Amount',\n availableVariants: 'Available variants',\n billing: 'Billing',\n billingAddress: 'Billing address',\n cancelled: 'Cancelled',\n cart: 'Cart',\n carts: 'Carts',\n cartsCollectionDescription:\n \"Carts represent a customer's selection of products they intend to purchase. They are related to a customer where possible and guest users do not have a customer attached.\",\n completed: 'Completed',\n currency: 'Currency',\n currencyNotSet: 'Currency not set.',\n customer: 'Customer',\n customerEmail: 'Customer email',\n customers: 'Customers',\n enableCurrencyPrice: `Enable {{currency}} price`,\n enableVariants: 'Enable variants',\n expired: 'Expired',\n failed: 'Failed',\n inventory: 'Inventory',\n item: 'Item',\n items: 'Items',\n open: 'Open',\n order: 'Order',\n orderDetails: 'Order Details',\n orders: 'Orders',\n ordersCollectionDescription:\n \"Orders represent a customer's intent to purchase products from your store. They include details such as the products ordered, quantities, prices, customer information, and order status.\",\n paymentMethod: 'Payment method',\n paymentMethods: 'Payment methods',\n pending: 'Pending',\n price: 'Price',\n priceIn: 'Price ({{currency}})',\n priceNotSet: 'Price not set.',\n prices: 'Prices',\n priceSetInVariants: 'Price set in variants.',\n processing: 'Processing',\n product: 'Product',\n productPriceDescription:\n 'This price will also be used for sorting and filtering products. If you have variants enabled then you can enter the lowest or average price to help with search and filtering, but this price will not be used for checkout.',\n productRequired: 'A product is required.',\n products: 'Products',\n purchased: 'Purchased',\n purchasedAt: 'Purchased at',\n quantity: 'Quantity',\n refunded: 'Refunded',\n shipping: 'Shipping',\n shippingAddress: 'Shipping address',\n status: 'Status',\n subtotal: 'Subtotal',\n succeeded: 'Succeeded',\n transaction: 'Transaction',\n transactionDetails: 'Transaction Details',\n transactions: 'Transactions',\n transactionsCollectionDescription:\n 'Transactions represent payment attempts made for an order. An order can have multiple transactions associated with it, such as an initial payment attempt and subsequent refunds or adjustments.',\n variant: 'Variant',\n variantOption: 'Variant Option',\n variantOptions: 'Variant Options',\n variantOptionsAlreadyExists:\n 'This variant combo is already in use by another variant. Please select different options.',\n variantOptionsCollectionDescription:\n 'Variant options define the options a variant type can have, such as red or white for colors.',\n variantOptionsRequired: 'Variant options are required.',\n variantOptionsRequiredAll: 'All variant options are required.',\n variants: 'Variants',\n variantsCollectionDescription:\n \"Product variants allow you to offer different versions of a product, such as size or color variations. They refrence a product's variant options based on the variant types approved.\",\n variantType: 'Variant Type',\n variantTypes: 'Variant Types',\n variantTypesCollectionDescription:\n 'Variant types are used to define the different types of variants your products can have, such as size or color. Each variant type can have multiple options associated with it.',\n },\n}\n"],"names":["en","$schema","abandoned","active","address","addressCity","addressCompany","addressCountry","addresses","addressesCollectionDescription","addressFirstName","addressLastName","addressLine1","addressLine2","addressPhone","addressPostalCode","addressState","addressTitle","amount","availableVariants","billing","billingAddress","cancelled","cart","carts","cartsCollectionDescription","completed","currency","currencyNotSet","customer","customerEmail","customers","enableCurrencyPrice","enableVariants","expired","failed","inventory","item","items","open","order","orderDetails","orders","ordersCollectionDescription","paymentMethod","paymentMethods","pending","price","priceIn","priceNotSet","prices","priceSetInVariants","processing","product","productPriceDescription","productRequired","products","purchased","purchasedAt","quantity","refunded","shipping","shippingAddress","status","subtotal","succeeded","transaction","transactionDetails","transactions","transactionsCollectionDescription","variant","variantOption","variantOptions","variantOptionsAlreadyExists","variantOptionsCollectionDescription","variantOptionsRequired","variantOptionsRequiredAll","variants","variantsCollectionDescription","variantType","variantTypes","variantTypesCollectionDescription"],"mappings":"AAEA,OAAO,MAAMA,KAAgC;IAC3CC,SAAS;IACT,oBAAoB;QAClBC,WAAW;QACXC,QAAQ;QACRC,SAAS;QACTC,aAAa;QACbC,gBAAgB;QAChBC,gBAAgB;QAChBC,WAAW;QACXC,gCACE;QACFC,kBAAkB;QAClBC,iBAAiB;QACjBC,cAAc;QACdC,cAAc;QACdC,cAAc;QACdC,mBAAmB;QACnBC,cAAc;QACdC,cAAc;QACdC,QAAQ;QACRC,mBAAmB;QACnBC,SAAS;QACTC,gBAAgB;QAChBC,WAAW;QACXC,MAAM;QACNC,OAAO;QACPC,4BACE;QACFC,WAAW;QACXC,UAAU;QACVC,gBAAgB;QAChBC,UAAU;QACVC,eAAe;QACfC,WAAW;QACXC,qBAAqB,CAAC,yBAAyB,CAAC;QAChDC,gBAAgB;QAChBC,SAAS;QACTC,QAAQ;QACRC,WAAW;QACXC,MAAM;QACNC,OAAO;QACPC,MAAM;QACNC,OAAO;QACPC,cAAc;QACdC,QAAQ;QACRC,6BACE;QACFC,eAAe;QACfC,gBAAgB;QAChBC,SAAS;QACTC,OAAO;QACPC,SAAS;QACTC,aAAa;QACbC,QAAQ;QACRC,oBAAoB;QACpBC,YAAY;QACZC,SAAS;QACTC,yBACE;QACFC,iBAAiB;QACjBC,UAAU;QACVC,WAAW;QACXC,aAAa;QACbC,UAAU;QACVC,UAAU;QACVC,UAAU;QACVC,iBAAiB;QACjBC,QAAQ;QACRC,UAAU;QACVC,WAAW;QACXC,aAAa;QACbC,oBAAoB;QACpBC,cAAc;QACdC,mCACE;QACFC,SAAS;QACTC,eAAe;QACfC,gBAAgB;QAChBC,6BACE;QACFC,qCACE;QACFC,wBAAwB;QACxBC,2BAA2B;QAC3BC,UAAU;QACVC,+BACE;QACFC,aAAa;QACbC,cAAc;QACdC,mCACE;IACJ;AACF,EAAC"}
|
|
@@ -13,13 +13,10 @@ export const pushTypeScriptProperties = ({ collectionSlugMap, jsonSchema })=>{
|
|
|
13
13
|
});
|
|
14
14
|
requiredCollectionProperties.push(slug);
|
|
15
15
|
});
|
|
16
|
-
console.log({
|
|
17
|
-
collectionSlugMap,
|
|
18
|
-
propertiesMap
|
|
19
|
-
});
|
|
20
16
|
jsonSchema.properties.ecommerce = {
|
|
21
17
|
type: 'object',
|
|
22
18
|
additionalProperties: false,
|
|
19
|
+
description: 'Generated by the Payload Ecommerce plugin',
|
|
23
20
|
properties: {
|
|
24
21
|
collections: {
|
|
25
22
|
type: 'object',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/pushTypeScriptProperties.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { SanitizedConfig } from 'payload'\n\nimport type { CollectionSlugMap, SanitizedEcommercePluginConfig } from '../types/index.js'\n\nexport const pushTypeScriptProperties = ({\n collectionSlugMap,\n jsonSchema,\n}: {\n collectionSlugMap: CollectionSlugMap\n config: SanitizedConfig\n jsonSchema: JSONSchema4\n sanitizedPluginConfig: SanitizedEcommercePluginConfig\n}): JSONSchema4 => {\n if (!jsonSchema.properties) {\n jsonSchema.properties = {}\n }\n\n if (Array.isArray(jsonSchema.required)) {\n jsonSchema.required.push('ecommerce')\n }\n\n const requiredCollectionProperties: string[] = []\n const propertiesMap = new Map<string, { $ref: string }>()\n\n Object.entries(collectionSlugMap).forEach(([key, slug]) => {\n propertiesMap.set(key, { $ref: `#/definitions/${slug}` })\n\n requiredCollectionProperties.push(slug)\n })\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/pushTypeScriptProperties.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { SanitizedConfig } from 'payload'\n\nimport type { CollectionSlugMap, SanitizedEcommercePluginConfig } from '../types/index.js'\n\nexport const pushTypeScriptProperties = ({\n collectionSlugMap,\n jsonSchema,\n}: {\n collectionSlugMap: CollectionSlugMap\n config: SanitizedConfig\n jsonSchema: JSONSchema4\n sanitizedPluginConfig: SanitizedEcommercePluginConfig\n}): JSONSchema4 => {\n if (!jsonSchema.properties) {\n jsonSchema.properties = {}\n }\n\n if (Array.isArray(jsonSchema.required)) {\n jsonSchema.required.push('ecommerce')\n }\n\n const requiredCollectionProperties: string[] = []\n const propertiesMap = new Map<string, { $ref: string }>()\n\n Object.entries(collectionSlugMap).forEach(([key, slug]) => {\n propertiesMap.set(key, { $ref: `#/definitions/${slug}` })\n\n requiredCollectionProperties.push(slug)\n })\n\n jsonSchema.properties.ecommerce = {\n type: 'object',\n additionalProperties: false,\n description: 'Generated by the Payload Ecommerce plugin',\n properties: {\n collections: {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...Object.fromEntries(propertiesMap),\n },\n required: requiredCollectionProperties,\n },\n },\n required: ['collections'],\n }\n\n return jsonSchema\n}\n"],"names":["pushTypeScriptProperties","collectionSlugMap","jsonSchema","properties","Array","isArray","required","push","requiredCollectionProperties","propertiesMap","Map","Object","entries","forEach","key","slug","set","$ref","ecommerce","type","additionalProperties","description","collections","fromEntries"],"mappings":"AAMA,OAAO,MAAMA,2BAA2B,CAAC,EACvCC,iBAAiB,EACjBC,UAAU,EAMX;IACC,IAAI,CAACA,WAAWC,UAAU,EAAE;QAC1BD,WAAWC,UAAU,GAAG,CAAC;IAC3B;IAEA,IAAIC,MAAMC,OAAO,CAACH,WAAWI,QAAQ,GAAG;QACtCJ,WAAWI,QAAQ,CAACC,IAAI,CAAC;IAC3B;IAEA,MAAMC,+BAAyC,EAAE;IACjD,MAAMC,gBAAgB,IAAIC;IAE1BC,OAAOC,OAAO,CAACX,mBAAmBY,OAAO,CAAC,CAAC,CAACC,KAAKC,KAAK;QACpDN,cAAcO,GAAG,CAACF,KAAK;YAAEG,MAAM,CAAC,cAAc,EAAEF,MAAM;QAAC;QAEvDP,6BAA6BD,IAAI,CAACQ;IACpC;IAEAb,WAAWC,UAAU,CAACe,SAAS,GAAG;QAChCC,MAAM;QACNC,sBAAsB;QACtBC,aAAa;QACblB,YAAY;YACVmB,aAAa;gBACXH,MAAM;gBACNC,sBAAsB;gBACtBjB,YAAY;oBACV,GAAGQ,OAAOY,WAAW,CAACd,cAAc;gBACtC;gBACAH,UAAUE;YACZ;QACF;QACAF,UAAU;YAAC;SAAc;IAC3B;IAEA,OAAOJ;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-ecommerce",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.58.0-canary.4",
|
|
4
4
|
"description": "Ecommerce plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"default": "./dist/index.js"
|
|
33
33
|
},
|
|
34
34
|
"./types": {
|
|
35
|
-
"import": "./dist/exports/types
|
|
36
|
-
"types": "./dist/exports/types
|
|
37
|
-
"default": "./dist/exports/types
|
|
35
|
+
"import": "./dist/exports/types.js",
|
|
36
|
+
"types": "./dist/exports/types.d.ts",
|
|
37
|
+
"default": "./dist/exports/types.js"
|
|
38
38
|
},
|
|
39
39
|
"./payments/stripe": {
|
|
40
40
|
"import": "./dist/exports/payments/stripe.js",
|
|
@@ -69,22 +69,22 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"qs-esm": "7.0.2",
|
|
72
|
-
"@payloadcms/
|
|
73
|
-
"@payloadcms/
|
|
72
|
+
"@payloadcms/translations": "3.58.0-canary.4",
|
|
73
|
+
"@payloadcms/ui": "3.58.0-canary.4"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/json-schema": "7.0.15",
|
|
77
77
|
"@types/react": "19.1.0",
|
|
78
78
|
"@types/react-dom": "19.1.2",
|
|
79
79
|
"stripe": "18.3.0",
|
|
80
|
-
"@payloadcms/
|
|
81
|
-
"
|
|
82
|
-
"
|
|
80
|
+
"@payloadcms/next": "3.58.0-canary.4",
|
|
81
|
+
"payload": "3.58.0-canary.4",
|
|
82
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
86
86
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
87
|
-
"payload": "3.
|
|
87
|
+
"payload": "3.58.0-canary.4"
|
|
88
88
|
},
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"registry": "https://registry.npmjs.org/"
|