addio-ecomm-sdk 1.3.77 → 1.3.78
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/.vscode/settings.json +34 -34
- package/README.md +79 -79
- package/dist/index.d.ts +203 -203
- package/dist/index.js +1237 -1237
- package/dist/lib/constants/components/CreditCardInput.d.ts +11 -11
- package/dist/lib/constants/components/CreditCardInput.js +65 -65
- package/dist/lib/constants/components/Snackbar.d.ts +11 -11
- package/dist/lib/constants/components/Snackbar.js +29 -29
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.js +640 -640
- package/dist/lib/constants/contexts/CartContext/index.d.ts +79 -79
- package/dist/lib/constants/contexts/CartContext/index.js +47 -47
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.d.ts +15 -15
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.js +173 -173
- package/dist/lib/constants/contexts/DataContext/index.d.ts +47 -47
- package/dist/lib/constants/contexts/DataContext/index.js +27 -27
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.d.ts +6 -6
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.js +40 -40
- package/dist/lib/constants/contexts/LogContext/index.d.ts +7 -7
- package/dist/lib/constants/contexts/LogContext/index.js +7 -7
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.js +61 -61
- package/dist/lib/constants/contexts/ModalContext/index.d.ts +14 -14
- package/dist/lib/constants/contexts/ModalContext/index.js +16 -16
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.d.ts +8 -8
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.js +23 -23
- package/dist/lib/constants/contexts/SDKContext/index.d.ts +4 -4
- package/dist/lib/constants/contexts/SDKContext/index.js +4 -4
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.d.ts +4 -4
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.js +6 -6
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.d.ts +12 -12
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.js +38 -38
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.d.ts +19 -19
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.js +21 -21
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.js +112 -112
- package/dist/lib/constants/contexts/StockNotifContext/index.d.ts +10 -10
- package/dist/lib/constants/contexts/StockNotifContext/index.js +10 -10
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.d.ts +5 -5
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.js +313 -313
- package/dist/lib/constants/contexts/UserContext/index.d.ts +54 -54
- package/dist/lib/constants/contexts/UserContext/index.js +28 -28
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.d.ts +6 -6
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.js +231 -231
- package/dist/lib/constants/contexts/WishlistContext/index.d.ts +12 -12
- package/dist/lib/constants/contexts/WishlistContext/index.js +12 -12
- package/dist/lib/constants/hooks/useCart.d.ts +2 -2
- package/dist/lib/constants/hooks/useCart.js +11 -11
- package/dist/lib/constants/hooks/useData.d.ts +2 -2
- package/dist/lib/constants/hooks/useData.js +11 -11
- package/dist/lib/constants/hooks/useLogs.d.ts +2 -2
- package/dist/lib/constants/hooks/useLogs.js +11 -11
- package/dist/lib/constants/hooks/useModal.d.ts +2 -2
- package/dist/lib/constants/hooks/useModal.js +11 -11
- package/dist/lib/constants/hooks/useSDK.d.ts +2 -2
- package/dist/lib/constants/hooks/useSDK.js +11 -11
- package/dist/lib/constants/hooks/useSnackbar.d.ts +2 -2
- package/dist/lib/constants/hooks/useSnackbar.js +11 -11
- package/dist/lib/constants/hooks/useStockNotif.d.ts +2 -2
- package/dist/lib/constants/hooks/useStockNotif.js +11 -11
- package/dist/lib/constants/hooks/useUser.d.ts +2 -2
- package/dist/lib/constants/hooks/useUser.js +11 -11
- package/dist/lib/constants/hooks/useWishlist.d.ts +2 -2
- package/dist/lib/constants/hooks/useWishlist.js +11 -11
- package/dist/lib/models/image/index.d.ts +6 -6
- package/dist/lib/models/image/index.js +10 -10
- package/dist/lib/models/stockNotification/index.d.ts +13 -13
- package/dist/lib/models/stockNotification/index.js +70 -70
- package/dist/lib/models/wishlist/index.d.ts +14 -14
- package/dist/lib/models/wishlist/index.js +86 -86
- package/dist/utils/StripeErrors.d.ts +24 -24
- package/dist/utils/StripeErrors.js +55 -55
- package/dist/utils/algolia.d.ts +3 -3
- package/dist/utils/algolia.js +35 -35
- package/dist/utils/analytics.d.ts +71 -71
- package/dist/utils/analytics.js +246 -246
- package/dist/utils/cart.d.ts +3 -3
- package/dist/utils/cart.js +65 -65
- package/dist/utils/contentful.d.ts +10 -10
- package/dist/utils/contentful.js +63 -63
- package/dist/utils/functions.d.ts +21 -21
- package/dist/utils/functions.js +183 -183
- package/dist/utils/getSDK.d.ts +4 -4
- package/dist/utils/getSDK.js +19 -19
- package/dist/utils/initStoreData.d.ts +3 -3
- package/dist/utils/initStoreData.js +17 -17
- package/dist/utils/interfaces/IClientCMSData.d.ts +132 -132
- package/dist/utils/interfaces/IClientCMSData.js +2 -2
- package/dist/utils/interfaces/IEndpointResult.d.ts +10 -10
- package/dist/utils/interfaces/IEndpointResult.js +2 -2
- package/dist/utils/interfaces/IFacebookUserProfile.d.ts +10 -10
- package/dist/utils/interfaces/IFacebookUserProfile.js +2 -2
- package/dist/utils/interfaces/IFilter.d.ts +23 -23
- package/dist/utils/interfaces/IFilter.js +2 -2
- package/dist/utils/interfaces/IGoogleUserProfile.d.ts +7 -7
- package/dist/utils/interfaces/IGoogleUserProfile.js +2 -2
- package/dist/utils/interfaces/ISDKConfig.d.ts +7 -7
- package/dist/utils/interfaces/ISDKConfig.js +2 -2
- package/dist/utils/interfaces/ISpaceData.d.ts +18 -18
- package/dist/utils/interfaces/ISpaceData.js +2 -2
- package/dist/utils/larivieremeunier.d.ts +3 -3
- package/dist/utils/larivieremeunier.js +156 -156
- package/dist/utils/technosupply.d.ts +3 -3
- package/dist/utils/technosupply.js +155 -155
- package/package.json +61 -61
- package/publish.sh +132 -132
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IExpeditionInfo } from 'addio-admin-sdk/dist/Interfaces/Customer';
|
|
3
|
-
import ICart, { IActionDoneOnCart, ICartItem, ICartPromoApplied, IShippingQuote, PaymentTypeEnum } from 'addio-admin-sdk/dist/Interfaces/Cart';
|
|
4
|
-
import IStripePayload from 'addio-admin-sdk/dist/Interfaces/Cart/IStripePayload';
|
|
5
|
-
import IPaypalPayload from 'addio-admin-sdk/dist/Interfaces/Cart/IPaypalPayload';
|
|
6
|
-
import ILang from 'addio-admin-sdk/dist/utils/string';
|
|
7
|
-
import { ICustomPriceItem } from 'addio-admin-sdk/dist/Interfaces/G2';
|
|
8
|
-
import { ApplyBanksToCartErrorsEnum } from 'addio-admin-sdk/dist/Interfaces/PromiseToPurchase';
|
|
9
|
-
import { RuleFieldEnum } from 'addio-admin-sdk/dist/Interfaces/Rules/IDiscountRule';
|
|
10
|
-
export interface ICartContext {
|
|
11
|
-
readonly loading: boolean;
|
|
12
|
-
readonly cartData?: ICart;
|
|
13
|
-
readonly cartErrors: string[];
|
|
14
|
-
readonly isGuest?: string;
|
|
15
|
-
readonly setIsGuest: (isGuest: string) => void;
|
|
16
|
-
readonly setCartErrors: (errorCodes: string[]) => void;
|
|
17
|
-
readonly setCartData: (cart: ICart) => void;
|
|
18
|
-
readonly saveCart: (cartData?: Partial<ICart>, saveToDatabase?: boolean, promo_code?: string | undefined, onlyNewCart?: boolean, onlyPartial?: boolean) => Promise<ICart>;
|
|
19
|
-
readonly setCartLoading: (value: boolean) => void;
|
|
20
|
-
readonly getCartFromDatabase: (cardID: string) => Promise<ICart | undefined>;
|
|
21
|
-
readonly handlePayment: (data?: any) => Promise<{
|
|
22
|
-
accessToken?: string;
|
|
23
|
-
error?: ILang;
|
|
24
|
-
}>;
|
|
25
|
-
readonly cartSliderOpen: boolean;
|
|
26
|
-
readonly addItem: (cartData: ICart | undefined, items: ICartItem | ICartItem[], retro?: boolean, useParentName?: boolean, saveToDatabase?: boolean, defaultAdd?: boolean, isServiceUpsellOfSku?: boolean, customPriceList?: ICustomPriceItem[]) => Promise<ICart>;
|
|
27
|
-
readonly setCartSliderOpen: (open: boolean) => void;
|
|
28
|
-
readonly updateItem: (cartData: ICart | undefined, items: {
|
|
29
|
-
sku: string;
|
|
30
|
-
qte: number;
|
|
31
|
-
}[] | {
|
|
32
|
-
sku: string;
|
|
33
|
-
qte: number;
|
|
34
|
-
}, saveToDatabase?: boolean) => Promise<ICart>;
|
|
35
|
-
readonly deleteItem: (cartData: ICart | undefined, sku: string | string[], saveToDatabase?: boolean, onlyIfUpsellOf?: string) => Promise<ICart>;
|
|
36
|
-
readonly verifyCart: () => Promise<false | IActionDoneOnCart[]>;
|
|
37
|
-
readonly uploadFileToOrder: (newCart: ICart | undefined, file: File, propsName: string, saveToDatabase?: boolean) => Promise<{
|
|
38
|
-
cart: ICart;
|
|
39
|
-
data: undefined;
|
|
40
|
-
error: string;
|
|
41
|
-
} | {
|
|
42
|
-
cart: ICart;
|
|
43
|
-
data: {
|
|
44
|
-
url: string;
|
|
45
|
-
ref: string;
|
|
46
|
-
};
|
|
47
|
-
error: undefined;
|
|
48
|
-
} | undefined>;
|
|
49
|
-
readonly updateEmail: (newCart: ICart | undefined, email: string, saveToDatabase: boolean) => Promise<ICart>;
|
|
50
|
-
readonly updateDefaultCustomer: (newCart: ICart | undefined, email: string, id: string, pro_info?: {
|
|
51
|
-
pro_title?: string;
|
|
52
|
-
pro_proof_doc?: string;
|
|
53
|
-
customer_external_code?: string;
|
|
54
|
-
}, saveToDatabase?: boolean) => Promise<ICart>;
|
|
55
|
-
readonly emptyCart: (removeCartIDFromLocalStorage?: boolean) => Promise<boolean>;
|
|
56
|
-
readonly saveOrder: (payload: IStripePayload | IPaypalPayload) => Promise<{
|
|
57
|
-
orderID: string;
|
|
58
|
-
accessToken: string;
|
|
59
|
-
} | 'error'>;
|
|
60
|
-
readonly updateShippingAddress: (cartData: ICart | undefined, _isPickup: boolean, _shipping: IExpeditionInfo | undefined, saveToDatabase?: boolean, setCAIfNoCountry?: boolean) => Promise<ICart>;
|
|
61
|
-
readonly updateBillingAddress: (cartData: ICart | undefined, _billing: IExpeditionInfo, saveToDatabase?: boolean, setCAIfNoCountry?: boolean) => Promise<ICart>;
|
|
62
|
-
readonly getIsSameBillingThenShipping: () => boolean;
|
|
63
|
-
readonly setShippingPayload: (newCart: ICart | undefined, payload: any, saveToDatabase?: boolean) => Promise<ICart>;
|
|
64
|
-
readonly removeDiscountRule: (cart: ICart, code: string) => Promise<boolean>;
|
|
65
|
-
readonly getShippingQuotes: () => Promise<Partial<IShippingQuote>[] | undefined>;
|
|
66
|
-
readonly selectShippingQuote: (_quote: Partial<IShippingQuote>) => Promise<ICart | undefined>;
|
|
67
|
-
readonly setPromoCode: (promo_code: string) => Promise<void>;
|
|
68
|
-
readonly getApplicablePromos: (forceShipping: boolean) => Promise<ICartPromoApplied[] | undefined>;
|
|
69
|
-
readonly canBePaidWithPA: (userId: string) => Promise<{
|
|
70
|
-
canBePaid: boolean;
|
|
71
|
-
updatedCart: ICart | undefined;
|
|
72
|
-
canBePaidReason?: ApplyBanksToCartErrorsEnum;
|
|
73
|
-
} | undefined>;
|
|
74
|
-
readonly getPaymentIncentiveDiscountAmount: (skipCheckForRuleFields?: RuleFieldEnum[]) => number | undefined;
|
|
75
|
-
readonly setPaidBy: (paidByValue: PaymentTypeEnum | null, customPriceList?: ICustomPriceItem[] | undefined, chosenPayment?: PaymentTypeEnum) => Promise<void>;
|
|
76
|
-
}
|
|
77
|
-
export declare const getDefaultCartContext: () => ICartContext;
|
|
78
|
-
declare const CartContext: React.Context<ICartContext>;
|
|
79
|
-
export default CartContext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IExpeditionInfo } from 'addio-admin-sdk/dist/Interfaces/Customer';
|
|
3
|
+
import ICart, { IActionDoneOnCart, ICartItem, ICartPromoApplied, IShippingQuote, PaymentTypeEnum } from 'addio-admin-sdk/dist/Interfaces/Cart';
|
|
4
|
+
import IStripePayload from 'addio-admin-sdk/dist/Interfaces/Cart/IStripePayload';
|
|
5
|
+
import IPaypalPayload from 'addio-admin-sdk/dist/Interfaces/Cart/IPaypalPayload';
|
|
6
|
+
import ILang from 'addio-admin-sdk/dist/utils/string';
|
|
7
|
+
import { ICustomPriceItem } from 'addio-admin-sdk/dist/Interfaces/G2';
|
|
8
|
+
import { ApplyBanksToCartErrorsEnum } from 'addio-admin-sdk/dist/Interfaces/PromiseToPurchase';
|
|
9
|
+
import { RuleFieldEnum } from 'addio-admin-sdk/dist/Interfaces/Rules/IDiscountRule';
|
|
10
|
+
export interface ICartContext {
|
|
11
|
+
readonly loading: boolean;
|
|
12
|
+
readonly cartData?: ICart;
|
|
13
|
+
readonly cartErrors: string[];
|
|
14
|
+
readonly isGuest?: string;
|
|
15
|
+
readonly setIsGuest: (isGuest: string) => void;
|
|
16
|
+
readonly setCartErrors: (errorCodes: string[]) => void;
|
|
17
|
+
readonly setCartData: (cart: ICart) => void;
|
|
18
|
+
readonly saveCart: (cartData?: Partial<ICart>, saveToDatabase?: boolean, promo_code?: string | undefined, onlyNewCart?: boolean, onlyPartial?: boolean) => Promise<ICart>;
|
|
19
|
+
readonly setCartLoading: (value: boolean) => void;
|
|
20
|
+
readonly getCartFromDatabase: (cardID: string) => Promise<ICart | undefined>;
|
|
21
|
+
readonly handlePayment: (data?: any) => Promise<{
|
|
22
|
+
accessToken?: string;
|
|
23
|
+
error?: ILang;
|
|
24
|
+
}>;
|
|
25
|
+
readonly cartSliderOpen: boolean;
|
|
26
|
+
readonly addItem: (cartData: ICart | undefined, items: ICartItem | ICartItem[], retro?: boolean, useParentName?: boolean, saveToDatabase?: boolean, defaultAdd?: boolean, isServiceUpsellOfSku?: boolean, customPriceList?: ICustomPriceItem[]) => Promise<ICart>;
|
|
27
|
+
readonly setCartSliderOpen: (open: boolean) => void;
|
|
28
|
+
readonly updateItem: (cartData: ICart | undefined, items: {
|
|
29
|
+
sku: string;
|
|
30
|
+
qte: number;
|
|
31
|
+
}[] | {
|
|
32
|
+
sku: string;
|
|
33
|
+
qte: number;
|
|
34
|
+
}, saveToDatabase?: boolean) => Promise<ICart>;
|
|
35
|
+
readonly deleteItem: (cartData: ICart | undefined, sku: string | string[], saveToDatabase?: boolean, onlyIfUpsellOf?: string) => Promise<ICart>;
|
|
36
|
+
readonly verifyCart: () => Promise<false | IActionDoneOnCart[]>;
|
|
37
|
+
readonly uploadFileToOrder: (newCart: ICart | undefined, file: File, propsName: string, saveToDatabase?: boolean) => Promise<{
|
|
38
|
+
cart: ICart;
|
|
39
|
+
data: undefined;
|
|
40
|
+
error: string;
|
|
41
|
+
} | {
|
|
42
|
+
cart: ICart;
|
|
43
|
+
data: {
|
|
44
|
+
url: string;
|
|
45
|
+
ref: string;
|
|
46
|
+
};
|
|
47
|
+
error: undefined;
|
|
48
|
+
} | undefined>;
|
|
49
|
+
readonly updateEmail: (newCart: ICart | undefined, email: string, saveToDatabase: boolean) => Promise<ICart>;
|
|
50
|
+
readonly updateDefaultCustomer: (newCart: ICart | undefined, email: string, id: string, pro_info?: {
|
|
51
|
+
pro_title?: string;
|
|
52
|
+
pro_proof_doc?: string;
|
|
53
|
+
customer_external_code?: string;
|
|
54
|
+
}, saveToDatabase?: boolean) => Promise<ICart>;
|
|
55
|
+
readonly emptyCart: (removeCartIDFromLocalStorage?: boolean) => Promise<boolean>;
|
|
56
|
+
readonly saveOrder: (payload: IStripePayload | IPaypalPayload) => Promise<{
|
|
57
|
+
orderID: string;
|
|
58
|
+
accessToken: string;
|
|
59
|
+
} | 'error'>;
|
|
60
|
+
readonly updateShippingAddress: (cartData: ICart | undefined, _isPickup: boolean, _shipping: IExpeditionInfo | undefined, saveToDatabase?: boolean, setCAIfNoCountry?: boolean) => Promise<ICart>;
|
|
61
|
+
readonly updateBillingAddress: (cartData: ICart | undefined, _billing: IExpeditionInfo, saveToDatabase?: boolean, setCAIfNoCountry?: boolean) => Promise<ICart>;
|
|
62
|
+
readonly getIsSameBillingThenShipping: () => boolean;
|
|
63
|
+
readonly setShippingPayload: (newCart: ICart | undefined, payload: any, saveToDatabase?: boolean) => Promise<ICart>;
|
|
64
|
+
readonly removeDiscountRule: (cart: ICart, code: string) => Promise<boolean>;
|
|
65
|
+
readonly getShippingQuotes: () => Promise<Partial<IShippingQuote>[] | undefined>;
|
|
66
|
+
readonly selectShippingQuote: (_quote: Partial<IShippingQuote>) => Promise<ICart | undefined>;
|
|
67
|
+
readonly setPromoCode: (promo_code: string) => Promise<void>;
|
|
68
|
+
readonly getApplicablePromos: (forceShipping: boolean) => Promise<ICartPromoApplied[] | undefined>;
|
|
69
|
+
readonly canBePaidWithPA: (userId: string) => Promise<{
|
|
70
|
+
canBePaid: boolean;
|
|
71
|
+
updatedCart: ICart | undefined;
|
|
72
|
+
canBePaidReason?: ApplyBanksToCartErrorsEnum;
|
|
73
|
+
} | undefined>;
|
|
74
|
+
readonly getPaymentIncentiveDiscountAmount: (skipCheckForRuleFields?: RuleFieldEnum[]) => number | undefined;
|
|
75
|
+
readonly setPaidBy: (paidByValue: PaymentTypeEnum | null, customPriceList?: ICustomPriceItem[] | undefined, chosenPayment?: PaymentTypeEnum) => Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export declare const getDefaultCartContext: () => ICartContext;
|
|
78
|
+
declare const CartContext: React.Context<ICartContext>;
|
|
79
|
+
export default CartContext;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDefaultCartContext = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const Cart_1 = require("addio-admin-sdk/dist/Interfaces/Cart");
|
|
9
|
-
const getDefaultCartContext = () => ({
|
|
10
|
-
loading: false,
|
|
11
|
-
cartData: (0, Cart_1.getDefaultCart)(Cart_1.CartTypeEnum.WEB),
|
|
12
|
-
cartErrors: [],
|
|
13
|
-
cartSliderOpen: false,
|
|
14
|
-
isGuest: undefined,
|
|
15
|
-
setIsGuest: (_isGuest) => { },
|
|
16
|
-
setCartErrors: (_errorCodes) => { },
|
|
17
|
-
setCartData: (_cart) => { },
|
|
18
|
-
setCartLoading: (_value) => { },
|
|
19
|
-
getCartFromDatabase: async (_cartID) => undefined,
|
|
20
|
-
saveCart: async () => (0, Cart_1.getDefaultCart)(),
|
|
21
|
-
handlePayment: async () => ({}),
|
|
22
|
-
addItem: async (_cart, _item) => (0, Cart_1.getDefaultCart)(),
|
|
23
|
-
setCartSliderOpen: (_open) => { },
|
|
24
|
-
deleteItem: async (_cart, _sku) => (0, Cart_1.getDefaultCart)(),
|
|
25
|
-
updateItem: async (_cartData, _items, _saveToDatabase) => (0, Cart_1.getDefaultCart)(),
|
|
26
|
-
verifyCart: async () => false,
|
|
27
|
-
uploadFileToOrder: async (_cart, _) => undefined,
|
|
28
|
-
updateEmail: async (_cart, _email) => (0, Cart_1.getDefaultCart)(),
|
|
29
|
-
updateDefaultCustomer: async (_cart, _email, _id, _pro_info, _saveToDatabase) => (0, Cart_1.getDefaultCart)(),
|
|
30
|
-
emptyCart: async () => false,
|
|
31
|
-
saveOrder: async (_payload) => ({ orderID: '', accessToken: '' }),
|
|
32
|
-
updateShippingAddress: async (_cart, _isPickup, _shipping) => (0, Cart_1.getDefaultCart)(),
|
|
33
|
-
updateBillingAddress: async (_cart, _billing) => (0, Cart_1.getDefaultCart)(),
|
|
34
|
-
getIsSameBillingThenShipping: () => false,
|
|
35
|
-
setShippingPayload: async (_cart, _payload) => (0, Cart_1.getDefaultCart)(),
|
|
36
|
-
removeDiscountRule: async (_cart, _code) => true,
|
|
37
|
-
getShippingQuotes: async () => [],
|
|
38
|
-
selectShippingQuote: async (_quote) => (0, Cart_1.getDefaultCart)(),
|
|
39
|
-
setPromoCode: async (_promo_code) => { },
|
|
40
|
-
getApplicablePromos: async (_forceShipping) => [],
|
|
41
|
-
canBePaidWithPA: async (_userId) => ({ canBePaid: false, updatedCart: (0, Cart_1.getDefaultCart)() }),
|
|
42
|
-
getPaymentIncentiveDiscountAmount: (_skipCheckForRuleFields) => undefined,
|
|
43
|
-
setPaidBy: async (_paidByValue, _customPriceList) => undefined
|
|
44
|
-
});
|
|
45
|
-
exports.getDefaultCartContext = getDefaultCartContext;
|
|
46
|
-
const CartContext = react_1.default.createContext((0, exports.getDefaultCartContext)());
|
|
47
|
-
exports.default = CartContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDefaultCartContext = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const Cart_1 = require("addio-admin-sdk/dist/Interfaces/Cart");
|
|
9
|
+
const getDefaultCartContext = () => ({
|
|
10
|
+
loading: false,
|
|
11
|
+
cartData: (0, Cart_1.getDefaultCart)(Cart_1.CartTypeEnum.WEB),
|
|
12
|
+
cartErrors: [],
|
|
13
|
+
cartSliderOpen: false,
|
|
14
|
+
isGuest: undefined,
|
|
15
|
+
setIsGuest: (_isGuest) => { },
|
|
16
|
+
setCartErrors: (_errorCodes) => { },
|
|
17
|
+
setCartData: (_cart) => { },
|
|
18
|
+
setCartLoading: (_value) => { },
|
|
19
|
+
getCartFromDatabase: async (_cartID) => undefined,
|
|
20
|
+
saveCart: async () => (0, Cart_1.getDefaultCart)(),
|
|
21
|
+
handlePayment: async () => ({}),
|
|
22
|
+
addItem: async (_cart, _item) => (0, Cart_1.getDefaultCart)(),
|
|
23
|
+
setCartSliderOpen: (_open) => { },
|
|
24
|
+
deleteItem: async (_cart, _sku) => (0, Cart_1.getDefaultCart)(),
|
|
25
|
+
updateItem: async (_cartData, _items, _saveToDatabase) => (0, Cart_1.getDefaultCart)(),
|
|
26
|
+
verifyCart: async () => false,
|
|
27
|
+
uploadFileToOrder: async (_cart, _) => undefined,
|
|
28
|
+
updateEmail: async (_cart, _email) => (0, Cart_1.getDefaultCart)(),
|
|
29
|
+
updateDefaultCustomer: async (_cart, _email, _id, _pro_info, _saveToDatabase) => (0, Cart_1.getDefaultCart)(),
|
|
30
|
+
emptyCart: async () => false,
|
|
31
|
+
saveOrder: async (_payload) => ({ orderID: '', accessToken: '' }),
|
|
32
|
+
updateShippingAddress: async (_cart, _isPickup, _shipping) => (0, Cart_1.getDefaultCart)(),
|
|
33
|
+
updateBillingAddress: async (_cart, _billing) => (0, Cart_1.getDefaultCart)(),
|
|
34
|
+
getIsSameBillingThenShipping: () => false,
|
|
35
|
+
setShippingPayload: async (_cart, _payload) => (0, Cart_1.getDefaultCart)(),
|
|
36
|
+
removeDiscountRule: async (_cart, _code) => true,
|
|
37
|
+
getShippingQuotes: async () => [],
|
|
38
|
+
selectShippingQuote: async (_quote) => (0, Cart_1.getDefaultCart)(),
|
|
39
|
+
setPromoCode: async (_promo_code) => { },
|
|
40
|
+
getApplicablePromos: async (_forceShipping) => [],
|
|
41
|
+
canBePaidWithPA: async (_userId) => ({ canBePaid: false, updatedCart: (0, Cart_1.getDefaultCart)() }),
|
|
42
|
+
getPaymentIncentiveDiscountAmount: (_skipCheckForRuleFields) => undefined,
|
|
43
|
+
setPaidBy: async (_paidByValue, _customPriceList) => undefined
|
|
44
|
+
});
|
|
45
|
+
exports.getDefaultCartContext = getDefaultCartContext;
|
|
46
|
+
const CartContext = react_1.default.createContext((0, exports.getDefaultCartContext)());
|
|
47
|
+
exports.default = CartContext;
|
|
48
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import IBrand from 'addio-admin-sdk/dist/Interfaces/Brand';
|
|
3
|
-
import ICategory from 'addio-admin-sdk/dist/Interfaces/Category';
|
|
4
|
-
import ISpaceData from '../../../../utils/interfaces/ISpaceData';
|
|
5
|
-
interface IProps {
|
|
6
|
-
readonly spaceData?: ISpaceData;
|
|
7
|
-
readonly children: JSX.Element;
|
|
8
|
-
readonly maintenanceComponent: JSX.Element;
|
|
9
|
-
readonly ssrStoreData?: ISpaceData | undefined;
|
|
10
|
-
readonly ssrCategories?: ICategory[] | undefined;
|
|
11
|
-
readonly ssrAttributes?: any[] | undefined;
|
|
12
|
-
readonly ssrBrands?: IBrand[] | undefined;
|
|
13
|
-
}
|
|
14
|
-
export default function DataContextProvider({ spaceData, children, maintenanceComponent, ssrStoreData, ssrCategories, ssrAttributes, ssrBrands }: IProps): JSX.Element;
|
|
15
|
-
export {};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import IBrand from 'addio-admin-sdk/dist/Interfaces/Brand';
|
|
3
|
+
import ICategory from 'addio-admin-sdk/dist/Interfaces/Category';
|
|
4
|
+
import ISpaceData from '../../../../utils/interfaces/ISpaceData';
|
|
5
|
+
interface IProps {
|
|
6
|
+
readonly spaceData?: ISpaceData;
|
|
7
|
+
readonly children: JSX.Element;
|
|
8
|
+
readonly maintenanceComponent: JSX.Element;
|
|
9
|
+
readonly ssrStoreData?: ISpaceData | undefined;
|
|
10
|
+
readonly ssrCategories?: ICategory[] | undefined;
|
|
11
|
+
readonly ssrAttributes?: any[] | undefined;
|
|
12
|
+
readonly ssrBrands?: IBrand[] | undefined;
|
|
13
|
+
}
|
|
14
|
+
export default function DataContextProvider({ spaceData, children, maintenanceComponent, ssrStoreData, ssrCategories, ssrAttributes, ssrBrands }: IProps): JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
-
const toNumber_1 = __importDefault(require("lodash/toNumber"));
|
|
31
|
-
const react_1 = require("react");
|
|
32
|
-
const _1 = __importStar(require("."));
|
|
33
|
-
const useSDK_1 = __importDefault(require("../../hooks/useSDK"));
|
|
34
|
-
const functions_1 = require("../../../../utils/functions");
|
|
35
|
-
function DataContextProvider({ spaceData, children, maintenanceComponent, ssrStoreData, ssrCategories, ssrAttributes, ssrBrands }) {
|
|
36
|
-
const sdk = (0, useSDK_1.default)();
|
|
37
|
-
const api = !!sdk ? sdk.getAPIInfos() : null;
|
|
38
|
-
const [state, setState] = (0, react_1.useState)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, _1.getDefaultDataContext)()), (!!spaceData ? spaceData : {})), (!!ssrStoreData ? { data: ssrStoreData } : {})), (!!ssrCategories ? { categories: ssrCategories, categoryTree: (0, functions_1.printTree)(ssrCategories) } : {})), (!!ssrAttributes ? { attributes: ssrAttributes } : {})), (!!ssrBrands ? { brands: ssrBrands } : {})));
|
|
39
|
-
const [fetchingContent, setFetchingContent] = (0, react_1.useState)(false);
|
|
40
|
-
const setCurrency = (currency) => {
|
|
41
|
-
setState((prevstate) => (Object.assign(Object.assign({}, prevstate), { currency: currency })));
|
|
42
|
-
};
|
|
43
|
-
const calculateAmountByCurrency = (amountToCalculate) => {
|
|
44
|
-
const formatPrice = (price) => {
|
|
45
|
-
try {
|
|
46
|
-
if ((0, toNumber_1.default)(price) === 0)
|
|
47
|
-
return '0';
|
|
48
|
-
return (0, toNumber_1.default)(price).toFixed(2);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
console.log(`error while formating number`, error);
|
|
52
|
-
return `${price}`;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
if (state.currency === state.defaultCurrency)
|
|
56
|
-
return formatPrice((0, toNumber_1.default)(amountToCalculate));
|
|
57
|
-
const allCurrencies = state.exchangeRates;
|
|
58
|
-
if (!!!allCurrencies)
|
|
59
|
-
return formatPrice((0, toNumber_1.default)(amountToCalculate));
|
|
60
|
-
const currencyRate = (0, toNumber_1.default)(state.exchangeRates.rates[state.currency] || 1);
|
|
61
|
-
const storeCurrencyRate = (0, toNumber_1.default)(allCurrencies.rates[state.defaultCurrency] || 1);
|
|
62
|
-
return formatPrice((amountToCalculate / storeCurrencyRate) * currencyRate);
|
|
63
|
-
};
|
|
64
|
-
const fetchProductSDK = async (slug, locale = 'fr', useFeeArray, noDrafts) => {
|
|
65
|
-
if (!!!sdk)
|
|
66
|
-
return;
|
|
67
|
-
try {
|
|
68
|
-
const prod = await sdk.products.getProduct(slug, locale, !!useFeeArray ? state.fees : undefined, noDrafts);
|
|
69
|
-
return prod;
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
console.log('Error on fetching product from DB: ', e.toString());
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
(0, react_1.useEffect)(() => {
|
|
76
|
-
if (!!!sdk)
|
|
77
|
-
return;
|
|
78
|
-
const getContent = async () => {
|
|
79
|
-
let data = undefined;
|
|
80
|
-
let categories = [];
|
|
81
|
-
let categoryTree = [];
|
|
82
|
-
let attributes = [];
|
|
83
|
-
let brands = [];
|
|
84
|
-
let fees = [];
|
|
85
|
-
try {
|
|
86
|
-
data = !!!ssrStoreData ? await sdk.initStoreData(spaceData) : ssrStoreData;
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
console.log('error on fetching data for space: ', e.toString());
|
|
90
|
-
setFetchingContent(false);
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
categories = !!!ssrCategories
|
|
94
|
-
? !!state.categories && !!state.categories.length
|
|
95
|
-
? state.categories
|
|
96
|
-
: (await sdk.products.getCategories()) || []
|
|
97
|
-
: ssrCategories;
|
|
98
|
-
if (!!categories.length) {
|
|
99
|
-
categoryTree = (0, functions_1.printTree)(categories);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
console.log('error on fetching categories for space: ', e.toString());
|
|
104
|
-
setFetchingContent(false);
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
attributes = !!!ssrAttributes
|
|
108
|
-
? !!state.attributes && !!state.attributes.length
|
|
109
|
-
? state.attributes
|
|
110
|
-
: (await sdk.products.getAttributes()) || []
|
|
111
|
-
: ssrAttributes;
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
console.log('error on fetching attributes for space: ', e.toString());
|
|
115
|
-
setFetchingContent(false);
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
brands = !!!ssrBrands
|
|
119
|
-
? !!state.brands && !!state.brands.length
|
|
120
|
-
? state.brands
|
|
121
|
-
: (await sdk.products.getBrands()) || []
|
|
122
|
-
: ssrBrands;
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
console.log('error on fetching brands for space: ', e.toString());
|
|
126
|
-
setFetchingContent(false);
|
|
127
|
-
}
|
|
128
|
-
try {
|
|
129
|
-
fees =
|
|
130
|
-
!!state.fees && state.fees.length
|
|
131
|
-
? state.fees
|
|
132
|
-
: !!api && api.org === 'gr'
|
|
133
|
-
? (await sdk.products.getFees()) || []
|
|
134
|
-
: [];
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
console.log('error on fetching fees for space: ', e.toString());
|
|
138
|
-
setFetchingContent(false);
|
|
139
|
-
}
|
|
140
|
-
setState((prevState) => (Object.assign(Object.assign(Object.assign({}, prevState), (!!data ? data : {})), { categories,
|
|
141
|
-
categoryTree,
|
|
142
|
-
attributes,
|
|
143
|
-
brands,
|
|
144
|
-
fees })));
|
|
145
|
-
setFetchingContent(false);
|
|
146
|
-
};
|
|
147
|
-
if (!fetchingContent) {
|
|
148
|
-
setFetchingContent(true);
|
|
149
|
-
getContent();
|
|
150
|
-
}
|
|
151
|
-
}, [sdk, state.currency]);
|
|
152
|
-
(0, react_1.useEffect)(() => {
|
|
153
|
-
const storageCurrency = localStorage.getItem('currency');
|
|
154
|
-
if ((!!storageCurrency && storageCurrency === 'CAD') || storageCurrency === 'USD') {
|
|
155
|
-
setCurrency(storageCurrency);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
localStorage.setItem('currency', state.currency);
|
|
159
|
-
}
|
|
160
|
-
}, []);
|
|
161
|
-
(0, react_1.useEffect)(() => {
|
|
162
|
-
if ((!!state.currency && state.currency === 'CAD') || state.currency === 'USD') {
|
|
163
|
-
localStorage.setItem('currency', state.currency);
|
|
164
|
-
}
|
|
165
|
-
}, [state.currency]);
|
|
166
|
-
return ((0, jsx_runtime_1.jsx)(_1.default.Provider, Object.assign({ value: Object.assign(Object.assign({}, state), { calculateAmountByCurrency: calculateAmountByCurrency, setCurrency: setCurrency, fetchProductSDK: fetchProductSDK }) }, { children: !!state.website_in_maintenance &&
|
|
167
|
-
!!maintenanceComponent &&
|
|
168
|
-
!!!process.env.IS_TEST_ENV &&
|
|
169
|
-
!!!process.env.IS_STAGING
|
|
170
|
-
? maintenanceComponent
|
|
171
|
-
: children })));
|
|
172
|
-
}
|
|
173
|
-
exports.default = DataContextProvider;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
+
const toNumber_1 = __importDefault(require("lodash/toNumber"));
|
|
31
|
+
const react_1 = require("react");
|
|
32
|
+
const _1 = __importStar(require("."));
|
|
33
|
+
const useSDK_1 = __importDefault(require("../../hooks/useSDK"));
|
|
34
|
+
const functions_1 = require("../../../../utils/functions");
|
|
35
|
+
function DataContextProvider({ spaceData, children, maintenanceComponent, ssrStoreData, ssrCategories, ssrAttributes, ssrBrands }) {
|
|
36
|
+
const sdk = (0, useSDK_1.default)();
|
|
37
|
+
const api = !!sdk ? sdk.getAPIInfos() : null;
|
|
38
|
+
const [state, setState] = (0, react_1.useState)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, _1.getDefaultDataContext)()), (!!spaceData ? spaceData : {})), (!!ssrStoreData ? { data: ssrStoreData } : {})), (!!ssrCategories ? { categories: ssrCategories, categoryTree: (0, functions_1.printTree)(ssrCategories) } : {})), (!!ssrAttributes ? { attributes: ssrAttributes } : {})), (!!ssrBrands ? { brands: ssrBrands } : {})));
|
|
39
|
+
const [fetchingContent, setFetchingContent] = (0, react_1.useState)(false);
|
|
40
|
+
const setCurrency = (currency) => {
|
|
41
|
+
setState((prevstate) => (Object.assign(Object.assign({}, prevstate), { currency: currency })));
|
|
42
|
+
};
|
|
43
|
+
const calculateAmountByCurrency = (amountToCalculate) => {
|
|
44
|
+
const formatPrice = (price) => {
|
|
45
|
+
try {
|
|
46
|
+
if ((0, toNumber_1.default)(price) === 0)
|
|
47
|
+
return '0';
|
|
48
|
+
return (0, toNumber_1.default)(price).toFixed(2);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.log(`error while formating number`, error);
|
|
52
|
+
return `${price}`;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
if (state.currency === state.defaultCurrency)
|
|
56
|
+
return formatPrice((0, toNumber_1.default)(amountToCalculate));
|
|
57
|
+
const allCurrencies = state.exchangeRates;
|
|
58
|
+
if (!!!allCurrencies)
|
|
59
|
+
return formatPrice((0, toNumber_1.default)(amountToCalculate));
|
|
60
|
+
const currencyRate = (0, toNumber_1.default)(state.exchangeRates.rates[state.currency] || 1);
|
|
61
|
+
const storeCurrencyRate = (0, toNumber_1.default)(allCurrencies.rates[state.defaultCurrency] || 1);
|
|
62
|
+
return formatPrice((amountToCalculate / storeCurrencyRate) * currencyRate);
|
|
63
|
+
};
|
|
64
|
+
const fetchProductSDK = async (slug, locale = 'fr', useFeeArray, noDrafts) => {
|
|
65
|
+
if (!!!sdk)
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
const prod = await sdk.products.getProduct(slug, locale, !!useFeeArray ? state.fees : undefined, noDrafts);
|
|
69
|
+
return prod;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
console.log('Error on fetching product from DB: ', e.toString());
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
(0, react_1.useEffect)(() => {
|
|
76
|
+
if (!!!sdk)
|
|
77
|
+
return;
|
|
78
|
+
const getContent = async () => {
|
|
79
|
+
let data = undefined;
|
|
80
|
+
let categories = [];
|
|
81
|
+
let categoryTree = [];
|
|
82
|
+
let attributes = [];
|
|
83
|
+
let brands = [];
|
|
84
|
+
let fees = [];
|
|
85
|
+
try {
|
|
86
|
+
data = !!!ssrStoreData ? await sdk.initStoreData(spaceData) : ssrStoreData;
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
console.log('error on fetching data for space: ', e.toString());
|
|
90
|
+
setFetchingContent(false);
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
categories = !!!ssrCategories
|
|
94
|
+
? !!state.categories && !!state.categories.length
|
|
95
|
+
? state.categories
|
|
96
|
+
: (await sdk.products.getCategories()) || []
|
|
97
|
+
: ssrCategories;
|
|
98
|
+
if (!!categories.length) {
|
|
99
|
+
categoryTree = (0, functions_1.printTree)(categories);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
console.log('error on fetching categories for space: ', e.toString());
|
|
104
|
+
setFetchingContent(false);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
attributes = !!!ssrAttributes
|
|
108
|
+
? !!state.attributes && !!state.attributes.length
|
|
109
|
+
? state.attributes
|
|
110
|
+
: (await sdk.products.getAttributes()) || []
|
|
111
|
+
: ssrAttributes;
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
console.log('error on fetching attributes for space: ', e.toString());
|
|
115
|
+
setFetchingContent(false);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
brands = !!!ssrBrands
|
|
119
|
+
? !!state.brands && !!state.brands.length
|
|
120
|
+
? state.brands
|
|
121
|
+
: (await sdk.products.getBrands()) || []
|
|
122
|
+
: ssrBrands;
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
console.log('error on fetching brands for space: ', e.toString());
|
|
126
|
+
setFetchingContent(false);
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
fees =
|
|
130
|
+
!!state.fees && state.fees.length
|
|
131
|
+
? state.fees
|
|
132
|
+
: !!api && api.org === 'gr'
|
|
133
|
+
? (await sdk.products.getFees()) || []
|
|
134
|
+
: [];
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
console.log('error on fetching fees for space: ', e.toString());
|
|
138
|
+
setFetchingContent(false);
|
|
139
|
+
}
|
|
140
|
+
setState((prevState) => (Object.assign(Object.assign(Object.assign({}, prevState), (!!data ? data : {})), { categories,
|
|
141
|
+
categoryTree,
|
|
142
|
+
attributes,
|
|
143
|
+
brands,
|
|
144
|
+
fees })));
|
|
145
|
+
setFetchingContent(false);
|
|
146
|
+
};
|
|
147
|
+
if (!fetchingContent) {
|
|
148
|
+
setFetchingContent(true);
|
|
149
|
+
getContent();
|
|
150
|
+
}
|
|
151
|
+
}, [sdk, state.currency]);
|
|
152
|
+
(0, react_1.useEffect)(() => {
|
|
153
|
+
const storageCurrency = localStorage.getItem('currency');
|
|
154
|
+
if ((!!storageCurrency && storageCurrency === 'CAD') || storageCurrency === 'USD') {
|
|
155
|
+
setCurrency(storageCurrency);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
localStorage.setItem('currency', state.currency);
|
|
159
|
+
}
|
|
160
|
+
}, []);
|
|
161
|
+
(0, react_1.useEffect)(() => {
|
|
162
|
+
if ((!!state.currency && state.currency === 'CAD') || state.currency === 'USD') {
|
|
163
|
+
localStorage.setItem('currency', state.currency);
|
|
164
|
+
}
|
|
165
|
+
}, [state.currency]);
|
|
166
|
+
return ((0, jsx_runtime_1.jsx)(_1.default.Provider, Object.assign({ value: Object.assign(Object.assign({}, state), { calculateAmountByCurrency: calculateAmountByCurrency, setCurrency: setCurrency, fetchProductSDK: fetchProductSDK }) }, { children: !!state.website_in_maintenance &&
|
|
167
|
+
!!maintenanceComponent &&
|
|
168
|
+
!!!process.env.IS_TEST_ENV &&
|
|
169
|
+
!!!process.env.IS_STAGING
|
|
170
|
+
? maintenanceComponent
|
|
171
|
+
: children })));
|
|
172
|
+
}
|
|
173
|
+
exports.default = DataContextProvider;
|
|
174
174
|
//# sourceMappingURL=DataContextProvider.js.map
|