@weareconceptstudio/account 0.2.8 → 0.2.9

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 (30) hide show
  1. package/dist/modules/account/AccountBalanceTemplate/HeroBalance/ProgressBalance/ProgressComponent/index.d.ts +2 -1
  2. package/dist/modules/account/AccountBalanceTemplate/HeroBalance/ProgressBalance/ProgressComponent/index.js +6 -8
  3. package/dist/modules/account/AccountBalanceTemplate/HeroBalance/ProgressBalance/ProgressComponent/style.js +9 -0
  4. package/dist/modules/account/AccountBalanceTemplate/HeroBalance/ProgressBalance/index.js +7 -5
  5. package/dist/modules/account/AccountBalanceTemplate/HistoryBalance/index.d.ts +3 -1
  6. package/dist/modules/account/AccountBalanceTemplate/HistoryBalance/index.js +6 -3
  7. package/dist/modules/account/AccountBalanceTemplate/HistoryBalance/style.js +21 -0
  8. package/dist/modules/account/AccountBalanceTemplate/StatusBalance/index.js +5 -24
  9. package/dist/modules/account/AccountBalanceTemplate/index.d.ts +2 -1
  10. package/dist/modules/account/AccountBalanceTemplate/index.js +2 -2
  11. package/dist/modules/address/AddressForm/index.js +2 -2
  12. package/dist/modules/address/AddressItem/index.js +3 -3
  13. package/dist/modules/address/AddressProvider.js +32 -17
  14. package/dist/modules/address/SelectAddressPopup/index.js +1 -1
  15. package/dist/modules/auth/ForgotPasswordTemplate/index.js +1 -3
  16. package/dist/modules/auth/ResetPasswordTemplate/ExpiredLink/index.d.ts +6 -0
  17. package/dist/modules/auth/ResetPasswordTemplate/ExpiredLink/index.js +20 -0
  18. package/dist/modules/auth/ResetPasswordTemplate/ExpiredLink/style.d.ts +2 -0
  19. package/dist/modules/auth/ResetPasswordTemplate/ExpiredLink/style.js +81 -0
  20. package/dist/modules/auth/ResetPasswordTemplate/index.d.ts +2 -1
  21. package/dist/modules/auth/ResetPasswordTemplate/index.js +41 -19
  22. package/dist/modules/checkout/CheckoutTemplate/index.js +2 -3
  23. package/dist/translations/en.d.ts +4 -0
  24. package/dist/translations/en.js +5 -0
  25. package/dist/translations/hy.d.ts +4 -0
  26. package/dist/translations/hy.js +5 -0
  27. package/dist/translations/index.d.ts +12 -0
  28. package/dist/translations/ru.d.ts +4 -0
  29. package/dist/translations/ru.js +5 -0
  30. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  export default ProgressComponent;
2
- declare function ProgressComponent({ round, value, maxValue, size, gapSize, strokeWidth, className, percent }: {
2
+ declare function ProgressComponent({ round, value, maxValue, size, gapSize, strokeWidth, className, percent, animated }: {
3
3
  round: any;
4
4
  value?: number;
5
5
  maxValue?: number;
@@ -8,5 +8,6 @@ declare function ProgressComponent({ round, value, maxValue, size, gapSize, stro
8
8
  strokeWidth: any;
9
9
  className: any;
10
10
  percent: any;
11
+ animated: any;
11
12
  }): React.JSX.Element;
12
13
  import React from 'react';
@@ -1,9 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  //* Styles
3
3
  import ProgressComponentStyle from './style';
4
- import { useUi } from '@weareconceptstudio/core';
5
- const ProgressComponent = ({ round, value = 50, maxValue = 100, size, gapSize, strokeWidth, className, percent }) => {
6
- const { winWidth } = useUi();
4
+ const ProgressComponent = ({ round, value = 50, maxValue = 100, size, gapSize, strokeWidth, className, percent, animated }) => {
7
5
  const [styleElement, setStyleElement] = useState(null);
8
6
  const [progressAnimation, setProgressAnimation] = useState(0);
9
7
  function getValue(value) {
@@ -21,21 +19,21 @@ const ProgressComponent = ({ round, value = 50, maxValue = 100, size, gapSize, s
21
19
  }
22
20
  }
23
21
  const sizeNumber = getValue(size || '--sizeProgress');
22
+ console.log(sizeNumber);
24
23
  const strokeWidthNumber = getValue(strokeWidth || '--strokeWidth');
25
24
  const gapSizeValue = getValue(gapSize || '--gapDistance');
26
25
  const radius = (sizeNumber - strokeWidthNumber) / 2;
27
26
  const circumference = 2 * Math.PI * radius;
28
27
  const progress = progressAnimation;
29
- // const progress = percent ? percent : (value / maxValue) * 100;
30
28
  const filledLength = (progress / 100) * circumference;
31
29
  useEffect(() => {
32
30
  setTimeout(() => {
33
31
  setProgressAnimation(percent ? percent : (value / maxValue) * 100);
34
- }, 10);
35
- }, []);
32
+ }, 0);
33
+ }, [percent]);
36
34
  return (React.createElement(ProgressComponentStyle, { ref: (element) => setStyleElement(element) }, sizeNumber ? (React.createElement("div", { className: `${className || ' '} progress-wrapper`, style: { position: 'relative', width: `${size}`, height: `${size}` } },
37
- React.createElement("svg", { width: sizeNumber, height: sizeNumber, viewBox: `0 0 ${sizeNumber} ${sizeNumber}`, style: { transform: 'rotate(-90deg)' } },
38
- React.createElement("circle", { cx: sizeNumber / 2, cy: sizeNumber / 2, r: radius, stroke: '#E9ECEE', strokeWidth: strokeWidthNumber, fill: 'none', strokeDasharray: `${circumference - filledLength - gapSizeValue * 2} ${filledLength + gapSizeValue}`, strokeDashoffset: circumference - filledLength - gapSizeValue * 2, strokeLinecap: round ? 'round' : 'none' }),
35
+ React.createElement("svg", { width: sizeNumber, height: sizeNumber, viewBox: `0 0 ${sizeNumber} ${sizeNumber}`, style: { transform: 'rotate(-90deg)' }, className: `${animated ? 'animated' : ' '}` },
36
+ React.createElement("circle", { cx: sizeNumber / 2, cy: sizeNumber / 2, r: radius, stroke: '#E9ECEE', strokeWidth: strokeWidthNumber, fill: 'none', strokeDasharray: `${filledLength ? `${circumference - filledLength - gapSizeValue * 2} ${filledLength + gapSizeValue * 2}` : `${circumference - gapSizeValue * 2} ${gapSizeValue * 2}`} `, strokeDashoffset: circumference / 2 - gapSizeValue, strokeLinecap: round ? 'round' : 'none', style: { transform: 'rotateY(-180deg)', transformOrigin: '50% 50%' } }),
39
37
  React.createElement("circle", { cx: sizeNumber / 2, cy: sizeNumber / 2, r: radius, stroke: 'url(#gradient)', strokeWidth: strokeWidthNumber, fill: 'none', strokeDasharray: `${filledLength} ${circumference - filledLength}`, strokeDashoffset: 0, strokeLinecap: round ? 'round' : 'none' }),
40
38
  React.createElement("defs", null,
41
39
  React.createElement("linearGradient", { id: 'gradient', x1: '1', y1: '0', x2: '0', y2: '1' },
@@ -16,6 +16,15 @@ const ProgressComponentStyle = styled.div `
16
16
  max-width: 100%;
17
17
  }
18
18
 
19
+ .animated {
20
+ circle {
21
+ transition:
22
+ stroke-dasharray 1.5s ease-out,
23
+ stroke-dashoffset 1.5s ease-out;
24
+ will-change: stroke-dasharray, stroke-dashoffset;
25
+ }
26
+ }
27
+
19
28
  /* //! 1920 */
20
29
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
21
30
  /* --sizeProgress: var(--sp51x); */
@@ -1,14 +1,16 @@
1
- import React, { useRef } from 'react';
2
- // //* Styles
3
- import ProgressBalanceStyle from './style';
1
+ import React from 'react';
2
+ import { Text, useTranslation } from '@weareconceptstudio/core';
3
+ //* Component
4
4
  import ProgressComponent from './ProgressComponent';
5
- import { Icon, Text, useTranslation } from '@weareconceptstudio/core';
5
+ //* Util
6
6
  import { handlePriceCheckFunc } from '../../../../../utils/_functions';
7
+ //* Styles
8
+ import ProgressBalanceStyle from './style';
7
9
  const ProgressBalance = ({ progress, balance, nextStatusValue, nextStatusTitle, iconValue }) => {
8
10
  const { translate } = useTranslation();
9
11
  return (React.createElement(ProgressBalanceStyle, null,
10
12
  React.createElement("div", { className: 'wrapper-progress-inner-info' },
11
- React.createElement(ProgressComponent, { className: 'circular-progress', percent: progress, round: true }),
13
+ React.createElement(ProgressComponent, { className: 'circular-progress', percent: progress, animated: true, round: true }),
12
14
  balance || balance == 0 ? (React.createElement("div", { className: 'wrapper-progress-text' },
13
15
  React.createElement(Text, { className: 'account-primary-color1 account-p account-p4 first-letter balance-title' }, translate('progressBalanceTitle')),
14
16
  React.createElement(Text, { className: 'account-primary-color1 account-h5 first-letter balance-value' }, typeof balance == 'number' ? handlePriceCheckFunc(balance, translate('priceValue')) : balance))) : null),
@@ -1,3 +1,5 @@
1
1
  export default HistoryBalance;
2
- declare function HistoryBalance(): React.JSX.Element;
2
+ declare function HistoryBalance({ linkEarnPage }: {
3
+ linkEarnPage: any;
4
+ }): React.JSX.Element;
3
5
  import React from 'react';
@@ -1,12 +1,12 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
- import { api, Text, useTranslation } from '@weareconceptstudio/core';
2
+ import { api, Link, Text, useTranslation } from '@weareconceptstudio/core';
3
3
  //* Styles
4
4
  import HistoryBalanceStyle from './style';
5
5
  //* Component
6
6
  import ItemHistory from './ItemHistory';
7
7
  import { Pagination } from '../../../../components';
8
8
  const dataCategoryName = ['balanceCategoryDate', 'balanceCategoryActivity', 'balanceCategoryAmount'];
9
- const HistoryBalance = () => {
9
+ const HistoryBalance = ({ linkEarnPage }) => {
10
10
  const { translate, selectedLang } = useTranslation();
11
11
  const [currentPage, setCurrentPage] = useState(1);
12
12
  const [pagination, setPagination] = useState({
@@ -27,7 +27,10 @@ const HistoryBalance = () => {
27
27
  }, [currentPage]);
28
28
  return data && data.length ? (React.createElement(HistoryBalanceStyle, null,
29
29
  React.createElement("div", { className: 'wrapper-title-section-history' },
30
- React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p account-p1 first-letter title-section-history', text: 'balanceRecentActivity' }),
30
+ React.createElement("div", { className: 'wrapper-history-link' },
31
+ React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p account-p1 first-letter title-section-history', text: 'balanceRecentActivity' }),
32
+ linkEarnPage ? (React.createElement(Link, { href: '/muramoney' },
33
+ React.createElement(Text, { className: 'account-primary-color1 account-font-bold account-p account-p4 first-letter how-earn-text', text: 'balanceHowToEarn' }))) : null),
31
34
  React.createElement("div", { className: 'line-title' })),
32
35
  React.createElement("div", { className: 'wrapper-history-container' },
33
36
  React.createElement("div", { className: 'wrapper-history-category-title', id: 'history-category-title' }, dataCategoryName.map((item, i) => {
@@ -33,6 +33,27 @@ const HistoryBalanceStyle = styled.section `
33
33
  margin-top: var(--account_distance_pagination);
34
34
  }
35
35
 
36
+ .wrapper-history-link {
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: space-between;
40
+ }
41
+
42
+ .how-earn-text {
43
+ transition: var(--trTime) ease-out;
44
+ text-decoration: underline;
45
+ }
46
+
47
+ @media (pointer: fine) {
48
+ @media (hover: hover) {
49
+ .how-earn-text {
50
+ &:hover {
51
+ color: var(--account_primaryColor3);
52
+ }
53
+ }
54
+ }
55
+ }
56
+
36
57
  /* //! 1920 */
37
58
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
38
59
  --account_distance_line_history_marginTB: var(--sp3x) 0 var(--sp3x);
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { Text, useUi } from '@weareconceptstudio/core';
2
+ import { Text, useResizeObserver, useUi } from '@weareconceptstudio/core';
3
3
  //* Styles
4
4
  import StatusBalanceStyle from './style';
5
5
  //* Component
@@ -8,36 +8,17 @@ const StatusBalance = ({ allItem, activeStatus }) => {
8
8
  const { winWidth } = useUi();
9
9
  //! Refs
10
10
  const wrapperStatusRef = useRef();
11
- const resizableRefs = useRef();
12
- const resizeTimeoutRef = useRef();
13
11
  const statusActiveItem = useRef(false);
14
12
  const styleRef = useRef();
15
13
  const contentRef = useRef();
16
14
  const outsideContentRef = useRef();
17
15
  //! State
18
16
  const [sizeLine, setSizeLine] = useState();
19
- const [resize, setResize] = useState();
20
- //! Resize logic
21
- useEffect(() => {
22
- const bodyElement = document.querySelector('body');
23
- resizableRefs.current = new ResizeObserver((entries) => {
24
- if (resizeTimeoutRef.current) {
25
- clearTimeout(resizeTimeoutRef.current);
26
- }
27
- resizeTimeoutRef.current = setTimeout(() => {
28
- setResize(entries[0].contentRect.height);
29
- }, 300);
30
- });
31
- resizableRefs.current.observe(bodyElement);
32
- return () => {
33
- if (resizableRefs.current) {
34
- resizableRefs.current.disconnect();
35
- }
36
- };
37
- }, [winWidth]);
17
+ //! Resizes
18
+ const resizes = useResizeObserver(document.querySelector('body'));
38
19
  //! Calculate size range
39
20
  useEffect(() => {
40
- if (wrapperStatusRef.current && resize && styleRef.current) {
21
+ if (wrapperStatusRef.current && resizes && styleRef.current) {
41
22
  const allCircle = wrapperStatusRef.current.querySelectorAll('.circle-line');
42
23
  const sizeCircleLeftRight = [...allCircle].map((item) => Math.floor(item.getBoundingClientRect().left));
43
24
  const differences = sizeCircleLeftRight.slice(1).map((value, index) => Math.floor(value - (sizeCircleLeftRight[index] + allCircle[0].getBoundingClientRect().width)));
@@ -54,7 +35,7 @@ const StatusBalance = ({ allItem, activeStatus }) => {
54
35
  if (allItem.length) {
55
36
  statusActiveItem.current = allItem.findIndex((item) => item.name?.toLowerCase() === activeStatus?.toLowerCase());
56
37
  }
57
- }, [resize, winWidth]);
38
+ }, [resizes, winWidth]);
58
39
  return (React.createElement(StatusBalanceStyle, { ref: styleRef, className: 'account-progress-status-wrapper' },
59
40
  React.createElement("div", { className: 'wrapper-title-section' },
60
41
  React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p account-p1 first-letter status-title-section-progress', text: 'balanceStatus' }),
@@ -1,7 +1,8 @@
1
1
  export default AccountBalanceTemplate;
2
- declare function AccountBalanceTemplate({ iconValue, dataItem, className }: {
2
+ declare function AccountBalanceTemplate({ iconValue, dataItem, linkEarnPage, className }: {
3
3
  iconValue: any;
4
4
  dataItem: any;
5
+ linkEarnPage: any;
5
6
  className: any;
6
7
  }): React.JSX.Element;
7
8
  import React from 'react';
@@ -6,7 +6,7 @@ import AccountBalanceTemplateStyle from './style';
6
6
  import HeroBalance from './HeroBalance';
7
7
  import HistoryBalance from './HistoryBalance';
8
8
  import StatusBalance from './StatusBalance';
9
- const AccountBalanceTemplate = ({ iconValue, dataItem, className }) => {
9
+ const AccountBalanceTemplate = ({ iconValue, dataItem, linkEarnPage, className }) => {
10
10
  const { selectedLang } = useTranslation();
11
11
  //! State
12
12
  const [dataBalance, setDataBalance] = useState(false);
@@ -26,6 +26,6 @@ const AccountBalanceTemplate = ({ iconValue, dataItem, className }) => {
26
26
  }
27
27
  })() }),
28
28
  React.createElement(StatusBalance, { activeStatus: dataBalance.info.status, allItem: dataItem }),
29
- React.createElement(HistoryBalance, null))) : null;
29
+ React.createElement(HistoryBalance, { linkEarnPage: linkEarnPage }))) : null;
30
30
  };
31
31
  export default AccountBalanceTemplate;
@@ -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 }) => {
10
+ const AddressForm = Memo(({ title, data, type, isCheckoutPage = false }) => {
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 }) => {
22
22
  };
23
23
  setIsDisabled(true);
24
24
  return (!isDisabled &&
25
- eval(data?.id ? `updateAddress(newData, data.id)` : `createAddress(newData)`).then(() => {
25
+ eval(data?.id ? `updateAddress({data: newData, addressId: data.id, type, isCheckoutPage})` : `createAddress({data: newData, type, isCheckoutPage})`).then(() => {
26
26
  closePopup();
27
27
  }));
28
28
  }, [data, isChecked, createAddress, updateAddress, isDisabled]);
@@ -12,13 +12,13 @@ const AddressItem = ({ type, title, data, checkout_review, select_address, onCli
12
12
  const { deleteAddress, selectedAddresses } = useAddressContext();
13
13
  //! Handle Popups
14
14
  const handleDeletePopup = useCallback(() => {
15
- openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteAddressMessage', description: 'confirmDeleteAddress', onRemove: () => deleteAddress(data.id, data.type) }), {
15
+ openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteAddressMessage', description: 'confirmDeleteAddress', onRemove: () => deleteAddress({ addressId: data.id, type: data.type }) }), {
16
16
  className: 'messagePopup',
17
17
  accountIcon: true,
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 }), {
21
+ openPopup(React.createElement(AddressForm, { title: type === 'billing' ? `updateYourBillingAddress` : type == 'shipping' ? `updateYourShippingAddress` : 'updateYourAddress', data: data, isCheckoutPage: select_address }), {
22
22
  accountIcon: true,
23
23
  });
24
24
  }, [data]);
@@ -38,7 +38,7 @@ const AddressItem = ({ type, title, data, checkout_review, select_address, onCli
38
38
  React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedAddresses?.id === data.id ? 'selected' : 'note-selected'}` },
39
39
  React.createElement("path", { d: 'M13.345 30.462c-1.062 0-1.859-0.531-2.39-1.328l-9.56-16.996c-0.797-1.328-0.266-2.921 1.062-3.718 1.328-0.531 2.921 0 3.718 1.328l7.436 13.012 12.481-20.183c0.797-1.328 2.39-1.593 3.718-0.797s1.593 2.39 0.797 3.718l-14.871 23.635c-0.531 0.797-1.328 1.328-2.39 1.328z' }))))),
40
40
  !checkout_review && (React.createElement("div", { className: `edit-remove-wrapper` },
41
- React.createElement(AccountButton, { text: `edit`, btnType: `green-small-text`, onClick: handleEditAddressPopup, className: 'btn-one-address-version' }),
41
+ !select_address || (select_address && checkedId == data.id) ? (React.createElement(AccountButton, { text: `edit`, btnType: `green-small-text`, onClick: handleEditAddressPopup, className: 'btn-one-address-version' })) : null,
42
42
  !select_address && !data.is_default && (React.createElement(React.Fragment, null,
43
43
  React.createElement("div", { className: `vertical-line` }),
44
44
  React.createElement(AccountButton, { text: `remove`, onClick: handleDeletePopup, btnType: `green-small-text`, className: 'btn-more-address-version' })))))))));
@@ -24,34 +24,49 @@ export const AddressProvider = ({ addressType, addressFormFields = [], useUser,
24
24
  useEffect(() => {
25
25
  if (isLoggedIn) {
26
26
  api.get({ url: 'addresses' }).then((res) => {
27
- setAddresses(res.data);
28
- setSelectedAddresses(addressType
29
- ? {
30
- shipping: res.data[0],
31
- billing: res.data[0],
32
- }
33
- : res.data[0]);
27
+ if (addressType) {
28
+ }
29
+ else {
30
+ setAddresses(res.addresses);
31
+ setSelectedAddresses(res.addresses[0]);
32
+ }
34
33
  setAddressLoading(false);
35
34
  });
36
35
  }
37
36
  }, [isLoggedIn]);
38
- const createAddress = async (data) => {
37
+ const createAddress = async ({ data, type, isCheckoutPage }) => {
39
38
  return await api.post('addresses', data).then((res) => {
40
- setAddresses(res.data);
41
- setSelectedAddresses(addressType
42
- ? {
43
- shipping: res.data[0],
44
- billing: res.data[0],
39
+ if (addressType) {
40
+ }
41
+ else {
42
+ setAddresses(res.addresses);
43
+ if (isCheckoutPage) {
44
+ selectAddress({ checkedId: res.currentAddress.id });
45
+ setSelectedAddresses(res.currentAddress);
46
+ }
47
+ else {
48
+ setSelectedAddresses(res.addresses[0]);
45
49
  }
46
- : res.data[0]);
50
+ }
47
51
  });
48
52
  };
49
- const updateAddress = async (data, addressId) => {
53
+ const updateAddress = async ({ data, addressId, type, isCheckoutPage }) => {
50
54
  return await api.put(`addresses/${addressId}`, data).then((res) => {
51
- setAddresses(res.data);
55
+ if (addressType) {
56
+ }
57
+ else {
58
+ setAddresses(res.addresses);
59
+ if (isCheckoutPage) {
60
+ selectAddress({ checkedId: res.currentAddress.id });
61
+ setSelectedAddresses(res.currentAddress);
62
+ }
63
+ else {
64
+ setSelectedAddresses(res.addresses[0]);
65
+ }
66
+ }
52
67
  });
53
68
  };
54
- const deleteAddress = async (addressId) => {
69
+ const deleteAddress = async ({ addressId, type }) => {
55
70
  return await api.delete(`addresses/${addressId}`).then((res) => {
56
71
  setAddresses(res.data);
57
72
  });
@@ -12,7 +12,7 @@ const SelectAddressPopup = Memo(({ title, type }) => {
12
12
  const { selectAddress, addresses, hasAddressType, selectedAddresses } = useAddressContext();
13
13
  const [checkedId, setCheckedId] = useState(() => selectedAddresses.id, [selectedAddresses]);
14
14
  const handleNewAddressPopup = () => {
15
- openPopup(React.createElement(AddressForm, { title: type == 'shipping' ? `addNewShippingAddress` : type == 'billing' ? 'addNewBillingAddress' : 'addNewAddress', selected: { value: false, type: type } }), {
15
+ openPopup(React.createElement(AddressForm, { title: type == 'shipping' ? `addNewShippingAddress` : type == 'billing' ? 'addNewBillingAddress' : 'addNewAddress', type: type, isCheckoutPage: true }), {
16
16
  accountIcon: true,
17
17
  });
18
18
  };
@@ -94,9 +94,7 @@ const ForgotPasswordTemplate = ({ signInUrl = '/sign-in' }) => {
94
94
  React.createElement("div", { className: 'recovery-wrap' },
95
95
  React.createElement(Text, { className: 'account-p account-p2 account-font-medium account-primary-color1 recovery-text', text: 'recoveryText' }),
96
96
  "\u00A0",
97
- React.createElement(Text, { className: 'account-p account-p2 account-font-bold account-primary-color1 recovery-email',
98
- // text={forgotState.email}
99
- text: 'antonyanwm@gmail.com' })),
97
+ React.createElement(Text, { className: 'account-p account-p2 account-font-bold account-primary-color1 recovery-email', text: forgotState.email })),
100
98
  React.createElement("div", { className: 'try-again-wrap' },
101
99
  React.createElement(Text, { text: `resendNewLink`, onClick: handleTryAgain, className: `account-p account-p3 account-font-bold account-primary-color1 underline try-again-text ${forgotState.isBtnDisabled ? 'disabled' : ''}` }))),
102
100
  React.createElement("div", { className: 'col-3 col-t-1 col-m-0' })))))));
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface ExpiredLinkProps {
3
+ signInUrl?: any;
4
+ }
5
+ declare const ExpiredLink: ({ signInUrl }: ExpiredLinkProps) => React.JSX.Element;
6
+ export default ExpiredLink;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { Link, Text } from '@weareconceptstudio/core';
3
+ //* Styles
4
+ import ExpiredLinkStyle from './style';
5
+ //* Component
6
+ import AccountContainer from '../../../../components/AccountContainer';
7
+ const ExpiredLink = ({ signInUrl }) => {
8
+ return (React.createElement(ExpiredLinkStyle, { className: 'expired-container' },
9
+ React.createElement(AccountContainer, { className: 'wrapper-container', row: true, full: true },
10
+ React.createElement("div", { className: 'col-3 col-t-1 col-m-0' }),
11
+ React.createElement("div", { className: 'wrapper-expired col-6 col-t-10 col-m-12' },
12
+ React.createElement(Text, { className: 'account-h2 account-font-bold account-primary-color1 expired-title-text', text: 'titleExpired' }),
13
+ React.createElement("div", { className: 'expired-description-wrap' },
14
+ React.createElement(Text, { className: 'account-p account-p2 account-font-medium account-primary-color1 expired-description-text', text: 'descriptionExpired' })),
15
+ React.createElement("div", { className: ' expired-link-wrap' },
16
+ React.createElement(Link, { href: signInUrl },
17
+ React.createElement(Text, { text: `linkTextResentExpired`, className: `account-p account-p3 account-font-bold account-primary-color1 underline expired-link-text ` })))),
18
+ React.createElement("div", { className: 'col-3 col-t-1 col-m-0' }))));
19
+ };
20
+ export default ExpiredLink;
@@ -0,0 +1,2 @@
1
+ export default ExpiredLinkStyle;
2
+ declare const ExpiredLinkStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
@@ -0,0 +1,81 @@
1
+ import styled from 'styled-components';
2
+ const ExpiredLinkStyle = styled.section `
3
+ --account_expiredRecoveryLinkWrapMTop: var(--sp3x);
4
+ --account_expiredTryAgainWrapMTop: var(--sp1x);
5
+
6
+ width: 100%;
7
+ display: flex;
8
+ justify-content: center;
9
+
10
+ .expired-title-text,
11
+ .expired-description-text {
12
+ text-align: center;
13
+ }
14
+
15
+ .expired-description-wrap,
16
+ .expired-link-wrap {
17
+ display: flex;
18
+ flex-wrap: wrap;
19
+ align-items: center;
20
+ justify-content: center;
21
+ }
22
+
23
+ .expired-description-wrap {
24
+ margin-top: var(--account_expiredRecoveryLinkWrapMTop);
25
+ }
26
+
27
+ .expired-link-wrap {
28
+ margin-top: var(--account_expiredTryAgainWrapMTop);
29
+
30
+ .expired-link-text {
31
+ transition: color var(--account_trTime) ease-out;
32
+ cursor: pointer;
33
+
34
+ @media (pointer: fine) {
35
+ @media (hover: hover) {
36
+ &:hover {
37
+ color: var(--account_primaryColor3);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
45
+ --account_expiredRecoveryLinkWrapMTop: var(--sp2x);
46
+ --account_expiredTryAgainWrapMTop: var(--sp1x);
47
+ }
48
+
49
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
50
+ --account_expiredRecoveryLinkWrapMTop: var(--sp2x);
51
+ --account_expiredTryAgainWrapMTop: var(--sp1x);
52
+ }
53
+
54
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
55
+ --account_expiredRecoveryLinkWrapMTop: var(--sp2x);
56
+ --account_expiredTryAgainWrapMTop: var(--sp1x);
57
+ }
58
+
59
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
60
+ --account_expiredRecoveryLinkWrapMTop: var(--sp2x);
61
+ --account_expiredTryAgainWrapMTop: var(--sp0-5x);
62
+ }
63
+
64
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
65
+ --account_expiredRecoveryLinkWrapMTop: var(--sp1-5x);
66
+ --account_expiredTryAgainWrapMTop: var(--sp0-5x);
67
+ }
68
+
69
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeS}) {
70
+ --account_expiredRecoveryLinkWrapMTop: var(--sp1-5x);
71
+ --account_expiredTryAgainWrapMTop: var(--sp0-5x);
72
+ }
73
+
74
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
75
+ --account_expiredRecoveryLinkWrapMTop: var(--sp1-5x);
76
+ --account_expiredTryAgainWrapMTop: var(--sp0-5x);
77
+
78
+ padding: 0 var(--sp2x);
79
+ }
80
+ `;
81
+ export default ExpiredLinkStyle;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface ResetPasswordProps {
3
3
  formFields?: [];
4
4
  urlParams?: any;
5
+ signInUrl?: string;
5
6
  }
6
- declare const ResetPasswordTemplate: ({ formFields, urlParams }: ResetPasswordProps) => React.JSX.Element;
7
+ declare const ResetPasswordTemplate: ({ formFields, urlParams, signInUrl }: ResetPasswordProps) => React.JSX.Element;
7
8
  export default ResetPasswordTemplate;
@@ -1,34 +1,56 @@
1
- import React, { useCallback, useState } from 'react';
2
- import { Text, Link, Page } from '@weareconceptstudio/core';
1
+ import React, { useCallback, useEffect, useState } from 'react';
3
2
  import { FormBuilder } from '@weareconceptstudio/form';
4
- import { AccountButton } from '../../../components';
5
- import ResetPasswordTemplateStyle from './style';
6
- import { defaultFormFields } from './utils';
3
+ import { Text, Link, Page } from '@weareconceptstudio/core';
4
+ //* Provider
7
5
  import { useAccountContext } from '../../../AccountProvider';
6
+ //* Utils
7
+ import { defaultFormFields } from './utils';
8
+ //* Style
9
+ import ResetPasswordTemplateStyle from './style';
10
+ //* Component
11
+ import ExpiredLink from './ExpiredLink';
12
+ import { AccountButton } from '../../../components';
8
13
  // @ts-ignore
9
- const ResetPasswordTemplate = ({ formFields = defaultFormFields, urlParams = {} }) => {
14
+ const ResetPasswordTemplate = ({ formFields = defaultFormFields, urlParams = {}, signInUrl }) => {
10
15
  const { useUser } = useAccountContext();
11
- const { resetPassword } = useUser();
16
+ const { resetPassword, checkTokenResetPassword } = useUser();
12
17
  const [isSuccess, setIsSuccess] = useState(false);
18
+ const [isValidToken, setIsValidToken] = useState(false);
19
+ // if (Object.values(urlParams).includes(undefined)) {
20
+ // window.location.href = '404';
21
+ // }
13
22
  const onSubmit = useCallback(async (values) => {
14
23
  return await resetPassword({
15
24
  ...values,
16
- ...urlParams
25
+ ...urlParams,
17
26
  }).then(() => {
18
27
  setIsSuccess(true);
19
28
  });
20
29
  }, []);
30
+ useEffect(() => {
31
+ checkTokenResetPassword({ ...urlParams })
32
+ .then(() => {
33
+ setIsValidToken(true);
34
+ })
35
+ .catch((error) => {
36
+ if (error.status == 419 || error.status == 400) {
37
+ setIsValidToken('linkExpired');
38
+ }
39
+ else {
40
+ window.location.href = '/not-found';
41
+ }
42
+ });
43
+ }, [checkTokenResetPassword, urlParams]);
21
44
  return (React.createElement(Page, { className: 'reset-password use-account' },
22
- React.createElement(ResetPasswordTemplateStyle, null,
23
- React.createElement("div", { className: `reset-password-wrapper` }, !isSuccess ? (React.createElement(React.Fragment, null,
24
- React.createElement(Text, { tag: 'h1', text: 'resetPassword', className: 'account-h2 account-font-bold account-primary-color1 title' }),
25
- React.createElement(FormBuilder, { fields: formFields, onSubmit: onSubmit },
26
- React.createElement("div", { className: 'forgotLinkWrap' },
27
- React.createElement(Link, { href: '/forgot-password' },
28
- React.createElement(Text, { tag: 'span', className: 'account-p account-p3 account-font-medium account-primary-color1 underline forgotLink', text: 'forgotPasswordLink' }))),
29
- React.createElement(AccountButton, { type: `submit`, text: `submit`, btnType: `full-width` })))) : (React.createElement(React.Fragment, null,
30
- React.createElement(Text, { tag: 'h1', className: 'account-h2 account-font-bold account-primary-color1 title', text: 'thankYou' }),
31
- React.createElement(Text, { className: 'account-p account-p2 account-font-regular account-primary-color1 successfully-message', text: 'successfullyMessage' }),
32
- React.createElement(AccountButton, { text: `login`, btnType: `full-width`, url: '/sign-in', className: `additional-btn-wrap` })))))));
45
+ React.createElement(ResetPasswordTemplateStyle, { className: `${isValidToken == 'linkExpired' ? 'expired-page' : ' '}` }, isValidToken && isValidToken !== 'linkExpired' ? (React.createElement("div", { className: `reset-password-wrapper` }, !isSuccess ? (React.createElement(React.Fragment, null,
46
+ React.createElement(Text, { tag: 'h1', text: 'resetPassword', className: 'account-h2 account-font-bold account-primary-color1 title' }),
47
+ React.createElement(FormBuilder, { fields: formFields, onSubmit: onSubmit },
48
+ React.createElement("div", { className: 'forgotLinkWrap' },
49
+ React.createElement(Link, { href: '/forgot-password' },
50
+ React.createElement(Text, { tag: 'span', className: 'account-p account-p3 account-font-medium account-primary-color1 underline forgotLink', text: 'forgotPasswordLink' }))),
51
+ React.createElement(AccountButton, { type: `submit`, text: `submit`, btnType: `full-width` })))) : (React.createElement(React.Fragment, null,
52
+ React.createElement(Text, { tag: 'h1', className: 'account-h2 account-font-bold account-primary-color1 title', text: 'thankYou' }),
53
+ React.createElement(Text, { className: 'account-p account-p2 account-font-regular account-primary-color1 successfully-message', text: 'successfullyMessage' }),
54
+ React.createElement(AccountButton, { text: `login`, btnType: `full-width`, url: '/sign-in', className: `additional-btn-wrap` }))))) : isValidToken == 'linkExpired' ? (React.createElement(ExpiredLink, { signInUrl: signInUrl })) : null)));
33
55
  };
34
56
  export default ResetPasswordTemplate;
@@ -13,7 +13,8 @@ import SkeletonCartTemplate from '../../cart/CartTemplate/Skeleton';
13
13
  import SequenceSkeleton from '../../../components/Sequence/Skeleton';
14
14
  import SkeletonAddressSelect from '../../address/SelectAddress/Skeleton';
15
15
  const CheckoutTemplate = () => {
16
- const { checkoutAddressId } = useAddressContext();
16
+ const firstStepFormRef = useRef(null);
17
+ const { checkoutAddressId, hasCheckoutAddress, addressLoading } = useAddressContext();
17
18
  const { useCart } = useAccountContext();
18
19
  const { items, itemsCount, subtotal, total, shippingCost, freeShippingRange } = useCart();
19
20
  const [checkoutData, setCheckoutData] = useState({
@@ -26,8 +27,6 @@ const CheckoutTemplate = () => {
26
27
  [key]: value,
27
28
  }));
28
29
  };
29
- const { hasCheckoutAddress, addressLoading } = useAddressContext();
30
- const firstStepFormRef = useRef(null);
31
30
  const checkStep = {
32
31
  isShipping: !hasCheckoutAddress,
33
32
  isReview: hasCheckoutAddress,
@@ -186,6 +186,10 @@ declare const _default: {
186
186
  balanceCategoryDate: string;
187
187
  balanceCategoryActivity: string;
188
188
  balanceCategoryAmount: string;
189
+ balanceHowToEarn: string;
189
190
  promoCodePlaceholder: string;
191
+ titleExpired: string;
192
+ descriptionExpired: string;
193
+ linkTextResentExpired: string;
190
194
  };
191
195
  export default _default;
@@ -199,6 +199,11 @@ export default {
199
199
  balanceCategoryDate: 'date',
200
200
  balanceCategoryActivity: 'activity',
201
201
  balanceCategoryAmount: 'amount',
202
+ balanceHowToEarn: 'How to earn?',
202
203
  //! Promocode
203
204
  promoCodePlaceholder: 'Type your code',
205
+ //! Expired password
206
+ titleExpired: 'Link expired',
207
+ descriptionExpired: 'To reset your password, return to the login page and select “forgot your password” to send new email.',
208
+ linkTextResentExpired: 'Back To log in page',
204
209
  };
@@ -186,6 +186,10 @@ declare const _default: {
186
186
  balanceCategoryDate: string;
187
187
  balanceCategoryActivity: string;
188
188
  balanceCategoryAmount: string;
189
+ balanceHowToEarn: string;
189
190
  promoCodePlaceholder: string;
191
+ titleExpired: string;
192
+ descriptionExpired: string;
193
+ linkTextResentExpired: string;
190
194
  };
191
195
  export default _default;
@@ -199,6 +199,11 @@ export default {
199
199
  balanceCategoryDate: 'date',
200
200
  balanceCategoryActivity: 'activity',
201
201
  balanceCategoryAmount: 'amount',
202
+ balanceHowToEarn: 'How to earn?',
202
203
  //! Promocode
203
204
  promoCodePlaceholder: 'Type your code',
205
+ //! Expired password
206
+ titleExpired: 'Link expired',
207
+ descriptionExpired: 'To reset your password, return to the login page and select “forgot your password” to send new email.',
208
+ linkTextResentExpired: 'Back To log in page',
204
209
  };
@@ -187,7 +187,11 @@ declare const _default: {
187
187
  balanceCategoryDate: string;
188
188
  balanceCategoryActivity: string;
189
189
  balanceCategoryAmount: string;
190
+ balanceHowToEarn: string;
190
191
  promoCodePlaceholder: string;
192
+ titleExpired: string;
193
+ descriptionExpired: string;
194
+ linkTextResentExpired: string;
191
195
  };
192
196
  hy: {
193
197
  editCart: string;
@@ -377,7 +381,11 @@ declare const _default: {
377
381
  balanceCategoryDate: string;
378
382
  balanceCategoryActivity: string;
379
383
  balanceCategoryAmount: string;
384
+ balanceHowToEarn: string;
380
385
  promoCodePlaceholder: string;
386
+ titleExpired: string;
387
+ descriptionExpired: string;
388
+ linkTextResentExpired: string;
381
389
  };
382
390
  ru: {
383
391
  editCart: string;
@@ -567,7 +575,11 @@ declare const _default: {
567
575
  balanceCategoryDate: string;
568
576
  balanceCategoryActivity: string;
569
577
  balanceCategoryAmount: string;
578
+ balanceHowToEarn: string;
570
579
  promoCodePlaceholder: string;
580
+ titleExpired: string;
581
+ descriptionExpired: string;
582
+ linkTextResentExpired: string;
571
583
  };
572
584
  };
573
585
  export default _default;
@@ -186,6 +186,10 @@ declare const _default: {
186
186
  balanceCategoryDate: string;
187
187
  balanceCategoryActivity: string;
188
188
  balanceCategoryAmount: string;
189
+ balanceHowToEarn: string;
189
190
  promoCodePlaceholder: string;
191
+ titleExpired: string;
192
+ descriptionExpired: string;
193
+ linkTextResentExpired: string;
190
194
  };
191
195
  export default _default;
@@ -199,6 +199,11 @@ export default {
199
199
  balanceCategoryDate: 'date',
200
200
  balanceCategoryActivity: 'activity',
201
201
  balanceCategoryAmount: 'amount',
202
+ balanceHowToEarn: 'How to earn?',
202
203
  //! Promocode
203
204
  promoCodePlaceholder: 'Type your code',
205
+ //! Expired password
206
+ titleExpired: 'Link expired',
207
+ descriptionExpired: 'To reset your password, return to the login page and select “forgot your password” to send new email.',
208
+ linkTextResentExpired: 'Back To log in page',
204
209
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/account",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Concept Studio Account",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",