@weareconceptstudio/account 0.3.7 → 0.3.8

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.
Files changed (50) hide show
  1. package/dist/components/Loader/index.d.ts +2 -1
  2. package/dist/components/Loader/index.js +17 -6
  3. package/dist/components/Loader/style.js +32 -9
  4. package/dist/components/TotalCheckout/BalanceComp/index.js +1 -3
  5. package/dist/components/TotalCheckout/PromoCodeComp/index.js +1 -1
  6. package/dist/components/TotalCheckout/index.js +5 -5
  7. package/dist/modules/account/AccountTemplate/index.js +4 -1
  8. package/dist/modules/account/AccountTemplate/style.js +5 -3
  9. package/dist/modules/address/AddressForm/index.js +2 -2
  10. package/dist/modules/address/AddressItem/index.js +1 -1
  11. package/dist/modules/address/AddressProvider.js +3 -3
  12. package/dist/modules/address/SelectAddressPopup/index.js +1 -1
  13. package/dist/modules/cart/CartTemplate/Skeleton/index.d.ts +1 -2
  14. package/dist/modules/cart/CartTemplate/Skeleton/index.js +6 -4
  15. package/dist/modules/cart/CartTemplate/index.d.ts +1 -2
  16. package/dist/modules/cart/CartTemplate/index.js +1 -2
  17. package/dist/modules/checkout/CheckoutProvider.js +29 -5
  18. package/dist/modules/checkout/CheckoutTemplate/index.js +2 -3
  19. package/dist/modules/order/OrderDetails/index.js +2 -2
  20. package/dist/modules/order/OrderIndividualTemplate/index.js +1 -2
  21. package/dist/modules/order/OrderStatus/index.js +3 -20
  22. package/dist/modules/order/OrderStatus/style.d.ts +2 -0
  23. package/dist/modules/order/OrderStatus/style.js +44 -0
  24. package/dist/modules/order/OrdersList/OrderItem/index.js +1 -3
  25. package/dist/modules/order/OrdersList/index.js +4 -2
  26. package/dist/modules/payment/AddNewCard/index.d.ts +1 -2
  27. package/dist/modules/payment/AddNewCard/index.js +4 -2
  28. package/dist/modules/payment/Card/index.d.ts +1 -2
  29. package/dist/modules/payment/Card/index.js +4 -2
  30. package/dist/modules/payment/Payment/index.js +1 -11
  31. package/dist/modules/payment/PaymentMethodItem/index.d.ts +1 -1
  32. package/dist/modules/payment/PaymentMethodItem/index.js +5 -6
  33. package/dist/modules/payment/PaymentMethodItem/style.js +25 -14
  34. package/dist/modules/payment/PaymentMethods/index.js +1 -1
  35. package/dist/modules/payment/PaymentMethods/style.js +8 -8
  36. package/dist/modules/payment/PaymentWrap/index.d.ts +1 -2
  37. package/dist/modules/payment/PaymentWrap/index.js +3 -3
  38. package/dist/modules/payment/PaymentWrap/style.js +2 -15
  39. package/dist/modules/payment/SelectPaymentMethodPopup/index.js +1 -1
  40. package/dist/modules/payment/SelectedPayment/index.js +2 -19
  41. package/dist/styles/theme.js +16 -1
  42. package/dist/styles/variables.js +22 -0
  43. package/dist/translations/en.d.ts +7 -2
  44. package/dist/translations/en.js +8 -2
  45. package/dist/translations/hy.d.ts +7 -2
  46. package/dist/translations/hy.js +8 -2
  47. package/dist/translations/index.d.ts +21 -6
  48. package/dist/translations/ru.d.ts +7 -2
  49. package/dist/translations/ru.js +8 -2
  50. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  export default Loader;
2
- declare function Loader({ className }: {
2
+ declare function Loader({ className, pathname }: {
3
3
  className: any;
4
+ pathname: any;
4
5
  }): React.JSX.Element;
5
6
  import React from 'react';
@@ -1,18 +1,29 @@
1
1
  'use client';
2
- import React, { useState, useEffect } from 'react';
2
+ import React, { useState, useEffect, useRef } from 'react';
3
3
  //* Styles
4
4
  import LoaderStyle from './style';
5
- const Loader = ({ className }) => {
5
+ const Loader = ({ className, pathname }) => {
6
6
  //! State
7
7
  const [loaderState, setLoaderState] = useState('');
8
+ const intervalStart = useRef();
9
+ const intervalEnd = useRef();
10
+ const intervalRerender = useRef();
8
11
  useEffect(() => {
9
- setTimeout(() => {
12
+ intervalStart.current = setTimeout(() => {
10
13
  setLoaderState('start');
11
14
  }, 100);
12
- setTimeout(() => {
13
- setLoaderState('end');
15
+ intervalEnd.current = setTimeout(() => {
16
+ setLoaderState('start end');
14
17
  }, 2000);
15
- }, []);
18
+ intervalRerender.current = setTimeout(() => {
19
+ setLoaderState('initial');
20
+ }, 2200);
21
+ return () => {
22
+ clearTimeout(intervalStart.current);
23
+ clearTimeout(intervalEnd.current);
24
+ clearTimeout(intervalRerender.current);
25
+ };
26
+ }, [pathname]);
16
27
  return (React.createElement(LoaderStyle, { className: `${loaderState || ''}` },
17
28
  React.createElement("div", { className: `loader ${className || ''}` },
18
29
  React.createElement("div", { className: 'cont' },
@@ -3,6 +3,9 @@ const LoaderStyle = styled.div `
3
3
  --sizeCircle: calc(var(--sp12x) + var(--sp0-5x));
4
4
  --sizeLine: var(--sp2-5x);
5
5
 
6
+ opacity: 1;
7
+ visibility: visible;
8
+
6
9
  &:before {
7
10
  content: '';
8
11
  position: absolute;
@@ -12,7 +15,8 @@ const LoaderStyle = styled.div `
12
15
  height: 100%;
13
16
  background-color: var(--account_backgroundColor);
14
17
  z-index: 1;
15
- transition: 1s linear;
18
+ opacity: 1;
19
+ visibility: visible;
16
20
  }
17
21
 
18
22
  .loader {
@@ -25,6 +29,8 @@ const LoaderStyle = styled.div `
25
29
  height: 100vh;
26
30
  z-index: 10;
27
31
  pointer-events: none;
32
+ opacity: 1;
33
+ visibility: visible;
28
34
 
29
35
  &:before {
30
36
  background-color: var(--account_backgroundColor);
@@ -37,24 +43,22 @@ const LoaderStyle = styled.div `
37
43
  left: 0;
38
44
  width: 100%;
39
45
  height: 100%;
40
- transition: 1s linear 1.8s;
46
+ opacity: 1;
41
47
  }
42
48
 
43
49
  .cont {
44
50
  position: absolute;
45
51
  top: 50%;
46
52
  left: 50%;
47
- transform: translate(-50%, -50%);
53
+ transform: translate(-50%, -50%) scale(1);
48
54
  width: var(--sizeCircle);
49
55
  height: var(--sizeCircle);
50
- transition: 0.5s linear 1.5s;
51
56
 
52
57
  span {
53
58
  background-color: var(--account_primaryColor1);
54
59
  height: var(--sizeLine);
55
60
  width: 0;
56
61
  position: absolute;
57
- transition: 0.5s ease-out 1s;
58
62
 
59
63
  &.line-top {
60
64
  bottom: calc(100% + var(--sizeLine));
@@ -83,32 +87,50 @@ const LoaderStyle = styled.div `
83
87
  width: 100%;
84
88
  height: 100%;
85
89
  background: linear-gradient(45deg, rgba(167, 0, 222, 1) 0%, rgba(254, 0, 133, 1) 100%);
86
- transition: 0.5s ease-in-out;
87
90
  }
88
91
  }
89
92
  }
90
93
  }
91
94
 
95
+ &.initial {
96
+ opacity: 0;
97
+ visibility: hidden;
98
+ transition: 0s linear;
99
+
100
+ &:before {
101
+ visibility: hidden;
102
+ }
103
+ }
104
+
92
105
  &.start {
93
106
  &:before {
94
- opacity: 0;
107
+ opacity: 1;
108
+ visibility: visible;
95
109
  }
96
110
 
97
111
  .loader {
112
+ opacity: 1;
113
+ visibility: visible;
114
+
98
115
  &:before {
99
- opacity: 0;
116
+ opacity: 1;
117
+ transition: 1s linear 1.8s;
118
+ visibility: visible;
100
119
  }
101
120
 
102
121
  .cont {
103
122
  transform: translate(-50%, -50%) scale(0);
123
+ transition: 0.5s linear 1.5s;
104
124
 
105
125
  span {
106
126
  width: 100%;
127
+ transition: 0.5s ease-out 1s;
107
128
  }
108
129
 
109
130
  .circle {
110
131
  &:before {
111
- top: 0;
132
+ top: 0%;
133
+ transition: 0.5s ease-in-out;
112
134
  }
113
135
  }
114
136
  }
@@ -120,6 +142,7 @@ const LoaderStyle = styled.div `
120
142
  .loader {
121
143
  opacity: 0;
122
144
  visibility: hidden;
145
+ transition: 0.2s linear;
123
146
  }
124
147
  }
125
148
 
@@ -15,9 +15,7 @@ const BalanceComp = ({ isBalance = true, currency, balance, useBalance, balanceH
15
15
  balanceHandler(values.balance);
16
16
  };
17
17
  return isBalance ? (React.createElement(BalanceCompStyle, { className: `collapse-distance ${getItemCount && balance ? ' ' : 'disable'}` },
18
- React.createElement(CollapseItem, { disable: disable,
19
- // status={'open'}
20
- title: React.createElement(React.Fragment, null,
18
+ React.createElement(CollapseItem, { disable: useBalance || disable, title: React.createElement(React.Fragment, null,
21
19
  React.createElement("div", { className: 'inner-wrapper-icon' },
22
20
  React.createElement("svg", { width: '12', height: '12', fill: 'none', viewBox: '0 0 12 12', xmlns: 'http://www.w3.org/2000/svg' },
23
21
  React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
@@ -14,7 +14,7 @@ const PromoCodeComp = ({ isPromoCode = true, promo_code, getItemCount }) => {
14
14
  setCouponCode(true);
15
15
  setDisable(true);
16
16
  };
17
- return isPromoCode ? (React.createElement(PromoCodeCompStyle, { className: `collapse-distance ${getItemCount ? ' ' : ' disable'}` },
17
+ return isPromoCode ? (React.createElement(PromoCodeCompStyle, { className: `collapse-distance ${getItemCount ? '' : 'disable'}` },
18
18
  React.createElement(CollapseItem, { disable: disable, title: React.createElement(React.Fragment, null,
19
19
  React.createElement("div", { className: 'inner-wrapper-icon' },
20
20
  React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '12', height: '12', viewBox: '0 0 12 12', fill: 'none' },
@@ -13,9 +13,9 @@ import TotalCheckoutStyle from './style';
13
13
  import SkeletonTotalCheckout from './Skeleton';
14
14
  // TODO: Promo code
15
15
  const promo_code = '10% of first order';
16
- const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, isCheckout = false }) => {
16
+ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps }) => {
17
17
  const { currency, useCart, useUser } = useAccountContext();
18
- const { fillCheckoutData, fillCart } = useCheckoutContext();
18
+ const { fillCheckoutData, fillCart, checkoutBtnDisabled, isCheckoutPage } = useCheckoutContext();
19
19
  const { addressLoading } = useAddressContext();
20
20
  const { user } = useUser();
21
21
  const { itemsCount, shippingCost, freeShippingRange, shippingCostValue, total, subtotal, useBalance, loading } = useCart();
@@ -70,12 +70,12 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
70
70
  React.createElement("div", { className: `od-item-wrap` },
71
71
  React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-total`, text: `total` }),
72
72
  React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-currency2`, text: itemsCount ? handlePriceCheckFunc(total, currency) : `0 ${currency}` })),
73
- !isCheckout ? (React.createElement(FreeShippingComp, { currency: currency, shippingCost: shippingCost, shippingCostValue: shippingCostValue, freeShippingRange: freeShippingRange })) : null,
73
+ !isCheckoutPage ? (React.createElement(FreeShippingComp, { currency: currency, shippingCost: shippingCost, shippingCostValue: shippingCostValue, freeShippingRange: freeShippingRange })) : null,
74
74
  React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
75
75
  React.createElement("div", { ref: innerCollapseRef },
76
76
  React.createElement(BalanceComp, { getItemCount: itemsCount, balance: user?.balance || 0, currency: currency, balanceHandler: handleBalance, useBalance: useBalance }),
77
77
  React.createElement(PromoCodeComp, { getItemCount: itemsCount, promo_code: promo_code }))),
78
- isCheckout && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, { fillCheckoutData: fillCheckoutData }) : null,
79
- React.createElement(AccountButton, { loading: buttonProps.loadingButton, url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, className: `sticky-wrap-btn`, disabled: buttonProps.disabled, onClick: () => buttonProps.handleClick && buttonProps.handleClick() }))) : (React.createElement(SkeletonTotalCheckout, null))))));
78
+ isCheckoutPage && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, { fillCheckoutData: fillCheckoutData }) : null,
79
+ React.createElement(AccountButton, { loading: buttonProps.loadingButton, url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, className: `sticky-wrap-btn`, disabled: checkoutBtnDisabled, onClick: () => buttonProps.handleClick && buttonProps.handleClick() }))) : (React.createElement(SkeletonTotalCheckout, null))))));
80
80
  });
81
81
  export default TotalCheckout;
@@ -18,6 +18,9 @@ const AccountTemplate = ({ isFullWidth = true, menuOptions = [], children }) =>
18
18
  return menuOptions.map((menuItem, index) => (React.createElement(Link, { key: index, href: menuItem.url, className: `menu-item ${menuItem.className ? menuItem.className : ''}`, ...menuItem.options },
19
19
  React.createElement(Text, { tag: `span`, className: `account-p account-p1 account-font-bold sidebar-item`, text: menuItem.name }))));
20
20
  }, [menuOptions]);
21
+ const loadingComponent = useMemo(() => {
22
+ return (React.createElement(Loader, { className: 'account', pathname: window.location.pathname }));
23
+ }, [window.location.pathname]);
21
24
  return user && isLoggedIn ? (React.createElement(Page, { className: 'account use-account' },
22
25
  React.createElement(AccountStyle, { className: 'account-container' },
23
26
  React.createElement("div", { className: 'account-wrap' },
@@ -30,7 +33,7 @@ const AccountTemplate = ({ isFullWidth = true, menuOptions = [], children }) =>
30
33
  React.createElement(Text, { text: 'signOut', onClick: signOut, className: 'account-p account-p1 account-error-color account-font-bold sign-out' }))),
31
34
  lineStore,
32
35
  React.createElement("div", { className: `right-bar` },
33
- React.createElement(Loader, { className: 'account' }),
36
+ loadingComponent,
34
37
  React.createElement("div", { className: `max-width-wrap ${isFullWidth ? 'full-max-width' : ''}` }, children)))))) : null;
35
38
  };
36
39
  export default AccountTemplate;
@@ -242,7 +242,8 @@ const AccountStyle = styled.section `
242
242
 
243
243
  .right-bar {
244
244
  height: 100vh;
245
- animation: heightMobile 1s ease-out 1.8s forwards;
245
+ animation: heightMobile 1s ease-out 1.6s forwards;
246
+ overflow: hidden;
246
247
 
247
248
  @keyframes heightMobile {
248
249
  0% {
@@ -293,8 +294,9 @@ const AccountStyle = styled.section `
293
294
  }
294
295
 
295
296
  .right-bar {
296
- height: 150vh;
297
- animation: heightMobile 1s ease-out 1.8s forwards;
297
+ height: 100vh;
298
+ animation: heightMobile 1s ease-out 1.6s forwards;
299
+ overflow: hidden;
298
300
 
299
301
  @keyframes heightMobile {
300
302
  0% {
@@ -7,7 +7,7 @@ import AccountButton from '../../../components/AccountButton';
7
7
  import { CheckboxIcon, CheckboxCheckedIcon } from '../../../utils/icons';
8
8
  //* Style
9
9
  import AddressFormStyle from './style';
10
- const AddressForm = Memo(({ title, data, type, isCheckoutPage = false }) => {
10
+ const AddressForm = Memo(({ title, data, type }) => {
11
11
  const { formFields, createAddress, updateAddress } = useAddressContext();
12
12
  const { closePopup } = useUi();
13
13
  //! States
@@ -22,7 +22,7 @@ const AddressForm = Memo(({ title, data, type, isCheckoutPage = false }) => {
22
22
  };
23
23
  setIsDisabled(true);
24
24
  return (!isDisabled &&
25
- eval(data?.id ? `updateAddress({data: newData, addressId: data.id, type, isCheckoutPage})` : `createAddress({data: newData, type, isCheckoutPage})`).then(() => {
25
+ eval(data?.id ? `updateAddress({data: newData, addressId: data.id, type})` : `createAddress({data: newData, type})`).then(() => {
26
26
  closePopup();
27
27
  }));
28
28
  }, [data, isChecked, createAddress, updateAddress, isDisabled]);
@@ -18,7 +18,7 @@ const AddressItem = ({ type, title, data, checkout_review, select_address, onCli
18
18
  });
19
19
  }, [data]);
20
20
  const handleEditAddressPopup = useCallback(() => {
21
- openPopup(React.createElement(AddressForm, { title: type === 'billing' ? `updateYourBillingAddress` : type == 'shipping' ? `updateYourShippingAddress` : 'updateYourAddress', data: data, isCheckoutPage: select_address }), {
21
+ openPopup(React.createElement(AddressForm, { title: type === 'billing' ? `updateYourBillingAddress` : type == 'shipping' ? `updateYourShippingAddress` : 'updateYourAddress', data: data }), {
22
22
  accountIcon: true,
23
23
  });
24
24
  }, [data]);
@@ -8,7 +8,7 @@ export const useAddressContext = () => {
8
8
  };
9
9
  export const AddressProvider = ({ addressType, addressFormFields = [], useUser, children }) => {
10
10
  const { isLoggedIn } = useUser();
11
- const { fillCheckoutData, fillCart } = useCheckoutContext();
11
+ const { fillCheckoutData, fillCart, isCheckoutPage } = useCheckoutContext();
12
12
  const [addressLoading, setAddressLoading] = useState(false);
13
13
  const [addresses, setAddresses] = useState(addressType ? { billing: [], shipping: [] } : []);
14
14
  const [selectedAddresses, setSelectedAddresses] = useState(addressType ? { billing: {}, shipping: {} } : {});
@@ -35,7 +35,7 @@ export const AddressProvider = ({ addressType, addressFormFields = [], useUser,
35
35
  });
36
36
  }
37
37
  }, [isLoggedIn]);
38
- const createAddress = async ({ data, type, isCheckoutPage }) => {
38
+ const createAddress = async ({ data, type }) => {
39
39
  return await api.post('addresses', data).then((res) => {
40
40
  if (addressType) {
41
41
  }
@@ -51,7 +51,7 @@ export const AddressProvider = ({ addressType, addressFormFields = [], useUser,
51
51
  }
52
52
  });
53
53
  };
54
- const updateAddress = async ({ data, addressId, type, isCheckoutPage }) => {
54
+ const updateAddress = async ({ data, addressId, type }) => {
55
55
  return await api.put(`addresses/${addressId}`, data).then((res) => {
56
56
  if (addressType) {
57
57
  }
@@ -18,7 +18,7 @@ const SelectAddressPopup = Memo(({ title, type }) => {
18
18
  const [refElement, setRefElement] = useState();
19
19
  const resize = useResizeObserver(flexWrapperRef.current ? [...[...flexWrapperRef.current.children].map((item) => item)] : null);
20
20
  const handleNewAddressPopup = () => {
21
- openPopup(React.createElement(AddressForm, { title: type == 'shipping' ? `addNewShippingAddress` : type == 'billing' ? 'addNewBillingAddress' : 'addNewAddress', type: type, isCheckoutPage: true }), {
21
+ openPopup(React.createElement(AddressForm, { title: type == 'shipping' ? `addNewShippingAddress` : type == 'billing' ? 'addNewBillingAddress' : 'addNewAddress', type: type }), {
22
22
  accountIcon: true,
23
23
  });
24
24
  };
@@ -1,6 +1,5 @@
1
1
  export default SkeletonCartTemplate;
2
- declare function SkeletonCartTemplate({ shopUrl, isCheckout }: {
2
+ declare function SkeletonCartTemplate({ shopUrl }: {
3
3
  shopUrl: any;
4
- isCheckout: any;
5
4
  }): React.JSX.Element;
6
5
  import React from 'react';
@@ -1,19 +1,21 @@
1
- import { useUi } from '@weareconceptstudio/core';
2
1
  import React from 'react';
2
+ import { useUi } from '@weareconceptstudio/core';
3
+ import { useCheckoutContext } from '../../../checkout';
3
4
  //* Styles
4
5
  import SkeletonCartTemplateStyle from './style';
5
6
  //* Files Skeleton
6
7
  import { skeletonCategoryName, skeletonMenuTitle, skeletonShopUrl, skeletonCategoryNameAdapting } from './icons';
7
8
  //*Component
8
9
  import SkeletonItemCart from './SkeletonItem';
9
- const SkeletonCartTemplate = ({ shopUrl, isCheckout }) => {
10
+ const SkeletonCartTemplate = ({ shopUrl }) => {
10
11
  const { winWidth } = useUi();
11
- return (React.createElement(SkeletonCartTemplateStyle, { className: isCheckout ? 'checkout-style' : ' ' },
12
+ const { isCheckoutPage } = useCheckoutContext();
13
+ return (React.createElement(SkeletonCartTemplateStyle, { className: isCheckoutPage ? 'checkout-style' : ' ' },
12
14
  React.createElement("div", { className: 'left-bar' },
13
15
  shopUrl ? React.createElement("div", { className: 'wrapper-url' }, skeletonShopUrl) : React.createElement(React.Fragment, null),
14
16
  React.createElement("div", { className: 'wrapper-cat' },
15
17
  React.createElement("div", { className: 'title-wrapper' }, skeletonMenuTitle),
16
- isCheckout ? null : React.createElement("div", { className: 'order-items-line' }),
18
+ isCheckoutPage ? null : React.createElement("div", { className: 'order-items-line' }),
17
19
  winWidth < 1510 ? (React.createElement("div", { className: 'category-name' }, skeletonCategoryNameAdapting)) : (React.createElement("div", { className: 'category-name' }, Array.from({ length: 4 }).map((_, i) => {
18
20
  return React.createElement("div", { key: i }, skeletonCategoryName);
19
21
  })))),
@@ -1,8 +1,7 @@
1
1
  export default CartTemplate;
2
- declare function CartTemplate({ children, actions, btnDisabled, checkoutUrl, moreMenu }: {
2
+ declare function CartTemplate({ children, actions, checkoutUrl, moreMenu }: {
3
3
  children: any;
4
4
  actions: any;
5
- btnDisabled: any;
6
5
  checkoutUrl?: string;
7
6
  moreMenu: any;
8
7
  }): React.JSX.Element;
@@ -12,7 +12,7 @@ const leftArrow = (React.createElement("svg", { fill: 'none', viewBox: '0 0 16 1
12
12
  import CartTemplateStyle from './style';
13
13
  //* Skeleton
14
14
  import SkeletonCartTemplate from './Skeleton';
15
- const CartTemplate = ({ children, actions, btnDisabled, checkoutUrl = '/checkout/', moreMenu }) => {
15
+ const CartTemplate = ({ children, actions, checkoutUrl = '/checkout/', moreMenu }) => {
16
16
  const { shopUrl, useCart } = useAccountContext();
17
17
  const { translate } = useTranslation();
18
18
  const { items, itemsCount, shippingCost, loading, subtotal, total, freeShippingRange, shippingCostValue } = useCart();
@@ -21,7 +21,6 @@ const CartTemplate = ({ children, actions, btnDisabled, checkoutUrl = '/checkout
21
21
  React.createElement(CartTemplateStyle, null,
22
22
  React.createElement(TotalCheckout, { total: total, loading: loading, subtotal: subtotal, itemsCount: itemsCount, shippingCost: shippingCost, freeShippingRange: freeShippingRange, shippingCostValue: shippingCostValue, buttonProps: {
23
23
  url: checkoutUrl,
24
- disabled: btnDisabled,
25
24
  text: 'proceedToCheckout',
26
25
  } }, !loading ? (itemsCount > 0 ? (React.createElement(React.Fragment, null,
27
26
  shopUrl ? (React.createElement(AccountButton, { url: shopUrl, btnType: `purple-text`, className: `back-to-shop` },
@@ -1,5 +1,5 @@
1
- import React, { createContext, useContext, useState, useRef, useEffect, useCallback } from 'react';
2
- import { api, useTranslation } from '@weareconceptstudio/core';
1
+ import React, { createContext, useContext, useState, useRef, useEffect, useCallback, useMemo } from 'react';
2
+ import { api, useTranslation, isNumeric } from '@weareconceptstudio/core';
3
3
  import { useAccountContext } from '../../AccountProvider';
4
4
  const CheckoutContext = createContext(null);
5
5
  export const useCheckoutContext = () => {
@@ -9,16 +9,30 @@ export const useCheckoutContext = () => {
9
9
  export const CheckoutProvider = ({ children }) => {
10
10
  const { selectedLang } = useTranslation();
11
11
  const { useCart, useUser } = useAccountContext();
12
- const { getCart } = useCart();
12
+ const { getCart, itemsCount } = useCart();
13
13
  const { user } = useUser();
14
+ const form = useRef();
14
15
  const [checkoutData, setCheckoutData] = useState({
15
16
  addressId: null,
16
17
  useBalance: null,
17
18
  note: '',
18
19
  paymentType: user?.default_payment_method || null,
19
20
  });
20
- const form = useRef();
21
21
  const [idramForm, setIdramForm] = useState();
22
+ const isCheckoutPage = useMemo(() => {
23
+ return window.location.href.includes('checkout');
24
+ }, [window.location.href]);
25
+ const checkoutBtnDisabled = useMemo(() => {
26
+ let isDisabled = false;
27
+ if (isCheckoutPage && isNumeric(checkoutData.paymentType)) {
28
+ const selectedCard = user?.cards?.find((card) => card.id == checkoutData.paymentType);
29
+ isDisabled = selectedCard.is_expired;
30
+ }
31
+ if (!itemsCount) {
32
+ isDisabled = true;
33
+ }
34
+ return isDisabled;
35
+ }, [checkoutData.paymentType, user, isCheckoutPage, itemsCount]);
22
36
  const fillCheckoutData = (key, value) => {
23
37
  setCheckoutData((prev) => ({
24
38
  ...prev,
@@ -33,7 +47,15 @@ export const CheckoutProvider = ({ children }) => {
33
47
  });
34
48
  }, [checkoutData]);
35
49
  const handleCheckout = async () => {
36
- return await api.post('checkout', checkoutData).then((res) => {
50
+ let data = { ...checkoutData };
51
+ if (isNumeric(checkoutData.paymentType)) {
52
+ data.paymentType = 'credit_card';
53
+ data.card_id = Number(checkoutData.paymentType);
54
+ }
55
+ if (checkoutData.paymentType == 'credit_card') {
56
+ data.card_id = 0;
57
+ }
58
+ return await api.post('checkout', data).then((res) => {
37
59
  if (res.redirect_url) {
38
60
  window.location.href = res.redirect_url;
39
61
  }
@@ -60,6 +82,8 @@ export const CheckoutProvider = ({ children }) => {
60
82
  fillCheckoutData,
61
83
  handleCheckout,
62
84
  fillCart,
85
+ checkoutBtnDisabled,
86
+ isCheckoutPage,
63
87
  } },
64
88
  children,
65
89
  idramForm));
@@ -43,9 +43,8 @@ const CheckoutTemplate = () => {
43
43
  return (React.createElement(Page, { className: 'checkout use-account' },
44
44
  React.createElement(AccountContainer, { className: `second-version` },
45
45
  React.createElement(CheckoutTemplateStyle, null,
46
- React.createElement(TotalCheckout, { isCheckout: true, isShipping: checkStep.isShipping, buttonProps: {
46
+ React.createElement(TotalCheckout, { isShipping: checkStep.isShipping, buttonProps: {
47
47
  url: false,
48
- disabled: false,
49
48
  handleClick: handleCheckoutBtn,
50
49
  type: checkStep.isShipping ? 'submit' : 'button',
51
50
  text: checkStep.isShipping ? 'proceedToCheckout' : 'proceedToPayment',
@@ -55,6 +54,6 @@ const CheckoutTemplate = () => {
55
54
  checkStep.isShipping ? React.createElement(StepShipping, { firstStepFormRef: firstStepFormRef }) : React.createElement(StepReview, { items: items }))) : (React.createElement(React.Fragment, null,
56
55
  React.createElement(SequenceSkeleton, { className: 'sequence-checkout-template' }),
57
56
  React.createElement(SkeletonAddressSelect, { className: 'address-checkout-template' }),
58
- React.createElement(SkeletonCartTemplate, { isCheckout: true }))))))));
57
+ React.createElement(SkeletonCartTemplate, null))))))));
59
58
  };
60
59
  export default CheckoutTemplate;
@@ -1,8 +1,8 @@
1
1
  import React, { memo } from 'react';
2
- import { handlePriceCheckFunc, numToLocalString, Text, useTranslation } from '@weareconceptstudio/core';
2
+ import { handlePriceCheckFunc, Text, useTranslation } from '@weareconceptstudio/core';
3
3
  import { useAccountContext } from '../../../AccountProvider';
4
- import OrderDetailsStyle from './style';
5
4
  import OrderStatus from '../OrderStatus';
5
+ import OrderDetailsStyle from './style';
6
6
  const OrderDetails = memo(({ className, status, date, orderNumber, itemsCount, total, shippingCost, usedBalance }) => {
7
7
  const { translate } = useTranslation();
8
8
  const { currency } = useAccountContext();
@@ -7,7 +7,6 @@ import OrderedItems from '../OrderedItems';
7
7
  import { ShippingBillingInfo } from '../../address';
8
8
  //* Style
9
9
  import OrderIndividualTemplateStyle from './style';
10
- // TODO: status change
11
10
  const OrderIndividualTemplate = ({ uniqueKey }) => {
12
11
  const [data, setData] = useState();
13
12
  const [loading, setLoading] = useState(true);
@@ -23,6 +22,6 @@ const OrderIndividualTemplate = ({ uniqueKey }) => {
23
22
  React.createElement("div", { className: `details-shipping-billing-wrap` },
24
23
  React.createElement(OrderDetails, { className: `col-50`, ...data }),
25
24
  React.createElement(ShippingBillingInfo, { className: `col-50`, billing_address: data?.billingAddress, shipping_address: data?.shippingAddress })),
26
- React.createElement(OrderedItems, { data: data.items, dataId: data.id, status: data.status })))) : null;
25
+ React.createElement(OrderedItems, { dataId: data.id, data: data.items, status: data.status })))) : null;
27
26
  };
28
27
  export default OrderIndividualTemplate;
@@ -1,25 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Text } from '@weareconceptstudio/core';
3
- {
4
- /* {data.status === 'delivered' ? (
5
- <Text
6
- className={`account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item delivered`}
7
- text={'delivered'}
8
- />
9
- ) : data.status === 'canceled' ? (
10
- <Text
11
- className={`account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item canceled`}
12
- text={'canceled'}
13
- />
14
- ) : (
15
- <Text
16
- className={`account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item in-progress`}
17
- text={'inProgress'}
18
- />
19
- )} */
20
- }
21
- // In order individual added className value
3
+ import OrderStatusStyle from './style';
22
4
  const OrderStatus = ({ status, className = '' }) => {
23
- return (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item ${status} ${className}`, text: status }));
5
+ return (React.createElement(OrderStatusStyle, null,
6
+ React.createElement(Text, { className: `account-p account-p4 account-font-bold status-item ${status} ${className}`, text: status })));
24
7
  };
25
8
  export default OrderStatus;
@@ -0,0 +1,2 @@
1
+ export default OrderStatusStyle;
2
+ declare const OrderStatusStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,44 @@
1
+ import styled from 'styled-components';
2
+ const OrderStatusStyle = styled.div `
3
+ .status-item {
4
+ /* //! Default */
5
+ color: var(--account_backgroundColor);
6
+ background-color: var(--account_primaryColor1);
7
+
8
+ &.canceled {
9
+ color: var(--account_statusCanceledColor);
10
+ background-color: var(--account_statusCanceledBgColor);
11
+ }
12
+
13
+ &.accepted {
14
+ color: var(--account_statusAcceptedColor);
15
+ background-color: var(--account_statusAcceptedBgColor);
16
+ }
17
+
18
+ &.processing {
19
+ color: var(--account_statusProcessingColor);
20
+ background-color: var(--account_statusProcessingBgColor);
21
+ }
22
+
23
+ &.delivered {
24
+ color: var(--account_statusDeliveredColor);
25
+ background-color: var(--account_statusDeliveredBgColor);
26
+ }
27
+
28
+ &.payment_failed {
29
+ color: var(--account_statusPaymentFailedColor);
30
+ background-color: var(--account_statusPaymentFailedBgColor);
31
+ }
32
+
33
+ &.pending {
34
+ color: var(--account_statusPendingColor);
35
+ background-color: var(--account_statusPendingBgColor);
36
+ }
37
+
38
+ &.completed {
39
+ color: var(--account_statusCompletedColor);
40
+ background-color: var(--account_statusCompletedBgColor);
41
+ }
42
+ }
43
+ `;
44
+ export default OrderStatusStyle;
@@ -1,10 +1,8 @@
1
1
  import React, { memo as Memo } from 'react';
2
2
  import { handlePriceCheckFunc, Text } from '@weareconceptstudio/core';
3
- import { useAccountContext } from '../../../../AccountProvider';
4
3
  import { AccountButton } from '../../../../components';
5
4
  import OrderStatus from '../../OrderStatus';
6
- const OrderItem = Memo(({ data }) => {
7
- const { currency } = useAccountContext();
5
+ const OrderItem = Memo(({ data, currency }) => {
8
6
  return (React.createElement("div", { className: `order-table-item-wrap` },
9
7
  React.createElement("div", { className: `col-item od-col-1 nowrap` },
10
8
  React.createElement(Text, { className: `account-p account-p4 account-font-medium account-primary-color1`, text: data.date })),
@@ -1,5 +1,6 @@
1
1
  import React, { useMemo, useState, useEffect, useCallback } from 'react';
2
2
  import { Text, useTranslation, useUi, api, handlePriceCheckFunc } from '@weareconceptstudio/core';
3
+ import { useAccountContext } from '../../../AccountProvider';
3
4
  //* Components
4
5
  import { Pagination, AccountButton } from '../../../components';
5
6
  import OrderItem from './OrderItem';
@@ -10,6 +11,7 @@ import OrdersListStyle from './style';
10
11
  const OrdersList = () => {
11
12
  const { translate } = useTranslation();
12
13
  const { winWidth } = useUi();
14
+ const { currency } = useAccountContext();
13
15
  const [loading, setLoading] = useState(true);
14
16
  const [data, setData] = useState([]);
15
17
  const [currentPage, setCurrentPage] = useState(1);
@@ -43,7 +45,7 @@ const OrdersList = () => {
43
45
  React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 nowrap align-right`, text: `totalPrice` })),
44
46
  React.createElement("div", { className: `order-table-title-wrap od-col-6` })),
45
47
  React.createElement("div", { className: `order-table-items-wrap` }, data.map((item, index) => {
46
- return (React.createElement(OrderItem, { key: index, data: item }));
48
+ return (React.createElement(OrderItem, { key: index, data: item, currency: currency }));
47
49
  })))) : (React.createElement("div", { className: `mobile-orders-wrap` }, data.map((item, index) => {
48
50
  return (React.createElement("div", { key: index, className: `mobile-order-item-wrap` },
49
51
  React.createElement("div", { className: `first-col-wrap` },
@@ -63,7 +65,7 @@ const OrdersList = () => {
63
65
  React.createElement(Text, { className: `account-p account-p4 account-font-regular account-primary-color1 value`, text: item.itemsCount })),
64
66
  React.createElement("div", { className: `left-item-wrap last` },
65
67
  React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1`, text: `${translate('totalPrice')}:` }),
66
- React.createElement(Text, { className: `account-p account-p4 account-font-regular account-primary-color1 value`, text: handlePriceCheckFunc(item.total, item.currency) }))),
68
+ React.createElement(Text, { className: `account-p account-p4 account-font-regular account-primary-color1 value`, text: handlePriceCheckFunc(item.total, currency) }))),
67
69
  React.createElement("div", { className: `right-wrap` },
68
70
  React.createElement(AccountButton, { text: 'viewOrder', btnType: `green-small-text`, url: `/account/order-history/${item.id}` })))));
69
71
  })));
@@ -1,6 +1,5 @@
1
1
  export default AddNewCard;
2
- declare function AddNewCard({ className, isCheckout }: {
2
+ declare function AddNewCard({ className }: {
3
3
  className: any;
4
- isCheckout: any;
5
4
  }): React.JSX.Element;
6
5
  import React from 'react';