@sentecacommerce-theme/lib 0.12.26 → 0.12.30
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/cjs/analytics/Releva/api/query/useRelevaQuery.js +4 -2
- package/dist/cjs/analytics/Releva/api/query/useRelevaQuery.js.map +1 -1
- package/dist/cjs/analytics/Releva/hooks/useRelevaData.js +2 -2
- package/dist/cjs/analytics/Releva/hooks/useRelevaData.js.map +1 -1
- package/dist/cjs/analytics/Releva/useReleva.js +8 -1
- package/dist/cjs/analytics/Releva/useReleva.js.map +1 -1
- package/dist/cjs/cms/api/queries/index.js +16 -0
- package/dist/cjs/cms/api/queries/index.js.map +1 -1
- package/dist/cjs/cms/api/queries/keys.js +15 -1
- package/dist/cjs/cms/api/queries/keys.js.map +1 -1
- package/dist/cjs/cms/api/queries/useCMSContentListQuery.js +64 -0
- package/dist/cjs/cms/api/queries/useCMSContentListQuery.js.map +1 -0
- package/dist/cjs/cms/api/queries/useCMSContentQuery.js +54 -0
- package/dist/cjs/cms/api/queries/useCMSContentQuery.js.map +1 -0
- package/dist/cjs/cms/hooks/index.js +24 -0
- package/dist/cjs/cms/hooks/index.js.map +1 -1
- package/dist/cjs/{hooks/cms-content-hooks/useCmsContent/index.js → cms/hooks/useCmsContent.js} +6 -8
- package/dist/cjs/cms/hooks/useCmsContent.js.map +1 -0
- package/dist/cjs/{hooks/cms-content-hooks/useCmsContentList/index.js → cms/hooks/useCmsContentList.js} +5 -5
- package/dist/cjs/cms/hooks/useCmsContentList.js.map +1 -0
- package/dist/cjs/{hooks/cms-content-hooks/useContentCategoriesMap/index.js → cms/hooks/useContentCategoriesMap.js} +1 -1
- package/dist/cjs/cms/hooks/useContentCategoriesMap.js.map +1 -0
- package/dist/cjs/cms/ssr/fetchPagePaths.js.map +1 -1
- package/dist/cjs/cms/ssr/index.js +16 -0
- package/dist/cjs/cms/ssr/index.js.map +1 -1
- package/dist/cjs/cms/ssr/prefetchCmsContent.js +78 -0
- package/dist/cjs/cms/ssr/prefetchCmsContent.js.map +1 -0
- package/dist/cjs/cms/ssr/prefetchCmsContentList.js +85 -0
- package/dist/cjs/cms/ssr/prefetchCmsContentList.js.map +1 -0
- package/dist/cjs/cms/utils/getCMSContentListFilter.js +16 -0
- package/dist/cjs/cms/utils/getCMSContentListFilter.js.map +1 -0
- package/dist/cjs/cms/utils/index.js +8 -0
- package/dist/cjs/cms/utils/index.js.map +1 -1
- package/dist/cjs/config/SentecaProvider.js.map +1 -1
- package/dist/cjs/contexts/CheckoutForm/hooks/useBilling/index.js +4 -2
- package/dist/cjs/contexts/CheckoutForm/hooks/useBilling/index.js.map +1 -1
- package/dist/cjs/contexts/CheckoutForm/hooks/useShipping/index.js +8 -6
- package/dist/cjs/contexts/CheckoutForm/hooks/useShipping/index.js.map +1 -1
- package/dist/cjs/contexts/CheckoutForm/index.js +16 -9
- package/dist/cjs/contexts/CheckoutForm/index.js.map +1 -1
- package/dist/cjs/contexts/CheckoutForm/utils/validateBillingAddress.js +1 -2
- package/dist/cjs/contexts/CheckoutForm/utils/validateBillingAddress.js.map +1 -1
- package/dist/cjs/contexts/CheckoutForm/utils/validateShipping.js +28 -21
- package/dist/cjs/contexts/CheckoutForm/utils/validateShipping.js.map +1 -1
- package/dist/cjs/hooks/addresses-hooks/useAddressForm/index.js +4 -2
- package/dist/cjs/hooks/addresses-hooks/useAddressForm/index.js.map +1 -1
- package/dist/cjs/hooks/order-hooks/useOrder/index.js +12 -1
- package/dist/cjs/hooks/order-hooks/useOrder/index.js.map +1 -1
- package/dist/cjs/hooks/useAggregateResult/index.js +0 -4
- package/dist/cjs/hooks/useAggregateResult/index.js.map +1 -1
- package/dist/cjs/hooks/useCheckoutShippingModule/index.js +6 -1
- package/dist/cjs/hooks/useCheckoutShippingModule/index.js.map +1 -1
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/seo/api/ssr/getCanonicalUrl.js +27 -0
- package/dist/cjs/seo/api/ssr/getCanonicalUrl.js.map +1 -0
- package/dist/cjs/seo/api/ssr/index.js +8 -0
- package/dist/cjs/seo/api/ssr/index.js.map +1 -1
- package/dist/cjs/user/api/index.js +8 -0
- package/dist/cjs/user/api/index.js.map +1 -1
- package/dist/cjs/user/api/utils/generateAnonymousToken.js +48 -0
- package/dist/cjs/user/api/utils/generateAnonymousToken.js.map +1 -0
- package/dist/cjs/user/api/utils/index.js +8 -0
- package/dist/cjs/user/api/utils/index.js.map +1 -1
- package/dist/cjs/user/index.js +8 -0
- package/dist/cjs/user/index.js.map +1 -1
- package/dist/esm/analytics/Releva/api/query/useRelevaQuery.js +4 -2
- package/dist/esm/analytics/Releva/api/query/useRelevaQuery.js.map +1 -1
- package/dist/esm/analytics/Releva/hooks/useRelevaData.js +2 -2
- package/dist/esm/analytics/Releva/hooks/useRelevaData.js.map +1 -1
- package/dist/esm/analytics/Releva/useReleva.js +8 -2
- package/dist/esm/analytics/Releva/useReleva.js.map +1 -1
- package/dist/esm/cms/api/queries/index.js +2 -0
- package/dist/esm/cms/api/queries/index.js.map +1 -1
- package/dist/esm/cms/api/queries/keys.js +5 -0
- package/dist/esm/cms/api/queries/keys.js.map +1 -1
- package/dist/esm/cms/api/queries/useCMSContentListQuery.js +31 -0
- package/dist/esm/cms/api/queries/useCMSContentListQuery.js.map +1 -0
- package/dist/esm/cms/api/queries/useCMSContentQuery.js +17 -0
- package/dist/esm/cms/api/queries/useCMSContentQuery.js.map +1 -0
- package/dist/esm/cms/hooks/index.js +3 -0
- package/dist/esm/cms/hooks/index.js.map +1 -1
- package/dist/esm/{hooks/cms-content-hooks/useCmsContent/index.js → cms/hooks/useCmsContent.js} +6 -8
- package/dist/esm/cms/hooks/useCmsContent.js.map +1 -0
- package/dist/esm/{hooks/cms-content-hooks/useCmsContentList/index.js → cms/hooks/useCmsContentList.js} +5 -5
- package/dist/esm/cms/hooks/useCmsContentList.js.map +1 -0
- package/dist/esm/{hooks/cms-content-hooks/useContentCategoriesMap/index.js → cms/hooks/useContentCategoriesMap.js} +1 -1
- package/dist/esm/cms/hooks/useContentCategoriesMap.js.map +1 -0
- package/dist/esm/cms/ssr/fetchPagePaths.js.map +1 -1
- package/dist/esm/cms/ssr/index.js +2 -0
- package/dist/esm/cms/ssr/index.js.map +1 -1
- package/dist/esm/cms/ssr/prefetchCmsContent.js +30 -0
- package/dist/esm/cms/ssr/prefetchCmsContent.js.map +1 -0
- package/dist/esm/cms/ssr/prefetchCmsContentList.js +32 -0
- package/dist/esm/cms/ssr/prefetchCmsContentList.js.map +1 -0
- package/dist/esm/cms/utils/getCMSContentListFilter.js +9 -0
- package/dist/esm/cms/utils/getCMSContentListFilter.js.map +1 -0
- package/dist/esm/cms/utils/index.js +1 -0
- package/dist/esm/cms/utils/index.js.map +1 -1
- package/dist/esm/config/SentecaProvider.js.map +1 -1
- package/dist/esm/contexts/CheckoutForm/hooks/useBilling/index.js +4 -2
- package/dist/esm/contexts/CheckoutForm/hooks/useBilling/index.js.map +1 -1
- package/dist/esm/contexts/CheckoutForm/hooks/useShipping/index.js +8 -6
- package/dist/esm/contexts/CheckoutForm/hooks/useShipping/index.js.map +1 -1
- package/dist/esm/contexts/CheckoutForm/index.js +13 -9
- package/dist/esm/contexts/CheckoutForm/index.js.map +1 -1
- package/dist/esm/contexts/CheckoutForm/utils/validateBillingAddress.js +1 -2
- package/dist/esm/contexts/CheckoutForm/utils/validateBillingAddress.js.map +1 -1
- package/dist/esm/contexts/CheckoutForm/utils/validateShipping.js +25 -18
- package/dist/esm/contexts/CheckoutForm/utils/validateShipping.js.map +1 -1
- package/dist/esm/hooks/addresses-hooks/useAddressForm/index.js +3 -2
- package/dist/esm/hooks/addresses-hooks/useAddressForm/index.js.map +1 -1
- package/dist/esm/hooks/order-hooks/useOrder/index.js +10 -1
- package/dist/esm/hooks/order-hooks/useOrder/index.js.map +1 -1
- package/dist/esm/hooks/useAggregateResult/index.js +0 -2
- package/dist/esm/hooks/useAggregateResult/index.js.map +1 -1
- package/dist/esm/hooks/useCheckoutShippingModule/index.js +6 -1
- package/dist/esm/hooks/useCheckoutShippingModule/index.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/seo/api/ssr/getCanonicalUrl.js +18 -0
- package/dist/esm/seo/api/ssr/getCanonicalUrl.js.map +1 -0
- package/dist/esm/seo/api/ssr/index.js +1 -0
- package/dist/esm/seo/api/ssr/index.js.map +1 -1
- package/dist/esm/user/api/index.js +1 -0
- package/dist/esm/user/api/index.js.map +1 -1
- package/dist/esm/user/api/utils/generateAnonymousToken.js +23 -0
- package/dist/esm/user/api/utils/generateAnonymousToken.js.map +1 -0
- package/dist/esm/user/api/utils/index.js +1 -0
- package/dist/esm/user/api/utils/index.js.map +1 -1
- package/dist/esm/user/index.js +1 -0
- package/dist/esm/user/index.js.map +1 -1
- package/dist/types/analytics/Releva/api/query/useRelevaQuery.d.ts +1 -1
- package/dist/types/analytics/Releva/hooks/useRelevaData.d.ts +1 -1
- package/dist/types/cms/api/queries/index.d.ts +2 -0
- package/dist/types/cms/api/queries/keys.d.ts +5 -1
- package/dist/types/cms/api/queries/useCMSContentListQuery.d.ts +15 -0
- package/dist/types/cms/api/queries/useCMSContentQuery.d.ts +1 -0
- package/dist/types/cms/hooks/index.d.ts +3 -0
- package/dist/types/{hooks/cms-content-hooks/useCmsContent/index.d.ts → cms/hooks/useCmsContent.d.ts} +0 -0
- package/dist/types/{hooks/cms-content-hooks/useCmsContentList/index.d.ts → cms/hooks/useCmsContentList.d.ts} +1 -1
- package/dist/types/{hooks/cms-content-hooks/useContentCategoriesMap/index.d.ts → cms/hooks/useContentCategoriesMap.d.ts} +0 -0
- package/dist/types/cms/ssr/fetchPagePaths.d.ts +1 -1
- package/dist/types/cms/ssr/index.d.ts +2 -0
- package/dist/types/cms/ssr/prefetchCmsContent.d.ts +5 -0
- package/dist/types/cms/ssr/prefetchCmsContentList.d.ts +3 -0
- package/dist/types/cms/utils/getCMSContentListFilter.d.ts +1 -0
- package/dist/types/cms/utils/index.d.ts +1 -0
- package/dist/types/config/SentecaProvider.d.ts +1 -0
- package/dist/types/contexts/CheckoutForm/hooks/useBilling/index.d.ts +4 -2
- package/dist/types/contexts/CheckoutForm/hooks/useShipping/index.d.ts +3 -1
- package/dist/types/contexts/CheckoutForm/index.d.ts +4 -1
- package/dist/types/contexts/CheckoutForm/utils/validateBillingAddress.d.ts +2 -2
- package/dist/types/contexts/CheckoutForm/utils/validateShipping.d.ts +1 -1
- package/dist/types/hooks/addresses-hooks/useAddressForm/index.d.ts +2 -1
- package/dist/types/hooks/order-hooks/useOrder/index.d.ts +7 -1
- package/dist/types/hooks/useAggregateResult/index.d.ts +2 -2
- package/dist/types/hooks/useCheckoutShippingModule/index.d.ts +2 -2
- package/dist/types/index.d.ts +0 -2
- package/dist/types/seo/api/ssr/getCanonicalUrl.d.ts +3 -0
- package/dist/types/seo/api/ssr/index.d.ts +1 -0
- package/dist/types/user/api/index.d.ts +1 -0
- package/dist/types/user/api/utils/generateAnonymousToken.d.ts +1 -0
- package/dist/types/user/api/utils/index.d.ts +1 -0
- package/dist/types/user/index.d.ts +1 -0
- package/package.json +3 -3
- package/dist/cjs/api/cmsContentApi/index.js +0 -325
- package/dist/cjs/api/cmsContentApi/index.js.map +0 -1
- package/dist/cjs/hooks/cms-content-hooks/index.js +0 -28
- package/dist/cjs/hooks/cms-content-hooks/index.js.map +0 -1
- package/dist/cjs/hooks/cms-content-hooks/useCmsContent/index.js.map +0 -1
- package/dist/cjs/hooks/cms-content-hooks/useCmsContentList/index.js.map +0 -1
- package/dist/cjs/hooks/cms-content-hooks/useContentCategoriesMap/index.js.map +0 -1
- package/dist/esm/api/cmsContentApi/index.js +0 -161
- package/dist/esm/api/cmsContentApi/index.js.map +0 -1
- package/dist/esm/hooks/cms-content-hooks/index.js +0 -4
- package/dist/esm/hooks/cms-content-hooks/index.js.map +0 -1
- package/dist/esm/hooks/cms-content-hooks/useCmsContent/index.js.map +0 -1
- package/dist/esm/hooks/cms-content-hooks/useCmsContentList/index.js.map +0 -1
- package/dist/esm/hooks/cms-content-hooks/useContentCategoriesMap/index.js.map +0 -1
- package/dist/types/api/cmsContentApi/index.d.ts +0 -37
- package/dist/types/hooks/cms-content-hooks/index.d.ts +0 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/hooks/addresses-hooks/useAddressForm/index.tsx"],"names":["React","useCallback","useEffect","useMemo","useState","addressesApi","myCartApi","validateShipping","defaultShippingValidations","useErrors","Couriers","AddressFormContext","createContext","AddressFormContextProvider","children","address","currentAddress","onSuccess","validations","errorLabels","emptyAddress","_id","createdAt","Date","now","updatedAt","setAddress","isSubmitting","setIsSubmitting","moduleData","setModuleData","addNewAddress","error","addNewError","useAdd","updateAddress","updateError","useUpdate","data","moduleTypesRaw","isLoading","isModuleTypesLoading","useGetAllShippingMethods","selectModule","moduleKey","methodKey","setModuleAddressData","key","value","formatMethod","method","select","addressErrors","modules","platformMethods","platformShippingMethods","map","merchantMethods","merchantsShippingMethods","methods","flat","result","reduce","current","onChange","name","addNewErrors","updateErrors","errors","hasErrors","Boolean","Object","keys","length","handleSubmit","e","preventDefault","id","dto","undefined","state","formKey","addressState","setAddressState","onInputChange","isValid","useAddressForm","context","useContext","Error"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,OAAxC,EAAiDC,QAAjD,QAAiE,OAAjE;AAMA,SAASC,YAAT,QAA6B,2BAA7B;AACA,SAASC,SAAT,QAA0B,wBAA1B;AACA,SACEC,gBADF,EAEEC,0BAFF,QAIO,sCAJP;AAMA,SAASC,SAAT,QAA6C,sBAA7C;AAEA,WAAYC,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,KAAAA,Q;;AAiCZ,IAAMC,kBAAkB,gBAAGX,KAAK,CAACY,aAAN,CACzB,EADyB,CAA3B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7E,OAAO,CAAC,MAA+B;AAAA;;AACnD,WAAO;AACL8E,MAAAA,OAAO,GAAKpD,UAAL,oBAAKA,UAAU,CAAEe,SAAjB,WAA8Bf,UAA9B,6CAA8BA,UAAU,CAAEA,UAA1C,qBAA8B,sBAAwBgB,SAAtD,CADF;AAELQ,MAAAA,OAFK;AAGLb,MAAAA,SAHK;AAIL0C,MAAAA,YAAY,EAAEnE,OAJT;AAKLoE,MAAAA,eAAe,EAAEzD,UALZ;AAML0D,MAAAA,aAAa,EAAEpB,QANV;AAOLnC,MAAAA,UAPK;AAQLiB,MAAAA,oBARK;AASLsB,MAAAA,MAAM,EAAEzC,YAAY,GAAGyC,MAAH,GAAY,EAT3B;AAULzC,MAAAA,YAVK;AAWL0D,MAAAA,OAAO,EAAE,CAAChB;AAXL,KAAP;AAaD,GAdoB,EAclB,CACDxC,UADC,EAEDd,OAFC,EAGDyB,SAHC,EAIDa,OAJC,EAKDP,oBALC,EAMDkB,QANC,EAODrC,YAPC,EAQDyC,MARC,EASDC,SATC,CAdkB,CAArB;AA0BA,sBACE,oBAAC,kBAAD,CAAoB,QAApB;AAA6B,IAAA,KAAK,EAAEW;AAApC,kBACE;AAAM,IAAA,QAAQ,EAAEN,YAAhB;AAA8B,IAAA,UAAU;AAAxC,KACG5D,QADH,CADF,CADF;AAOD,CAnNM;AAqNP,OAAO,IAAMwE,cAAc,GAAG,MAAM;AAClC,MAAMC,OAAO,GAAGvF,KAAK,CAACwF,UAAN,CAAiB7E,kBAAjB,CAAhB;;AAEA,MAAI,CAAC4E,OAAL,EAAc;AACZ,UAAM,IAAIE,KAAJ,CACJ,iEADI,CAAN;AAGD;;AAED,SAAOF,OAAP;AACD,CAVM","sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n AddressModuleDataDTO,\n ShippingMethodDTO,\n AddressDTO,\n} from '@sentecacommerce/sdk'\nimport { addressesApi } from '../../../api/addressesApi'\nimport { myCartApi } from '../../../api/myCartApi'\nimport {\n validateShipping,\n defaultShippingValidations,\n ShippingValidationsType,\n} from '../../../contexts/CheckoutForm/utils'\nimport { ShippingFormErrorLabels } from '../../../contexts/CheckoutForm'\nimport { useErrors, DefaultFormErrors } from '../../error-handling'\n\nexport enum Couriers {\n 'Speedy' = 'Speedy',\n 'Econt' = 'Econt',\n 'Evropat' = 'Evropat',\n}\n\nexport type AddressFormModule = {\n methods: {\n key?: string\n select: () => void\n }[]\n}\n\ntype Modules = {\n [key in Couriers]: AddressFormModule\n}\n\ntype AddressFormContextValue = {\n formKey: string\n modules: Modules\n isLoading: boolean\n addressState?: AddressDTO\n setAddressState: React.Dispatch<AddressDTO>\n onInputChange: (name: string, value: any) => void\n moduleData?: AddressModuleDataDTO\n setModuleAddressData: (key: string, value: any) => void\n isSubmitting: boolean\n isValid: boolean\n errors: {\n [key: string]: string | undefined\n }\n}\n\nconst AddressFormContext = React.createContext<AddressFormContextValue>(\n {} as any\n)\n\nexport type AddressFormLabelsType = ShippingFormErrorLabels & DefaultFormErrors\n\nexport const AddressFormContextProvider = ({\n children,\n address: currentAddress,\n onSuccess,\n validations = defaultShippingValidations,\n errorLabels,\n}: {\n children: JSX.Element | JSX.Element[]\n address?: AddressDTO\n onSuccess: () => void\n validations?: ShippingValidationsType\n errorLabels: AddressFormLabelsType\n}) => {\n const emptyAddress: AddressDTO = {\n _id: currentAddress?._id || '',\n createdAt: Date.now(),\n updatedAt: Date.now(),\n }\n \n const [address, setAddress] = useState(currentAddress || emptyAddress)\n\n const [isSubmitting, setIsSubmitting] = useState(false)\n\n const [moduleData, setModuleData] = useState(currentAddress?.moduleData?.[0])\n\n const [addNewAddress, { error: addNewError }] = addressesApi.useAdd({\n onSuccess,\n })\n const [updateAddress, { error: updateError }] = addressesApi.useUpdate(\n onSuccess\n )\n\n const {\n data: moduleTypesRaw,\n isLoading: isModuleTypesLoading,\n } = myCartApi.useGetAllShippingMethods()\n\n const isLoading = isModuleTypesLoading\n\n // set initial data\n useEffect(() => {\n if (!address && currentAddress) {\n setAddress(currentAddress)\n setModuleData(currentAddress.moduleData?.[0])\n }\n }, [address, currentAddress])\n\n const selectModule = (moduleKey: string, methodKey: string) => {\n setModuleData({ moduleKey, moduleData: { methodKey } })\n }\n\n const setModuleAddressData = useCallback(\n (key: string, value: any) => {\n if (!moduleData) return\n\n const data = { ...moduleData }\n\n if (!data.moduleData) data.moduleData = {}\n\n data.moduleData.address = {\n ...(data.moduleData.address || {}),\n [key]: value,\n }\n\n setModuleData(data)\n },\n [moduleData]\n )\n\n const formatMethod = useCallback((method: ShippingMethodDTO) => {\n return {\n moduleKey: method.moduleKey,\n select: () =>\n selectModule(method.moduleKey as string, method.methodKey as string),\n methodKey: method.methodKey,\n }\n }, [])\n\n const addressErrors = useMemo(() => {\n return validateShipping(\n address,\n moduleData,\n errorLabels as any,\n validations\n )\n }, [address, moduleData, errorLabels, validations])\n\n /**\n * Format all platform and merchant modules\n */\n const modules = useMemo((): Modules => {\n const platformMethods =\n moduleTypesRaw?.platformShippingMethods?.map?.(formatMethod) || []\n\n const merchantMethods =\n moduleTypesRaw?.merchantsShippingMethods?.map?.((data) => {\n return data?.methods?.map?.(formatMethod)\n }) || []\n\n const data = [...platformMethods, ...merchantMethods.flat()]\n\n const result = data.reduce((current, method) => {\n return {\n ...current,\n [method.moduleKey as Couriers]: {\n methods: [\n ...(current[method.moduleKey as Couriers]?.methods || []),\n {\n key: method.methodKey,\n select: method.select,\n },\n ],\n },\n }\n }, {})\n\n return (result as unknown) as Modules\n }, [moduleTypesRaw, formatMethod])\n\n /**\n * On input change\n */\n const onChange = useCallback(\n (name: string, value: any) => {\n if (!address) return\n\n setAddress({\n ...address,\n [name]: value,\n })\n },\n [address]\n )\n\n const addNewErrors = useErrors<AddressFormLabelsType>(\n addNewError,\n errorLabels\n )\n const updateErrors = useErrors<AddressFormLabelsType>(\n updateError,\n errorLabels\n )\n\n const errors = useMemo(() => {\n return {\n ...(addressErrors || {}),\n ...(updateErrors || {}),\n ...(addNewErrors || {}),\n }\n }, [addressErrors, updateErrors, addNewErrors])\n\n const hasErrors = Boolean(Object.keys(errors).length)\n\n const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n setIsSubmitting(true)\n\n if (hasErrors) return\n\n if (currentAddress?._id) {\n updateAddress({\n id: currentAddress._id,\n dto: {\n ...address,\n moduleData: moduleData && [moduleData],\n },\n })\n\n return\n }\n\n addNewAddress({\n ...address,\n _id: undefined,\n moduleData: moduleData && [moduleData],\n })\n }\n\n const state = useMemo((): AddressFormContextValue => {\n return {\n formKey: `${moduleData?.moduleKey}-${moduleData?.moduleData?.methodKey}`,\n modules,\n isLoading,\n addressState: address,\n setAddressState: setAddress,\n onInputChange: onChange,\n moduleData,\n setModuleAddressData,\n errors: isSubmitting ? errors : {},\n isSubmitting,\n isValid: !hasErrors,\n }\n }, [\n moduleData,\n address,\n isLoading,\n modules,\n setModuleAddressData,\n onChange,\n isSubmitting,\n errors,\n hasErrors,\n ])\n\n return (\n <AddressFormContext.Provider value={state}>\n <form onSubmit={handleSubmit} noValidate>\n {children}\n </form>\n </AddressFormContext.Provider>\n )\n}\n\nexport const useAddressForm = () => {\n const context = React.useContext(AddressFormContext)\n\n if (!context) {\n throw new Error(\n 'useAddressForm must be used within a AddressFormContextProvider'\n )\n }\n\n return context\n}\n"],"file":"index.js"}
|
1
|
+
{"version":3,"sources":["../../../../../src/hooks/addresses-hooks/useAddressForm/index.tsx"],"names":["React","useCallback","useEffect","useMemo","useState","addressesApi","myCartApi","validateShipping","defaultShippingValidations","useErrors","Couriers","AddressFormContext","createContext","AddressFormContextProvider","children","address","currentAddress","onSuccess","validations","errorLabels","requiredFields","emptyAddress","_id","createdAt","Date","now","updatedAt","setAddress","isSubmitting","setIsSubmitting","moduleData","setModuleData","addNewAddress","error","addNewError","useAdd","updateAddress","updateError","useUpdate","data","moduleTypesRaw","isLoading","isModuleTypesLoading","useGetAllShippingMethods","selectModule","moduleKey","methodKey","setModuleAddressData","key","value","formatMethod","method","select","addressErrors","modules","platformMethods","platformShippingMethods","map","merchantMethods","merchantsShippingMethods","methods","flat","result","reduce","current","onChange","name","addNewErrors","updateErrors","errors","hasErrors","Boolean","Object","keys","length","handleSubmit","e","preventDefault","id","dto","undefined","state","formKey","addressState","setAddressState","onInputChange","isValid","useAddressForm","context","useContext","Error"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,OAAxC,EAAiDC,QAAjD,QAAiE,OAAjE;AAMA,SAASC,YAAT,QAA6B,2BAA7B;AACA,SAASC,SAAT,QAA0B,wBAA1B;AACA,SACEC,gBADF,EAEEC,0BAFF,QAIO,sCAJP;AAMA,SAASC,SAAT,QAA6C,sBAA7C;AAEA,WAAYC,QAAZ;;WAAYA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,KAAAA,Q;;AAiCZ,IAAMC,kBAAkB,gBAAGX,KAAK,CAACY,aAAN,CACzB,EADyB,CAA3B;AAMA,OAAO,IAAMC,0BAA0B,GAAG,UAcpC;AAAA;;AAAA,MAdqC;AACzCC,IAAAA,QADyC;AAEzCC,IAAAA,OAAO,EAAEC,cAFgC;AAGzCC,IAAAA,SAHyC;AAIzCC,IAAAA,WAAW,GAAGV,0BAJ2B;AAKzCW,IAAAA,WALyC;AAMzCC,IAAAA,cAAc,GAAG,CAAC,WAAD,EAAc,UAAd,EAA0B,OAA1B,EAAmC,aAAnC;AANwB,GAcrC;AACJ,MAAMC,YAAwB,GAAG;AAC/BC,IAAAA,GAAG,EAAE,CAAAN,cAAc,QAAd,YAAAA,cAAc,CAAEM,GAAhB,KAAuB,EADG;AAE/BC,IAAAA,SAAS,EAAEC,IAAI,CAACC,GAAL,EAFoB;AAG/BC,IAAAA,SAAS,EAAEF,IAAI,CAACC,GAAL;AAHoB,GAAjC;AAMA,MAAM,CAACV,OAAD,EAAUY,UAAV,IAAwBvB,QAAQ,CAACY,cAAc,IAAIK,Y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XL,KAAP;AAaD,GAdoB,EAclB,CACDxC,UADC,EAEDf,OAFC,EAGD0B,SAHC,EAIDa,OAJC,EAKDP,oBALC,EAMDkB,QANC,EAODrC,YAPC,EAQDyC,MARC,EASDC,SATC,CAdkB,CAArB;AA0BA,sBACE,oBAAC,kBAAD,CAAoB,QAApB;AAA6B,IAAA,KAAK,EAAEW;AAApC,kBACE;AAAM,IAAA,QAAQ,EAAEN,YAAhB;AAA8B,IAAA,UAAU;AAAxC,KACG7D,QADH,CADF,CADF;AAOD,CAtNM;AAwNP,OAAO,IAAMyE,cAAc,GAAG,MAAM;AAClC,MAAMC,OAAO,GAAGxF,KAAK,CAACyF,UAAN,CAAiB9E,kBAAjB,CAAhB;;AAEA,MAAI,CAAC6E,OAAL,EAAc;AACZ,UAAM,IAAIE,KAAJ,CACJ,iEADI,CAAN;AAGD;;AAED,SAAOF,OAAP;AACD,CAVM","sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n AddressModuleDataDTO,\n ShippingMethodDTO,\n AddressDTO,\n} from '@sentecacommerce/sdk'\nimport { addressesApi } from '../../../api/addressesApi'\nimport { myCartApi } from '../../../api/myCartApi'\nimport {\n validateShipping,\n defaultShippingValidations,\n ShippingValidationsType,\n} from '../../../contexts/CheckoutForm/utils'\nimport { ShippingFormErrorLabels } from '../../../contexts/CheckoutForm'\nimport { useErrors, DefaultFormErrors } from '../../error-handling'\n\nexport enum Couriers {\n 'Speedy' = 'Speedy',\n 'Econt' = 'Econt',\n 'Evropat' = 'Evropat',\n}\n\nexport type AddressFormModule = {\n methods: {\n key?: string\n select: () => void\n }[]\n}\n\ntype Modules = {\n [key in Couriers]: AddressFormModule\n}\n\ntype AddressFormContextValue = {\n formKey: string\n modules: Modules\n isLoading: boolean\n addressState?: AddressDTO\n setAddressState: React.Dispatch<AddressDTO>\n onInputChange: (name: string, value: any) => void\n moduleData?: AddressModuleDataDTO\n setModuleAddressData: (key: string, value: any) => void\n isSubmitting: boolean\n isValid: boolean\n errors: {\n [key: string]: string | undefined\n }\n}\n\nconst AddressFormContext = React.createContext<AddressFormContextValue>(\n {} as any\n)\n\nexport type AddressFormLabelsType = ShippingFormErrorLabels & DefaultFormErrors\n\nexport const AddressFormContextProvider = ({\n children,\n address: currentAddress,\n onSuccess,\n validations = defaultShippingValidations,\n errorLabels,\n requiredFields = ['firstName', 'lastName', 'email', 'phoneNumber'],\n}: {\n children: JSX.Element | JSX.Element[]\n address?: AddressDTO\n onSuccess: () => void\n validations?: ShippingValidationsType\n errorLabels: AddressFormLabelsType\n requiredFields?: string[]\n}) => {\n const emptyAddress: AddressDTO = {\n _id: currentAddress?._id || '',\n createdAt: Date.now(),\n updatedAt: Date.now(),\n }\n\n const [address, setAddress] = useState(currentAddress || emptyAddress)\n\n const [isSubmitting, setIsSubmitting] = useState(false)\n\n const [moduleData, setModuleData] = useState(currentAddress?.moduleData?.[0])\n\n const [addNewAddress, { error: addNewError }] = addressesApi.useAdd({\n onSuccess,\n })\n const [updateAddress, { error: updateError }] = addressesApi.useUpdate(\n onSuccess\n )\n\n const {\n data: moduleTypesRaw,\n isLoading: isModuleTypesLoading,\n } = myCartApi.useGetAllShippingMethods()\n\n const isLoading = isModuleTypesLoading\n\n // set initial data\n useEffect(() => {\n if (!address && currentAddress) {\n setAddress(currentAddress)\n setModuleData(currentAddress.moduleData?.[0])\n }\n }, [address, currentAddress])\n\n const selectModule = (moduleKey: string, methodKey: string) => {\n setModuleData({ moduleKey, moduleData: { methodKey } })\n }\n\n const setModuleAddressData = useCallback(\n (key: string, value: any) => {\n if (!moduleData) return\n\n const data = { ...moduleData }\n\n if (!data.moduleData) data.moduleData = {}\n\n data.moduleData.address = {\n ...(data.moduleData.address || {}),\n [key]: value,\n }\n\n setModuleData(data)\n },\n [moduleData]\n )\n\n const formatMethod = useCallback((method: ShippingMethodDTO) => {\n return {\n moduleKey: method.moduleKey,\n select: () =>\n selectModule(method.moduleKey as string, method.methodKey as string),\n methodKey: method.methodKey,\n }\n }, [])\n\n const addressErrors = useMemo(() => {\n return validateShipping(\n address,\n moduleData,\n errorLabels as any,\n validations,\n requiredFields\n )\n }, [address, moduleData, errorLabels, validations])\n\n /**\n * Format all platform and merchant modules\n */\n const modules = useMemo((): Modules => {\n const platformMethods =\n moduleTypesRaw?.platformShippingMethods?.map?.(formatMethod) || []\n\n const merchantMethods =\n moduleTypesRaw?.merchantsShippingMethods?.map?.((data) => {\n return data?.methods?.map?.(formatMethod)\n }) || []\n\n const data = [...platformMethods, ...merchantMethods.flat()]\n\n const result = data.reduce((current, method) => {\n return {\n ...current,\n [method.moduleKey as Couriers]: {\n methods: [\n ...(current[method.moduleKey as Couriers]?.methods || []),\n {\n key: method.methodKey,\n select: method.select,\n },\n ],\n },\n }\n }, {})\n\n return (result as unknown) as Modules\n }, [moduleTypesRaw, formatMethod])\n\n /**\n * On input change\n */\n const onChange = useCallback(\n (name: string, value: any) => {\n if (!address) return\n\n setAddress({\n ...address,\n [name]: value,\n })\n },\n [address]\n )\n\n const addNewErrors = useErrors<AddressFormLabelsType>(\n addNewError,\n errorLabels\n )\n const updateErrors = useErrors<AddressFormLabelsType>(\n updateError,\n errorLabels\n )\n\n const errors = useMemo(() => {\n return {\n ...(addressErrors || {}),\n ...(updateErrors || {}),\n ...(addNewErrors || {}),\n }\n }, [addressErrors, updateErrors, addNewErrors])\n\n const hasErrors = Boolean(Object.keys(errors).length)\n\n const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault()\n setIsSubmitting(true)\n\n if (hasErrors) return\n\n if (currentAddress?._id) {\n updateAddress({\n id: currentAddress._id,\n dto: {\n ...address,\n moduleData: moduleData && [moduleData],\n },\n })\n\n return\n }\n\n addNewAddress({\n ...address,\n _id: undefined,\n moduleData: moduleData && [moduleData],\n })\n }\n\n const state = useMemo((): AddressFormContextValue => {\n return {\n formKey: `${moduleData?.moduleKey}-${moduleData?.moduleData?.methodKey}`,\n modules,\n isLoading,\n addressState: address,\n setAddressState: setAddress,\n onInputChange: onChange,\n moduleData,\n setModuleAddressData,\n errors: isSubmitting ? errors : {},\n isSubmitting,\n isValid: !hasErrors,\n }\n }, [\n moduleData,\n address,\n isLoading,\n modules,\n setModuleAddressData,\n onChange,\n isSubmitting,\n errors,\n hasErrors,\n ])\n\n return (\n <AddressFormContext.Provider value={state}>\n <form onSubmit={handleSubmit} noValidate>\n {children}\n </form>\n </AddressFormContext.Provider>\n )\n}\n\nexport const useAddressForm = () => {\n const context = React.useContext(AddressFormContext)\n\n if (!context) {\n throw new Error(\n 'useAddressForm must be used within a AddressFormContextProvider'\n )\n }\n\n return context\n}\n"],"file":"index.js"}
|
@@ -1,4 +1,6 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
1
2
|
import React from 'react';
|
3
|
+
import { getTranslatableField } from '../../../index';
|
2
4
|
import { myOrdersApi } from '../../../api/myOrdersApi';
|
3
5
|
export var useOrder = (_ref) => {
|
4
6
|
var {
|
@@ -8,7 +10,7 @@ export var useOrder = (_ref) => {
|
|
8
10
|
var orderQuery = myOrdersApi.useGetById(id);
|
9
11
|
var order = data || orderQuery.data;
|
10
12
|
var result = React.useMemo(() => {
|
11
|
-
var _order$shippings, _shipping$deliveries, _shipping$deliveries$, _order$shippingAddres, _order$shippingAddres2, _order$shippingAddres3, _order$shippingAddres4, _order$shippingAddres5, _order$shippingAddres6, _order$lineItemsCount;
|
13
|
+
var _order$shippings, _shipping$deliveries, _shipping$deliveries$, _order$shippingAddres, _order$shippingAddres2, _order$shippingAddres3, _order$shippingAddres4, _order$shippingAddres5, _order$shippingAddres6, _order$lineItemsCount, _order$customLineItem;
|
12
14
|
|
13
15
|
var shipping = order == null ? void 0 : (_order$shippings = order.shippings) == null ? void 0 : _order$shippings[0];
|
14
16
|
var parcels = shipping == null ? void 0 : (_shipping$deliveries = shipping.deliveries) == null ? void 0 : (_shipping$deliveries$ = _shipping$deliveries[0]) == null ? void 0 : _shipping$deliveries$.parcels;
|
@@ -20,10 +22,17 @@ export var useOrder = (_ref) => {
|
|
20
22
|
orderRefNumber: order == null ? void 0 : order.orderRefNumber,
|
21
23
|
createdAt: order == null ? void 0 : order.createdAt,
|
22
24
|
discountCodes: mapDiscountCodes(order == null ? void 0 : order.discountCodes),
|
25
|
+
customLineItems: order == null ? void 0 : (_order$customLineItem = order.customLineItems) == null ? void 0 : _order$customLineItem.map(customLineItem => {
|
26
|
+
return _extends({}, customLineItem, {
|
27
|
+
name: getTranslatableField(customLineItem.name)
|
28
|
+
});
|
29
|
+
}),
|
30
|
+
shippingAddress: order == null ? void 0 : order.shippingAddress,
|
23
31
|
shippingMethod: {
|
24
32
|
isOffice: isShippingMethodOffice,
|
25
33
|
isAddress: isShippingMethodOffice ? false : true
|
26
34
|
},
|
35
|
+
billingAddress: order == null ? void 0 : order.billingAddress,
|
27
36
|
trackingData: mapTrackingData(parcels)
|
28
37
|
};
|
29
38
|
return orderData;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/hooks/order-hooks/useOrder/index.ts"],"names":["React","myOrdersApi","useOrder","data","id","orderQuery","useGetById","order","result","useMemo","shipping","shippings","parcels","deliveries","isShippingMethodOffice","Boolean","shippingAddress","moduleData","address","office","orderData","lineItems","lineItemsCount","status","orderRefNumber","createdAt","discountCodes","mapDiscountCodes","shippingMethod","isOffice","isAddress","
|
1
|
+
{"version":3,"sources":["../../../../../src/hooks/order-hooks/useOrder/index.ts"],"names":["React","getTranslatableField","myOrdersApi","useOrder","data","id","orderQuery","useGetById","order","result","useMemo","shipping","shippings","parcels","deliveries","isShippingMethodOffice","Boolean","shippingAddress","moduleData","address","office","orderData","lineItems","lineItemsCount","status","orderRefNumber","createdAt","discountCodes","mapDiscountCodes","customLineItems","map","customLineItem","name","shippingMethod","isOffice","isAddress","billingAddress","trackingData","mapTrackingData","parcel","courierName","provider","trackingId","trackingUrl","providerMeta","trackUrl","codes","codeNames","filter","code","discountCode","resource","value"],"mappings":";AAAA,OAAOA,KAAP,MAAk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AH,oBAAGA,KAAK,CAAEE,MAAP,CAAeC,IAAD,IAAUA,IAAI,CAACzB,MAAL,KAAgB,UAAxC,CAAlB;AAEA,SAAOuB,SAAP,oBAAOA,SAAS,CAAEjB,GAAX,CAAgBmB,IAAD,IAAU;AAC9B,WAAOA,IAAI,CAACC,YAAL,CAAkBC,QAAlB,CAA2BnB,IAA3B,CAAgC,CAAhC,EAAmCoB,KAA1C;AACD,GAFM,CAAP;AAGD","sourcesContent":["import React from 'react'\nimport {\n DiscountCodeInfoDTO,\n LineItemDTO,\n OrderDTO,\n OrderDTOStatusEnum,\n ShippingDeliveryParcelDTO,\n CustomLineItemDTO,\n AddressDTO,\n} from '@sentecacommerce/sdk'\n\nimport { getTranslatableField } from '../../../index'\nimport { myOrdersApi } from '../../../api/myOrdersApi'\n\ntype TrackingProp = {\n provider?: string\n trackingId?: string\n trackingUrl?: string\n}\n\nexport type MappedCustomLineItemDTO = CustomLineItemDTO & {\n name: string\n}\n\ntype UseOrderProps = {\n lineItems?: LineItemDTO[]\n lineItemsCount: number\n createdAt?: number\n orderRefNumber?: string\n status?: OrderDTOStatusEnum\n discountCodes?: string[]\n shippingMethod: {\n isOffice: boolean\n isAddress: boolean\n }\n trackingData: TrackingProp[]\n customLineItems?: MappedCustomLineItemDTO[]\n shippingAddress: AddressDTO\n billingAddress?: AddressDTO\n}\n\nexport const useOrder = ({\n data,\n id,\n}: {\n data?: OrderDTO\n id?: string\n}): UseOrderProps => {\n const orderQuery = myOrdersApi.useGetById(id)\n\n const order = data || orderQuery.data\n\n const result = React.useMemo(() => {\n const shipping = order?.shippings?.[0]\n const parcels = shipping?.deliveries?.[0]?.parcels\n\n const isShippingMethodOffice = Boolean(\n order?.shippingAddress?.moduleData?.[0]?.moduleData?.address?.office\n ?.address\n )\n\n const orderData: UseOrderProps = {\n lineItems: order?.lineItems,\n lineItemsCount: order?.lineItemsCount ?? 0,\n status: order?.status,\n orderRefNumber: order?.orderRefNumber,\n createdAt: order?.createdAt,\n discountCodes: mapDiscountCodes(order?.discountCodes),\n customLineItems: order?.customLineItems?.map((customLineItem) => {\n return {\n ...customLineItem,\n name: getTranslatableField(customLineItem.name),\n } as MappedCustomLineItemDTO\n }),\n shippingAddress: order?.shippingAddress as AddressDTO,\n\n shippingMethod: {\n isOffice: isShippingMethodOffice,\n isAddress: isShippingMethodOffice ? false : true,\n },\n billingAddress: order?.billingAddress,\n\n trackingData: mapTrackingData(parcels),\n }\n return orderData\n }, [order])\n\n return result\n}\n\nfunction mapTrackingData(parcels?: ShippingDeliveryParcelDTO[]) {\n return (\n parcels?.map((parcel) => {\n return {\n courierName: parcel?.moduleData?.trackingData?.provider,\n trackingId: parcel?.moduleData?.trackingData?.trackingId,\n trackingUrl: parcel?.moduleData?.providerMeta?.trackUrl,\n }\n }) || []\n )\n}\n\nfunction mapDiscountCodes(codes?: DiscountCodeInfoDTO[]) {\n const codeNames = codes?.filter((code) => code.status !== 'NotValid')\n\n return codeNames?.map((code) => {\n return code.discountCode.resource.name[0].value\n })\n}\n"],"file":"index.js"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import { createAggregateQuery, generateQueryFromRouter } from '../../utils';
|
3
|
-
import { TermAggregationResult } from '@sentecacommerce/sdk';
|
4
3
|
import { useRouter } from 'next/router';
|
5
4
|
import { useMemo } from 'react';
|
6
5
|
import { catalogApi } from '../../api/catalogApi';
|
@@ -11,7 +10,6 @@ var byOrder = (a, b) => {
|
|
11
10
|
return 0;
|
12
11
|
};
|
13
12
|
|
14
|
-
export { TermAggregationResult };
|
15
13
|
var operatorMap = {
|
16
14
|
ranges: 'range',
|
17
15
|
stats: 'range',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/useAggregateResult/index.ts"],"names":["createAggregateQuery","generateQueryFromRouter","
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useAggregateResult/index.ts"],"names":["createAggregateQuery","generateQueryFromRouter","useRouter","useMemo","catalogApi","byOrder","a","b","order","operatorMap","ranges","stats","terms","mapKey","r","type","key","from","to","filterByType","filters","filterName","includes","filter","useAggregateResult","aggregates","slug","predicate","query","router","transformedQuery","data","aggData","isLoading","isIdle","isFetching","useAggregate","result","sort","reduce","res","current","aggregationType","find","c","name","aggregationDefinition","split","selectedCount","results","acc","count","filterKey","selected","filterDefinition","concat","onClick","push","aggType","aggKey","aggOperator","label","component","items","clearAll","pathname"],"mappings":";AAAA,SACEA,oBADF,EAEEC,uBAFF,QAGO,aAHP;AAYA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,OAAT,QAAwB,OAAxB;AAEA,SAASC,UAAT,QAA2B,sBAA3B;;AAEA,IAAMC,OAAO,GAAG,CAACC,CAAD,EAASC,CAAT,KAAoB;AAClC,MAAID,CAAC,CAACE,KAAF,GAAUD,CAAC,CAACC,KAAhB,EAAuB,OAAO,CAAP;AAEvB,MAAIF,CAAC,CAACE,KAAF,GAAUD,CAAC,CAACC,KAAhB,EAAuB,OAAO,CAAC,CAAR;AAEvB,SAAO,CAAP;AACD,CAND;;AAoCA,IAAMC,WAAW,GAAG;AAClBC,EAAAA,MAAM,EAAE,OADU;AAElBC,EAAAA,KAAK,EAAE,OAFW;AAGlBC,EAAAA,KAAK,EAAE;AAHW,CAApB,C,CAMA;;AACA,IAAMC,MAAM,GAAG,CAACC,CAAD,EAASC,IAAT,KAAuB;AACpC,UAAQ,IAAR;AACE,SAAKA,IAAI,KAAK,OAAd;AACE,oBAAWD,CAAC,CAACE,GAAb;;AACF,SAAKD,IAAI,KAAK,QAAd;AACE,aAAUD,CAAC,CAACG,IAAZ,SAAoBH,CAAC,CAACI,EAAtB;;AACF;AACE,aAAOJ,CAAC,CAACE,GAAT;AANJ;AAQD,CATD;;AAWA,IAAMG,YAAY,GAAG,CACnBC,OADmB,EAEnBC,UAFmB,KAGhB;AACH,MAAI,CAACD,OAAL,EAAc;;AAEd,MAAI,OAAOA,OAAP,KAAmB,QAAv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EAAsBjB,CAAC,CAACgD,gBAAxB;AAFjB;AAFK,SAAZ,CANJ;AAaEvC,QAAAA,IAAI,EAAET,CAAC,CAACoC;AAbV,OADgB,CAAX,CAAP;AAiBD,KAhEY,EAgEV,EAhEU,CAAf;AAkEA,WAAOL,MAAP;AACD,GAtEmB,EAsEjB,CAACJ,SAAD,EAAYD,OAAZ,EAAqBP,UAArB,EAAiCC,IAAjC,EAAuCX,IAAvC,CAtEiB,CAApB;AAwEA,SAAO;AACLkB,IAAAA,SADK;AAELC,IAAAA,MAFK;AAGLH,IAAAA,IAHK;AAILI,IAAAA;AAJK,GAAP;AAMD,CAtGM","sourcesContent":["import {\n createAggregateQuery,\n generateQueryFromRouter,\n} from '../../utils'\nimport type {\n TermAggregation,\n StatAggregation,\n RangeAggregation,\n TermAggregationResult,\n StatAggregationResult,\n RangeAggregationResult,\n} from '@sentecacommerce/sdk'\nimport { useRouter } from 'next/router'\nimport { useMemo } from 'react'\nimport { FiltersQuery } from '../../listing/types'\nimport { catalogApi } from '../../api/catalogApi'\n\nconst byOrder = (a: any, b: any) => {\n if (a.order > b.order) return 1\n\n if (a.order < b.order) return -1\n\n return 0\n}\n\ntype AggregationType = TermAggregation | StatAggregation | RangeAggregation\n\nexport type AggregationTypes = 'ranges' | 'terms' | 'stats'\n\ntype AggregationDTO =\n | TermAggregationResult\n | StatAggregationResult\n | RangeAggregationResult\n\nexport type { TermAggregationResult }\n\nexport type FormattedAggregationResultType = {\n onClick: () => void\n selected: boolean\n data: AggregationDTO\n label?: string\n aggregationType?: AggregationTypes\n}\n\nexport type AggregateResultType = {\n name: string\n component: string\n items: FormattedAggregationResultType[]\n type: AggregationTypes\n selectedCount: number\n clearAll: () => void\n}\n\nconst operatorMap = {\n ranges: 'range',\n stats: 'range',\n terms: 'eq',\n}\n\n// TODO: Additional mappers later\nconst mapKey = (r: any, type: any) => {\n switch (true) {\n case type === 'terms':\n return `\"${r.key}\"`\n case type === 'ranges':\n return `${r.from},${r.to}`\n default:\n return r.key\n }\n}\n\nconst filterByType = (\n filters: string | string[] | undefined,\n filterName: string\n) => {\n if (!filters) return\n\n if (typeof filters === 'string') {\n if (filters.includes(filterName)) return\n\n return filters\n }\n\n return filters.filter((filter) => !filter.includes(filterName))\n}\n\nexport const useAggregateResult = (\n type: 'category' | 'brand' | 'search' | 'view',\n aggregates: any[],\n slug: string,\n predicate: string,\n query: FiltersQuery\n) => {\n const router = useRouter()\n\n const transformedQuery = generateQueryFromRouter(query)\n\n const {\n data: aggData,\n isLoading,\n isIdle,\n isFetching,\n } = catalogApi.useAggregate(\n type,\n aggregates,\n slug,\n predicate,\n transformedQuery\n )\n\n const data = useMemo(() => {\n if (isLoading || !aggData) return null\n\n const result = aggregates\n .sort(byOrder)\n .reduce<AggregateResultType[]>((res, a) => {\n const current = aggData[a.aggregationType].find(\n (c: AggregationType) =>\n c.name === a.aggregationDefinition.split(':')[0]\n )\n let selectedCount = 0\n const results = current.results.reduce<\n FormattedAggregationResultType[]\n >((acc: FormattedAggregationResultType[], r: AggregationDTO) => {\n if (r.count === 0) return acc\n const filterKey = mapKey(r, a.aggregationType)\n\n const selected = router.query?.filter?.includes(\n `${a.filterDefinition};${\n operatorMap[a.aggregationType]\n };${filterKey}`\n )\n ? true\n : false\n\n if (selected) selectedCount++\n\n return acc.concat([\n {\n data: r,\n selected,\n onClick: () => {\n router.push(\n createAggregateQuery(\n type,\n slug,\n {\n aggType: a.filterDefinition,\n aggKey: filterKey,\n aggOperator: operatorMap[a.aggregationType],\n },\n selected,\n router\n )\n )\n },\n },\n ])\n }, [])\n\n return res.concat([\n {\n name: a.label,\n component: a.component,\n items: results,\n selectedCount,\n clearAll: () =>\n router.push({\n pathname: router.pathname,\n query: {\n ...router.query,\n filter: filterByType(router.query.filter, a.filterDefinition),\n },\n }),\n type: a.aggregationType as AggregationTypes,\n },\n ])\n }, [])\n\n return result\n }, [isLoading, aggData, aggregates, slug, type])\n\n return {\n isLoading,\n isIdle,\n data,\n isFetching,\n }\n}\n"],"file":"index.js"}
|
@@ -1,12 +1,17 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import { useMemo } from 'react';
|
3
|
-
export var useCheckoutShippingModule = orderQuery
|
3
|
+
export var useCheckoutShippingModule = function useCheckoutShippingModule(orderQuery, isEnabled) {
|
4
|
+
if (isEnabled === void 0) {
|
5
|
+
isEnabled = true;
|
6
|
+
}
|
7
|
+
|
4
8
|
var {
|
5
9
|
data: cartData
|
6
10
|
} = orderQuery;
|
7
11
|
return useMemo(() => {
|
8
12
|
var _cartData$shippings;
|
9
13
|
|
14
|
+
if (!isEnabled) return;
|
10
15
|
var shipping = cartData == null ? void 0 : (_cartData$shippings = cartData.shippings) == null ? void 0 : _cartData$shippings[0];
|
11
16
|
return {
|
12
17
|
moduleKey: shipping == null ? void 0 : shipping.moduleKey,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/useCheckoutShippingModule/index.tsx"],"names":["useMemo","useCheckoutShippingModule","orderQuery","data","cartData","shipping","shippings","moduleKey","moduleData","methodKey","moduleMethodKey"],"mappings":";AACA,SAASA,OAAT,QAAwB,OAAxB;AAGA,OAAO,IAAMC,yBAAyB,
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useCheckoutShippingModule/index.tsx"],"names":["useMemo","useCheckoutShippingModule","orderQuery","isEnabled","data","cartData","shipping","shippings","moduleKey","moduleData","methodKey","moduleMethodKey"],"mappings":";AACA,SAASA,OAAT,QAAwB,OAAxB;AAGA,OAAO,IAAMC,yBAAyB,GAAG,SAA5BA,yBAA4B,CACvCC,UADuC,EAEvCC,SAFuC,EAGpB;AAAA,MADnBA,SACmB;AADnBA,IAAAA,SACmB,GADP,IACO;AAAA;;AACnB,MAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAAqBH,UAA3B;AAEA,SAAOF,OAAO,CAAC,MAAM;AAAA;;AACnB,QAAI,CAACG,SAAL,EAAgB;AAEhB,QAAMG,QAAQ,GAAGD,QAAH,2CAAGA,QAAQ,CAAEE,SAAb,qBAAG,oBAAsB,CAAtB,CAAjB;AAEA,WAAO;AACLC,MAAAA,SAAS,EAAEF,QAAF,oBAAEA,QAAQ,CAAEE,SADhB;AAELC,MAAAA,UAAU,eACLH,QADK,oBACLA,QAAQ,CAAEG,UADL;AAERC,QAAAA,SAAS,EAAEJ,QAAF,oBAAEA,QAAQ,CAAEK;AAFb;AAFL,KAAP;AAOD,GAZa,EAYX,CAACN,QAAD,CAZW,CAAd;AAaD,CAnBM","sourcesContent":["import { OrderDTO } from '@sentecacommerce/sdk'\nimport { useMemo } from 'react'\nimport { QueryResult } from 'react-query'\n\nexport const useCheckoutShippingModule = (\n orderQuery: QueryResult<OrderDTO, unknown>,\n isEnabled = true\n): ShippingModule => {\n const { data: cartData } = orderQuery\n\n return useMemo(() => {\n if (!isEnabled) return\n\n const shipping = cartData?.shippings?.[0]\n\n return {\n moduleKey: shipping?.moduleKey,\n moduleData: {\n ...shipping?.moduleData,\n methodKey: shipping?.moduleMethodKey,\n },\n }\n }, [cartData])\n}\n\nexport type ShippingModule =\n | {\n moduleKey?: string\n moduleData?: any\n }\n | undefined\n"],"file":"index.js"}
|
package/dist/esm/index.js
CHANGED
@@ -20,7 +20,6 @@ export * from './api/myShippingsSpeedyApi';
|
|
20
20
|
export * from './api/myOrdersApi';
|
21
21
|
export * from './api/myShippingsEcontApi';
|
22
22
|
export * from './api/myShippingsEvropatApi';
|
23
|
-
export * from './api/cmsContentApi';
|
24
23
|
export * from './api/citiesApi';
|
25
24
|
export * from './api/searchHistoryApi';
|
26
25
|
export * from './api/walletApi';
|
@@ -52,7 +51,6 @@ export * from './hooks/wishlist-hooks/useWishlist';
|
|
52
51
|
export * from './hooks/useCheckoutSummary';
|
53
52
|
export * from './hooks/usePrice';
|
54
53
|
export * from './hooks/wishlist-hooks';
|
55
|
-
export * from './hooks/cms-content-hooks';
|
56
54
|
export * from './hooks/labels';
|
57
55
|
export * from './hooks/checkout-hooks';
|
58
56
|
export * from './hooks/basket-hooks/useBasketTotalCount';
|
package/dist/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAd,C,CAEA;AACA;;AACA,cAAc,mBAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,mBAAd;AACA,cAAc,kBAAd;AACA,cAAc,qBAAd;AACA,cAAc,iBAAd;AACA,cAAc,gBAAd;AACA,cAAc,wBAAd;AACA,cAAc,oBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AACA,cAAc,4BAAd;AACA,cAAc,mBAAd;AACA,cAAc,2BAAd;AACA,cAAc,6BAAd;AACA,cAAc,
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAd,C,CAEA;AACA;;AACA,cAAc,mBAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,mBAAd;AACA,cAAc,kBAAd;AACA,cAAc,qBAAd;AACA,cAAc,iBAAd;AACA,cAAc,gBAAd;AACA,cAAc,wBAAd;AACA,cAAc,oBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AACA,cAAc,4BAAd;AACA,cAAc,mBAAd;AACA,cAAc,2BAAd;AACA,cAAc,6BAAd;AACA,cAAc,iBAAd;AACA,cAAc,wBAAd;AAEA,cAAc,iBAAd;AACA,cAAc,qCAAd;AAEA,cAAc,2BAAd,C,CACA;AAEA;;AACA,cAAc,oBAAd;AACA,cAAc,yBAAd;AACA,cAAc,+BAAd;AACA,cAAc,kCAAd,C,CAEA;;AACA,cAAc,cAAd,C,CAEA;;AACA,cAAc,qBAAd;AACA,cAAc,iBAAd;AACA,cAAc,oBAAd;AACA,cAAc,0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UAAd;AACA,cAAc,eAAd;AAEA,cAAc,oBAAd;AAEA,cAAc,QAAd;AACA,cAAc,WAAd;AACA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,QAAd,C,CAEA;;AACA,cAAc,QAAd,C,CAEA;;AACA,cAAc,MAAd;AAEA,cAAc,YAAd,C,CAEA;;AACA,cAAc,SAAd,C,CAEA;;AACA,cAAc,SAAd,C,CAEA;;AACA,cAAc,WAAd,C,CAEA;;AACA,cAAc,YAAd,C,CAEA;;AACA,cAAc,WAAd","sourcesContent":["export * from './dto'\n\n// API\n// export * from './api/myCart'\nexport * from './api/productsApi'\nexport * from './api/pagesApi'\nexport * from './api/usersApi'\nexport * from './api/profileApi'\nexport * from './api/wishlistApi'\nexport * from './api/addressesApi'\nexport * from './api/consentsApi'\nexport * from './api/catalogApi'\nexport * from './api/categoriesApi'\nexport * from './api/brandsApi'\nexport * from './api/viewsApi'\nexport * from './api/notificationsApi'\nexport * from './api/companiesApi'\nexport * from './api/vouchersApi'\nexport * from './api/myCartApi'\nexport * from './api/myShippingsSpeedyApi'\nexport * from './api/myOrdersApi'\nexport * from './api/myShippingsEcontApi'\nexport * from './api/myShippingsEvropatApi'\nexport * from './api/citiesApi'\nexport * from './api/searchHistoryApi'\n\nexport * from './api/walletApi'\nexport * from './api/myShippingsPickupFromStoreAPI'\n\nexport * from './api/myPaymentsBoricaApi'\n// Components\n\n// Contexts\nexport * from './contexts/Strings'\nexport * from './contexts/CheckoutForm'\nexport * from './contexts/CheckoutForm/utils'\nexport * from './contexts/CustomProductProvider'\n\n// Components\nexport * from './components'\n\n// Hooks\nexport * from './hooks/useCarousel'\nexport * from './hooks/useZoom'\nexport * from './hooks/useProduct'\nexport * from './hooks/useCatalogResult'\nexport * from './hooks/useCopyToClipboard'\nexport * from './hooks/useVouchers'\nexport * from './hooks/usePromoCode'\nexport * from './hooks/useCheckoutDelivery'\nexport * from './hooks/useCheckoutPayment'\nexport * from './hooks/useCheckoutShippingAddress'\nexport * from './hooks/useCheckoutBillingAddress'\nexport * from './hooks/useCheckoutSubmit'\nexport * from './hooks/useCheckoutDiscountCode'\nexport * from './hooks/wishlist-hooks/useWishlist'\nexport * from './hooks/useCheckoutSummary'\nexport * from './hooks/usePrice'\nexport * from './hooks/wishlist-hooks'\nexport * from './hooks/labels'\nexport * from './hooks/checkout-hooks'\n\nexport * from './hooks/basket-hooks/useBasketTotalCount'\nexport * from './hooks/useIsBasketWithFixedShippingPrice'\nexport * from './hooks/useProductCarousel'\nexport * from './hooks/useSearchbar'\nexport * from './hooks/useSEOAggregateResult'\nexport * from './hooks/useCatalogPredicates'\nexport * from './hooks/useAggregateResult'\nexport * from './hooks/useSelectedFilters'\nexport * from './hooks/useAllSelectedFilters'\nexport * from './hooks/useClearAllFilters'\nexport * from './hooks/useCheckoutPickupFromStore'\nexport * from './hooks/useCheckoutShippingModule'\nexport * from './hooks/useLoyaltyProgram'\nexport * from './hooks/useCategoryTree'\nexport * from './hooks/useWallet'\nexport * from './hooks/useSizesReducer'\nexport * from './hooks/useAvailability'\n\nexport * from './hooks/cities-hooks'\n\nexport * from './hooks/useLineItem'\nexport * from './hooks/usePrefetchProduct'\nexport * from './hooks/ui-hooks'\nexport * from './hooks/order-hooks'\nexport * from './hooks/basket-hooks'\nexport * from './hooks/useAddressList'\n// export * from './hooks/third-party'\n\nexport * from './hooks/useConfig'\nexport * from './hooks/useShippingAddress'\nexport * from './hooks/useBillingAddress'\nexport * from './hooks/useContactForm'\n\nexport * from './hooks/user-hooks'\nexport * from './hooks/error-handling'\n\nexport * from './hooks/profile-hooks'\nexport * from './hooks/addresses-hooks'\nexport * from './hooks/companies-hooks'\nexport * from './hooks/subscriptions-hooks'\nexport * from './hooks/useRouterRedirect'\nexport * from './hooks/useProgressBar'\nexport * from './hooks/useCatalogDiscounts'\nexport * from './hooks/useLocalRating'\n\n// Utils\nexport * from './utils'\nexport * from './types'\n\n// SEO\nexport * from './seo'\n\n// Analytics\nexport * from './analytics/initiateCheckout'\nexport * from './analytics/viewContent'\n\nexport * from './analytics/Releva'\nexport * from './analytics/Pixel'\n\n// WebView\nexport * from './webview'\n\n// Carousel\nexport * from 'embla-carousel/react'\n\n// CMS\nexport * from './cms'\n\n// API v2\nexport * from './config'\nexport * from './api.v2/core'\n\nexport * from './api.v2/core/misc'\n\nexport * from './ssr/'\nexport * from './listing'\nexport * from './brands'\nexport * from './navigation'\nexport * from './GDPR'\n\n// User\nexport * from './user'\n\n// UI Components and hooks\nexport * from './ui'\n\nexport * from './wishlist'\n\n// Build Scripts \nexport * from './build'\n\n// Order\nexport * from './order'\n\n// Product\nexport * from './product'\n\n// Checkout\nexport * from './checkout'\n\n// PostCSS and related configuration\nexport * from './postcss'"],"file":"index.js"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export var getCanonicalUrl = (context, localeData, redirectTo) => {
|
2
|
+
var _req$url;
|
3
|
+
|
4
|
+
var {
|
5
|
+
req
|
6
|
+
} = context;
|
7
|
+
var reqHost = req.headers['senteca-host'];
|
8
|
+
var reqSSL = req.headers['senteca-ssl']; // Format domain (remove http and the slash at the end)
|
9
|
+
|
10
|
+
var domain = (localeData == null ? void 0 : localeData.domain) || '';
|
11
|
+
domain = domain[domain.length - 1] === '/' ? domain.slice(0, domain.length - 1) : domain;
|
12
|
+
if (!reqHost || !reqSSL || !domain) return;
|
13
|
+
var areWeSecured = reqSSL === 'https';
|
14
|
+
var [currentPath, queryString] = ((_req$url = req.url) == null ? void 0 : _req$url.split('?')) || ['/'];
|
15
|
+
if (!redirectTo && areWeSecured && (domain === reqHost || domain === reqHost + "/" + localeData.locale)) return;
|
16
|
+
return "https://" + domain + (redirectTo || currentPath) + (queryString ? "?" + queryString : '');
|
17
|
+
};
|
18
|
+
//# sourceMappingURL=getCanonicalUrl.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../src/seo/api/ssr/getCanonicalUrl.ts"],"names":["getCanonicalUrl","context","localeData","redirectTo","req","reqHost","headers","reqSSL","domain","length","slice","areWeSecured","currentPath","queryString","url","split","locale"],"mappings":"AAGA,OAAO,IAAMA,eAAe,GAAG,CAC7BC,OAD6B,EAE7BC,UAF6B,EAG7BC,UAH6B,KAIN;AAAA;;AACvB,MAAM;AAAEC,IAAAA;AAAF,MAAUH,OAAhB;AAEA,MAAMI,OAAO,GAAGD,GAAG,CAACE,OAAJ,CAAY,cAAZ,CAAhB;AACA,MAAMC,MAAM,GAAGH,GAAG,CAACE,OAAJ,CAAY,aAAZ,CAAf,CAJuB,CAMvB;;AACA,MAAIE,MAAM,GAAG,CAAAN,UAAU,QAAV,YAAAA,UAAU,CAAEM,MAAZ,KAAsB,EAAnC;AAEAA,EAAAA,MAAM,GACJA,MAAM,CAACA,MAAM,CAACC,MAAP,GAAgB,CAAjB,CAAN,KAA8B,GAA9B,GACID,MAAM,CAACE,KAAP,CAAa,CAAb,EAAgBF,MAAM,CAACC,MAAP,GAAgB,CAAhC,CADJ,GAEID,MAHN;AAKA,MAAI,CAACH,OAAD,IAAY,CAACE,MAAb,IAAuB,CAACC,MAA5B,EAAoC;AAEpC,MAAMG,YAAY,GAAGJ,MAAM,KAAK,OAAhC;AAEA,MAAM,CAACK,WAAD,EAAcC,WAAd,IAA6B,aAAAT,GAAG,CAACU,GAAJ,8BAASC,KAAT,CAAe,GAAf,MAAuB,CAAC,GAAD,CAA1D;AAEA,MACE,CAACZ,UAAD,IACAQ,YADA,KAECH,MAAM,KAAKH,OAAX,IAAsBG,MAAM,KAAQH,OAAR,SAAmBH,UAAU,CAACc,MAF3D,CADF,EAKE;AAEF,sBAAkBR,MAAlB,IAA2BL,UAAU,IAAIS,WAAzC,KACEC,WAAW,SAAOA,WAAP,GAAuB,EADpC;AAGD,CAlCM","sourcesContent":["import { GetServerSidePropsContext } from 'next'\nimport { LocaleData } from '../../..'\n\nexport const getCanonicalUrl = (\n context: GetServerSidePropsContext,\n localeData: LocaleData,\n redirectTo?: string\n): string | undefined => {\n const { req } = context\n\n const reqHost = req.headers['senteca-host']\n const reqSSL = req.headers['senteca-ssl']\n\n // Format domain (remove http and the slash at the end)\n let domain = localeData?.domain || ''\n\n domain =\n domain[domain.length - 1] === '/'\n ? domain.slice(0, domain.length - 1)\n : domain\n\n if (!reqHost || !reqSSL || !domain) return\n\n const areWeSecured = reqSSL === 'https'\n\n const [currentPath, queryString] = req.url?.split('?') || ['/']\n\n if (\n !redirectTo &&\n areWeSecured &&\n (domain === reqHost || domain === `${reqHost}/${localeData.locale}`)\n )\n return\n\n return `https://${domain}${redirectTo || currentPath}${\n queryString ? `?${queryString}` : ''\n }`\n}\n"],"file":"getCanonicalUrl.js"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/seo/api/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAd;AACA,cAAc,uBAAd","sourcesContent":["export * from './fetchSitemaps'\nexport * from './fetchRedirectByFrom'"],"file":"index.js"}
|
1
|
+
{"version":3,"sources":["../../../../../src/seo/api/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAd;AACA,cAAc,uBAAd;AACA,cAAc,mBAAd","sourcesContent":["export * from './fetchSitemaps'\nexport * from './fetchRedirectByFrom'\nexport * from './getCanonicalUrl'"],"file":"index.js"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/user/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAd;AACA,cAAc,WAAd","sourcesContent":["export * from './mutations'\nexport * from './queries'\n"],"file":"index.js"}
|
1
|
+
{"version":3,"sources":["../../../../src/user/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd","sourcesContent":["export * from './mutations'\nexport * from './queries'\nexport * from './utils'\n"],"file":"index.js"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
+
import { AuthCreateAnonymousToken, TokenRequestDTOGrantTypeEnum, HttpClient } from '@sentecacommerce/sdk';
|
3
|
+
import { generateGuid, prefetchSDKConfig } from '../../../';
|
4
|
+
export var generateAnonymousToken = /*#__PURE__*/function () {
|
5
|
+
var _ref = _asyncToGenerator(function* () {
|
6
|
+
if (!HttpClient.defaultConfig) {
|
7
|
+
prefetchSDKConfig({
|
8
|
+
interfaceKey: process.env.DEFAULT_INTERFACE_KEY,
|
9
|
+
storeKey: process.env.STORE
|
10
|
+
});
|
11
|
+
}
|
12
|
+
|
13
|
+
return AuthCreateAnonymousToken({}, {
|
14
|
+
grantType: TokenRequestDTOGrantTypeEnum.Implicit,
|
15
|
+
anonymousId: generateGuid()
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
return function generateAnonymousToken() {
|
20
|
+
return _ref.apply(this, arguments);
|
21
|
+
};
|
22
|
+
}();
|
23
|
+
//# sourceMappingURL=generateAnonymousToken.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../src/user/api/utils/generateAnonymousToken.ts"],"names":["AuthCreateAnonymousToken","TokenRequestDTOGrantTypeEnum","HttpClient","generateGuid","prefetchSDKConfig","generateAnonymousToken","defaultConfig","interfaceKey","process","env","DEFAULT_INTERFACE_KEY","storeKey","STORE","grantType","Implicit","anonymousId"],"mappings":";AAAA,SACEA,wBADF,EAEEC,4BAFF,EAGEC,UAHF,QAIO,sBAJP;AAKA,SAASC,YAAT,EAAuBC,iBAAvB,QAAgD,WAAhD;AAEA,OAAO,IAAMC,sBAAsB;AAAA,+BAAG,aAAY;AAChD,QAAI,CAACH,UAAU,CAACI,aAAhB,EAA+B;AAC7BF,MAAAA,iBAAiB,CAAC;AAChBG,QAAAA,YAAY,EAAEC,OAAO,CAACC,GAAR,CAAYC,qBADV;AAEhBC,QAAAA,QAAQ,EAAEH,OAAO,CAACC,GAAR,CAAYG;AAFN,OAAD,CAAjB;AAID;;AAED,WAAOZ,wBAAwB,CAC7B,EAD6B,EAE7B;AACEa,MAAAA,SAAS,EAAEZ,4BAA4B,CAACa,QAD1C;AAEEC,MAAAA,WAAW,EAAEZ,YAAY;AAF3B,KAF6B,CAA/B;AAOD,GAfkC;;AAAA,kBAAtBE,sBAAsB;AAAA;AAAA;AAAA,GAA5B","sourcesContent":["import {\n AuthCreateAnonymousToken,\n TokenRequestDTOGrantTypeEnum,\n HttpClient,\n} from '@sentecacommerce/sdk'\nimport { generateGuid, prefetchSDKConfig } from '../../../'\n\nexport const generateAnonymousToken = async () => {\n if (!HttpClient.defaultConfig) {\n prefetchSDKConfig({\n interfaceKey: process.env.DEFAULT_INTERFACE_KEY as string,\n storeKey: process.env.STORE as string,\n })\n }\n\n return AuthCreateAnonymousToken(\n {},\n {\n grantType: TokenRequestDTOGrantTypeEnum.Implicit,\n anonymousId: generateGuid(),\n }\n )\n}\n"],"file":"generateAnonymousToken.js"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/user/api/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,uBAAd;AACA,cAAc,qBAAd","sourcesContent":["export * from './processLogin'\nexport * from './processLoginPayload'\nexport * from './invalidateQueries'\n"],"file":"index.js"}
|
1
|
+
{"version":3,"sources":["../../../../../src/user/api/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,uBAAd;AACA,cAAc,qBAAd;AACA,cAAc,0BAAd","sourcesContent":["export * from './processLogin'\nexport * from './processLoginPayload'\nexport * from './invalidateQueries'\nexport * from './generateAnonymousToken'\n"],"file":"index.js"}
|
package/dist/esm/user/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAd;AACA,cAAc,SAAd","sourcesContent":["export * from './hooks'\nexport * from './types'\n"],"file":"index.js"}
|
1
|
+
{"version":3,"sources":["../../../src/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAd;AACA,cAAc,SAAd;AACA,cAAc,aAAd","sourcesContent":["export * from './hooks'\nexport * from './types'\nexport * from './api/utils'\n"],"file":"index.js"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { PayloadDTO } from '../../types';
|
2
|
-
export declare const useRelevaQuery: (payload?: PayloadDTO | undefined, isReady?: boolean | undefined) => import("react-query").QueryResult<any, unknown>;
|
2
|
+
export declare const useRelevaQuery: (payload?: PayloadDTO | undefined, isReady?: boolean | undefined, token?: string | undefined, interfaceKey?: string | undefined) => import("react-query").QueryResult<any, unknown>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RecommendersType, BannerType, PayloadDTO, PixelType } from '../types';
|
2
|
-
export declare const useRelevaData: (payload?: PayloadDTO | undefined, isReady?: boolean | undefined) => {
|
2
|
+
export declare const useRelevaData: (payload?: PayloadDTO | undefined, isReady?: boolean | undefined, token?: string | undefined, interfaceKey?: string | undefined) => {
|
3
3
|
recommenders: RecommendersType[];
|
4
4
|
banners: BannerType[];
|
5
5
|
pixelData: PixelType;
|
@@ -1,3 +1,7 @@
|
|
1
1
|
export declare enum cmsQueriesEnum {
|
2
|
-
useInjectedContentQueryKey = "injected-content"
|
2
|
+
useInjectedContentQueryKey = "injected-content",
|
3
|
+
useContent = "cms-content",
|
4
|
+
useContentList = "cms-content-list"
|
3
5
|
}
|
6
|
+
export declare const getContentKey: (key?: string | undefined) => string;
|
7
|
+
export declare const getContentListKey: (page: number, type?: string | undefined, tags?: string[] | undefined, enabled?: boolean | undefined) => (string | number | boolean | undefined)[];
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export declare type CmsListConfigType = {
|
2
|
+
storeKey?: string;
|
3
|
+
currencyCode?: string;
|
4
|
+
languageCode?: string;
|
5
|
+
priceListKey?: string;
|
6
|
+
time?: number;
|
7
|
+
merchantKey?: string;
|
8
|
+
expand?: string;
|
9
|
+
project?: string;
|
10
|
+
sort?: string;
|
11
|
+
limit: number;
|
12
|
+
tags?: string[];
|
13
|
+
type?: string;
|
14
|
+
};
|
15
|
+
export declare const useCMSContentListQuery: (config: CmsListConfigType, enabled?: boolean) => import("react-query").QueryResult<import("@sentecacommerce/sdk").CmsContentFilterResultDTO, unknown>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useCMSContentQuery: (key?: string | undefined) => import("react-query").QueryResult<import("@sentecacommerce/sdk").CmsContentDTO | undefined, unknown>;
|
package/dist/types/{hooks/cms-content-hooks/useCmsContent/index.d.ts → cms/hooks/useCmsContent.d.ts}
RENAMED
File without changes
|
File without changes
|
@@ -1,3 +1,3 @@
|
|
1
1
|
export declare function fetchPagePaths(themeKey: string, version: string, exceptions?: {
|
2
2
|
[key: string]: true;
|
3
|
-
}, excludePagesWithoutSlash?: boolean, excludeSlugPath?: boolean): Promise<
|
3
|
+
}, excludePagesWithoutSlash?: boolean, excludeSlugPath?: boolean): Promise<string[]>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getCMSContentListFilter: (type?: string | undefined, tags?: string[] | undefined) => string;
|
@@ -2,7 +2,7 @@ import { CheckoutFormErrorLabelsType, CheckoutFormErrorsResultType } from '../..
|
|
2
2
|
import { AddressDTO, OrderDTO } from '@sentecacommerce/sdk';
|
3
3
|
import { QueryResult } from 'react-query';
|
4
4
|
import { SavedBillingAddress } from '../useSavedBillingList';
|
5
|
-
export declare const useBilling: ({ orderQuery, errorLabels, withSavedBillingAddressList, enableSaveBillingAddress, withPersistBeforePageLeave, countryCode, validateBillingAddress, enabled, }: UseBillingProps) => UseBillingResultType;
|
5
|
+
export declare const useBilling: ({ orderQuery, errorLabels, withSavedBillingAddressList, enableSaveBillingAddress, withPersistBeforePageLeave, countryCode, validateBillingAddress, enabled, requiredFields, requiredFieldsOnShipping, }: UseBillingProps) => UseBillingResultType;
|
6
6
|
declare type UseBillingProps = {
|
7
7
|
orderQuery: QueryResult<OrderDTO, unknown>;
|
8
8
|
errorLabels: CheckoutFormErrorLabelsType;
|
@@ -11,7 +11,9 @@ declare type UseBillingProps = {
|
|
11
11
|
withPersistBeforePageLeave: boolean;
|
12
12
|
countryCode: string;
|
13
13
|
enabled: boolean;
|
14
|
-
|
14
|
+
requiredFields: string[];
|
15
|
+
requiredFieldsOnShipping: string[];
|
16
|
+
validateBillingAddress: (address: AddressDTO, errors: CheckoutFormErrorLabelsType, requiredCompanyFields: string[], requiredFields: string[]) => CheckoutFormErrorsResultType;
|
15
17
|
};
|
16
18
|
export declare type UseBillingResultType = {
|
17
19
|
isSubmitting: boolean;
|
@@ -2,7 +2,7 @@ import { QueryResult } from 'react-query';
|
|
2
2
|
import { AddressDTO, CustomerDTO, OrderDTO } from '@sentecacommerce/sdk';
|
3
3
|
import { CheckoutFormErrorLabelsType, CheckoutFormErrorsResultType } from '../../';
|
4
4
|
import { ShippingValidationsType } from '../../utils';
|
5
|
-
export declare const useShipping: ({ withPersistBeforePageLeave, orderQuery, validations, enableSavedAddressList, errorLabels, enableSaveAddress, autofillShippingPersonalData, userQuery, enabled, countryCode }: UseShippingProps) => UseShippingResultType;
|
5
|
+
export declare const useShipping: ({ withPersistBeforePageLeave, orderQuery, validations, enableSavedAddressList, errorLabels, enableSaveAddress, autofillShippingPersonalData, userQuery, enabled, countryCode, requiredFields, enableNoShippingMethodMode, }: UseShippingProps) => UseShippingResultType;
|
6
6
|
declare type UseGeographicalData = {
|
7
7
|
latitude: number;
|
8
8
|
longitude: number;
|
@@ -20,6 +20,8 @@ declare type UseShippingProps = {
|
|
20
20
|
userQuery: QueryResult<CustomerDTO, unknown>;
|
21
21
|
enabled: boolean;
|
22
22
|
countryCode: string;
|
23
|
+
requiredFields: string[];
|
24
|
+
enableNoShippingMethodMode: boolean;
|
23
25
|
};
|
24
26
|
declare type Address = AddressDTO & {
|
25
27
|
isSelectable: boolean;
|
@@ -5,7 +5,7 @@ import { UseBillingResultType, UsePaymentResultType, UseShippingResultType } fro
|
|
5
5
|
import { ShippingValidationsType, BillingAddressValidationType } from './utils';
|
6
6
|
export declare const CheckoutFormContext: React.Context<CheckoutFormContextType>;
|
7
7
|
export declare type CheckoutCustomState = {};
|
8
|
-
export declare function CheckoutFormContextProvider({ children, defaultStep, errorLabels, enableSavedAddressList, withPersistBeforePageLeave, shippingValidations, validateBillingAddress, enableSaveBillingAddress, enableSavedBillingAddressList, countryCode, enableSaveAddress, autofillShippingPersonalData, onSubmit, paymentEnabledOnStep, getPaymentMethodsWhenShippingMethodIsSelected, shippingEnabledOnStep, billingEnabledOnStep, customState: initialCustomState, redirectTimeout, onBeforeRedirect, onSuccess, onError, isBoricaInDevMode, withPixelMeta, }: Props): JSX.Element;
|
8
|
+
export declare function CheckoutFormContextProvider({ children, defaultStep, errorLabels, enableSavedAddressList, withPersistBeforePageLeave, shippingValidations, validateBillingAddress, enableSaveBillingAddress, enableSavedBillingAddressList, countryCode, enableSaveAddress, autofillShippingPersonalData, onSubmit, paymentEnabledOnStep, getPaymentMethodsWhenShippingMethodIsSelected, shippingEnabledOnStep, billingEnabledOnStep, customState: initialCustomState, redirectTimeout, onBeforeRedirect, onSuccess, onError, isBoricaInDevMode, withPixelMeta, requiredFieldsOnShippingStep, requiredFieldsOnBillingAddressStep, enableNoShippingMethodMode, }: Props): JSX.Element;
|
9
9
|
export declare type CheckoutFormOnSubmitData = {
|
10
10
|
isShippingValid: boolean;
|
11
11
|
setIsShippingSubmitting: (value: boolean) => void;
|
@@ -48,6 +48,9 @@ declare type Props = {
|
|
48
48
|
billingEnabledOnStep: CheckoutFormStepsEnum;
|
49
49
|
isBoricaInDevMode?: boolean;
|
50
50
|
withPixelMeta?: boolean;
|
51
|
+
requiredFieldsOnShippingStep?: string[];
|
52
|
+
requiredFieldsOnBillingAddressStep?: string[];
|
53
|
+
enableNoShippingMethodMode?: boolean;
|
51
54
|
};
|
52
55
|
declare type ServerErrors = {
|
53
56
|
[key: string]: any;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { AddressDTO } from '@sentecacommerce/sdk';
|
2
2
|
import { CheckoutFormErrorLabelsType, CheckoutFormErrorsResultType } from '..';
|
3
|
-
export declare type BillingAddressValidationType = (data: AddressDTO, errorLabels: CheckoutFormErrorLabelsType) => CheckoutFormErrorsResultType;
|
4
|
-
export declare function genericBillingAddressValidation(data: AddressDTO, errorLabels: CheckoutFormErrorLabelsType): CheckoutFormErrorsResultType;
|
3
|
+
export declare type BillingAddressValidationType = (data: AddressDTO, errorLabels: CheckoutFormErrorLabelsType, requiredFields: string[], requiredFieldsOnShipping: string[]) => CheckoutFormErrorsResultType;
|
4
|
+
export declare function genericBillingAddressValidation(data: AddressDTO, errorLabels: CheckoutFormErrorLabelsType, requiredCompanyFields: string[]): CheckoutFormErrorsResultType;
|