@weareconceptstudio/account 0.6.4 → 0.6.6

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 (25) hide show
  1. package/dist/components/TotalCheckout/CommentComp/index.js +7 -8
  2. package/dist/components/TotalCheckout/index.js +3 -3
  3. package/dist/modules/account/AccountBalanceTemplate/BalanceContext.d.ts +5 -0
  4. package/dist/modules/account/AccountBalanceTemplate/BalanceContext.js +68 -0
  5. package/dist/modules/account/AccountBalanceTemplate/HeroBalance/index.d.ts +2 -9
  6. package/dist/modules/account/AccountBalanceTemplate/HeroBalance/index.js +29 -8
  7. package/dist/modules/account/AccountBalanceTemplate/HistoryBalance/index.js +8 -24
  8. package/dist/modules/account/AccountBalanceTemplate/StatusBalance/index.d.ts +2 -3
  9. package/dist/modules/account/AccountBalanceTemplate/StatusBalance/index.js +13 -8
  10. package/dist/modules/account/AccountBalanceTemplate/Voucher/index.d.ts +3 -0
  11. package/dist/modules/account/AccountBalanceTemplate/Voucher/index.js +37 -0
  12. package/dist/modules/account/AccountBalanceTemplate/Voucher/style.d.ts +2 -0
  13. package/dist/modules/account/AccountBalanceTemplate/Voucher/style.js +68 -0
  14. package/dist/modules/account/AccountBalanceTemplate/index.d.ts +2 -2
  15. package/dist/modules/account/AccountBalanceTemplate/index.js +10 -23
  16. package/dist/modules/account/AccountSettingsTemplate/AccountInfo/index.js +1 -1
  17. package/dist/modules/account/AccountSettingsTemplate/AccountPassword/index.js +1 -1
  18. package/dist/translations/en.d.ts +11 -1
  19. package/dist/translations/en.js +11 -1
  20. package/dist/translations/hy.d.ts +11 -1
  21. package/dist/translations/hy.js +13 -3
  22. package/dist/translations/index.d.ts +33 -3
  23. package/dist/translations/ru.d.ts +11 -1
  24. package/dist/translations/ru.js +11 -1
  25. package/package.json +1 -1
@@ -1,17 +1,16 @@
1
1
  import React from 'react';
2
- import { CollapseContainer, CollapseItem, Text } from '@weareconceptstudio/core';
2
+ import { CollapseItem, Text } from '@weareconceptstudio/core';
3
3
  import { Input } from '@weareconceptstudio/form';
4
4
  import { useCart } from '../../../modules';
5
5
  import CommentCompStyle from './style';
6
6
  const CommentComp = ({ isShipping }) => {
7
7
  const { fillCheckoutData, isCheckoutPage } = useCart();
8
8
  return isCheckoutPage && typeof isShipping === 'boolean' && !isShipping ? (React.createElement(CommentCompStyle, { className: 'collapse-distance' },
9
- React.createElement(CollapseContainer, null,
10
- React.createElement(CollapseItem, { status: 'open', title: React.createElement(React.Fragment, null,
11
- React.createElement("div", { className: 'inner-wrapper-icon' },
12
- React.createElement("svg", { width: '12', height: '12', fill: 'none', viewBox: '0 0 12 12', xmlns: 'http://www.w3.org/2000/svg' },
13
- React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
14
- React.createElement("path", { d: 'M6 12L6 0', stroke: 'black', strokeWidth: '2' }))),
15
- React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium comment-text', text: 'account.order_balance.comment' })), description: React.createElement(Input.TextArea, { containerClassName: `comment-field`, placeholder: 'account.cart_checkout.checkoutCommentPlaceholder', onChange: (e) => fillCheckoutData('note', e.target.value), className: `account-p account-p3 account-font-regular account-primary-color1` }) })))) : null;
9
+ React.createElement(CollapseItem, { status: 'open', title: React.createElement(React.Fragment, null,
10
+ React.createElement("div", { className: 'inner-wrapper-icon' },
11
+ React.createElement("svg", { width: '12', height: '12', fill: 'none', viewBox: '0 0 12 12', xmlns: 'http://www.w3.org/2000/svg' },
12
+ React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
13
+ React.createElement("path", { d: 'M6 12L6 0', stroke: 'black', strokeWidth: '2' }))),
14
+ React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium comment-text', text: 'account.order_balance.comment' })), description: React.createElement(Input.TextArea, { containerClassName: `comment-field`, placeholder: 'account.cart_checkout.checkoutCommentPlaceholder', onChange: (e) => fillCheckoutData('note', e.target.value), className: `account-p account-p3 account-font-regular account-primary-color1` }) }))) : null;
16
15
  };
17
16
  export default CommentComp;
@@ -39,10 +39,10 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
39
39
  React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-currency2`, text: itemsCount ? handlePriceCheckFunc(total, currency) : `0 ${currency}` })),
40
40
  React.createElement(GiftComp, null),
41
41
  React.createElement(FreeShippingComp, null),
42
- React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
42
+ React.createElement(CollapseContainer, { className: 'collapse-container-wrapper', multiple: true },
43
43
  React.createElement(PromoCodeComp, null),
44
- React.createElement(BalanceComp, null)),
45
- React.createElement(CommentComp, { isShipping: isShipping }))),
44
+ React.createElement(BalanceComp, null),
45
+ React.createElement(CommentComp, { isShipping: isShipping })))),
46
46
  React.createElement(AccountButton, { url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, disabled: checkoutBtnDisabled, loading: buttonProps.loadingButton, className: `sticky-wrap-btn text-center`, onClick: () => buttonProps.handleClick && buttonProps.handleClick() })))) : (React.createElement(SkeletonTotalCheckout, null))))));
47
47
  });
48
48
  export default TotalCheckout;
@@ -0,0 +1,5 @@
1
+ export function BalanceProvider({ children }: {
2
+ children: any;
3
+ }): React.JSX.Element;
4
+ export function useBalance(): any;
5
+ import React from 'react';
@@ -0,0 +1,68 @@
1
+ import React, { createContext, useContext, useReducer, useEffect } from 'react';
2
+ import { api, useTranslation } from '@weareconceptstudio/core';
3
+ const BalanceContext = createContext(null);
4
+ export function BalanceProvider({ children }) {
5
+ const { selectedLang } = useTranslation();
6
+ const [data, dispatch] = useReducer(balanceReducer, initialBalance);
7
+ const getBalanceData = async () => {
8
+ await api.get({ url: `balance`, lang: selectedLang }).then((res) => {
9
+ dispatch({
10
+ type: 'fillBalanceData',
11
+ data: res,
12
+ });
13
+ });
14
+ };
15
+ const getBalanceHistory = async (page) => {
16
+ await api.get({ url: 'balance-history', params: { page }, lang: selectedLang }).then((res) => {
17
+ dispatch({
18
+ type: 'fillBalanceHistory',
19
+ data: res.histories,
20
+ pagination: res.pagination,
21
+ });
22
+ });
23
+ };
24
+ const redeemVoucher = async (code) => {
25
+ return await api.post('redeem-voucher', { code }).then((res) => {
26
+ dispatch({
27
+ type: 'fillVoucher',
28
+ newBalance: res.newBalance,
29
+ newHistory: res.newHistory,
30
+ });
31
+ });
32
+ };
33
+ useEffect(() => {
34
+ getBalanceData();
35
+ }, []);
36
+ return React.createElement(BalanceContext.Provider, { value: { ...data, dispatch, getBalanceHistory, redeemVoucher } }, children);
37
+ }
38
+ export const useBalance = () => {
39
+ return useContext(BalanceContext);
40
+ };
41
+ function balanceReducer(state, action) {
42
+ switch (action.type) {
43
+ case 'fillBalanceData': {
44
+ return action.data;
45
+ }
46
+ case 'fillBalanceHistory':
47
+ return { ...state, histories: action.data, pagination: action.pagination };
48
+ case 'fillVoucher':
49
+ return {
50
+ ...state,
51
+ balance: {
52
+ ...state.balance,
53
+ balance: action.newBalance,
54
+ },
55
+ histories: state.pagination.currentPage == 1 ? [action.newHistory, ...state.histories] : state.histories,
56
+ };
57
+ default:
58
+ return state;
59
+ }
60
+ }
61
+ const initialBalance = {
62
+ balance: null,
63
+ histories: [],
64
+ pagination: {
65
+ total: 0,
66
+ pageSize: 0,
67
+ },
68
+ };
@@ -1,14 +1,7 @@
1
1
  export default HeroBalance;
2
- declare function HeroBalance({ iconValue, balance, cashback, progress, totalSpent, nextStatusValue, description, title, nextStatusTitle, currency }: {
2
+ declare function HeroBalance({ iconValue, currency, balanceStatuses }: {
3
3
  iconValue: any;
4
- balance: any;
5
- cashback: any;
6
- progress: any;
7
- totalSpent: any;
8
- nextStatusValue: any;
9
- description: any;
10
- title: any;
11
- nextStatusTitle: any;
12
4
  currency: any;
5
+ balanceStatuses: any;
13
6
  }): React.JSX.Element;
14
7
  import React from 'react';
@@ -1,21 +1,42 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { handlePriceCheckFunc, Text, useTranslation } from '@weareconceptstudio/core';
3
+ import { useBalance } from '../BalanceContext';
3
4
  //* Styles
4
5
  import HeroBalanceStyle from './style';
5
6
  //* Component
6
7
  import ProgressBalance from './ProgressBalance';
7
- const HeroBalance = ({ iconValue, balance, cashback, progress, totalSpent, nextStatusValue, description, title, nextStatusTitle, currency }) => {
8
+ const HeroBalance = ({ iconValue, currency, balanceStatuses }) => {
8
9
  const { translate } = useTranslation();
9
- const dataInformation = [cashback, totalSpent, balance];
10
+ const data = useBalance()?.balance;
11
+ const newData = useMemo(() => {
12
+ return data
13
+ ? {
14
+ ...data,
15
+ progress: data.info.timeline,
16
+ totalSpent: data.info.spent.current,
17
+ nextStatusValue: data.info.spent.next,
18
+ dataInformation: [data.cashback, data.info.spent.current, data.balance],
19
+ }
20
+ : null;
21
+ }, [data]);
10
22
  const dataInformationTitle = ['account.balance_promotions.balanceCashback', 'account.balance_promotions.balanceTotalSpent', 'balance'];
11
- return (React.createElement(HeroBalanceStyle, { className: 'account-hero-balance' },
23
+ const nextStatusTitle = useMemo(() => {
24
+ const index = balanceStatuses?.findIndex((item) => item.name?.toLowerCase() === data?.info?.status?.toLowerCase());
25
+ const nextItem = balanceStatuses[index + 1] ?? balanceStatuses[index];
26
+ return nextItem?.name;
27
+ }, [data, balanceStatuses]);
28
+ const description = useMemo(() => {
29
+ const desc = balanceStatuses?.find((item) => item.name?.toLowerCase() === data?.info?.status?.toLowerCase());
30
+ return desc;
31
+ }, [data, balanceStatuses]);
32
+ return newData ? (React.createElement(HeroBalanceStyle, { className: 'account-hero-balance' },
12
33
  React.createElement("div", { className: 'inner-wrapper' },
13
34
  React.createElement("div", { className: 'left-bar-account-balance' },
14
35
  React.createElement("div", { className: 'inner-wrapper-left-bar' },
15
36
  React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p account-p3 first-letter status-title', text: 'account.balance_promotions.balanceStatus' }),
16
- React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-h5 first-letter text-title', text: `account.user_status.${title}` }),
17
- description && React.createElement(Text, { className: 'account-primary-color1 account-p account-p2 first-letter description-status' }, translate(description.description, { cashback: cashback })),
18
- React.createElement("div", { className: 'wrapper-information-payment' }, dataInformation.map((item, i, arr) => {
37
+ React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-h5 first-letter text-title', text: `account.user_status.${data.info.status.toLowerCase()}` }),
38
+ description && React.createElement(Text, { className: 'account-primary-color1 account-p account-p2 first-letter description-status' }, translate(description.description, { cashback: newData.cashback })),
39
+ React.createElement("div", { className: 'wrapper-information-payment' }, newData.dataInformation.map((item, i, arr) => {
19
40
  return ((item || item == 0) && (React.createElement(Text, { key: i, className: 'account-primary-color1 account-p account-p3 first-letter account-font-medium info-text' },
20
41
  translate(dataInformationTitle[i]),
21
42
  ":",
@@ -23,6 +44,6 @@ const HeroBalance = ({ iconValue, balance, cashback, progress, totalSpent, nextS
23
44
  React.createElement(Text, { tag: 'span', className: 'account-primary-color1 account-p account-p3 first-letter account-font-regular info-value-text' }, arr[0] == item ? item + '%' : typeof item == 'number' ? handlePriceCheckFunc(item, currency) : item))));
24
45
  })))),
25
46
  React.createElement("div", { className: 'empty' }),
26
- React.createElement(ProgressBalance, { balance: balance, progress: progress, currency: currency, iconValue: iconValue, nextStatusValue: nextStatusValue, nextStatusTitle: nextStatusTitle }))));
47
+ React.createElement(ProgressBalance, { ...newData, nextStatusTitle: nextStatusTitle, currency: currency, iconValue: iconValue })))) : null;
27
48
  };
28
49
  export default HeroBalance;
@@ -1,5 +1,6 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react';
2
- import { api, Link, Text, useTranslation } from '@weareconceptstudio/core';
1
+ import React, { useRef } from 'react';
2
+ import { Link, Text, useTranslation } from '@weareconceptstudio/core';
3
+ import { useBalance } from '../BalanceContext';
3
4
  //* Styles
4
5
  import HistoryBalanceStyle from './style';
5
6
  //* Component
@@ -7,27 +8,11 @@ import ItemHistory from './ItemHistory';
7
8
  import { Pagination } from '../../../../components';
8
9
  const dataCategoryName = ['account.balance_promotions.balanceCategoryDate', 'account.balance_promotions.balanceCategoryActivity', 'account.balance_promotions.balanceCategoryAmount'];
9
10
  const HistoryBalance = ({ linkEarnPage }) => {
10
- const { translate, selectedLang } = useTranslation();
11
11
  //! Ref
12
12
  const containerRef = useRef();
13
- const [currentPage, setCurrentPage] = useState(1);
14
- const [pagination, setPagination] = useState({
15
- total: 0,
16
- pageSize: 0,
17
- });
18
- const [data, setData] = useState();
19
- const [loading, setLoading] = useState(true);
20
- const getHistory = useCallback((page) => {
21
- api.get({ url: 'balance-history', params: { page }, lang: selectedLang }).then((res) => {
22
- setData(res.histories);
23
- setPagination(res.pagination);
24
- setLoading(false);
25
- });
26
- }, []);
27
- useEffect(() => {
28
- getHistory(currentPage);
29
- }, [currentPage]);
30
- return data?.length > 0 ? (React.createElement(HistoryBalanceStyle, { ref: containerRef },
13
+ const { translate } = useTranslation();
14
+ const { histories, getBalanceHistory, pagination } = useBalance();
15
+ return histories.length ? (React.createElement(HistoryBalanceStyle, { ref: containerRef },
31
16
  React.createElement("div", { className: 'wrapper-title-section-history' },
32
17
  React.createElement("div", { className: 'wrapper-history-link' },
33
18
  React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p account-p1 first-letter title-section-history', text: 'account.balance_promotions.balanceRecentActivity' }),
@@ -40,8 +25,7 @@ const HistoryBalance = ({ linkEarnPage }) => {
40
25
  })),
41
26
  React.createElement("div", { className: 'wrapper-history-content' },
42
27
  React.createElement("div", { className: 'line-info first-line' }),
43
- data &&
44
- data.map((item, i) => (React.createElement(ItemHistory, { key: i, ...item }))),
45
- React.createElement(Pagination, { parentElement: containerRef.current, activePageState: currentPage, ...pagination, onChange: (page) => setCurrentPage(page) }))))) : null;
28
+ histories.map((item, i) => (React.createElement(ItemHistory, { key: i, ...item }))),
29
+ React.createElement(Pagination, { parentElement: containerRef.current, activePageState: pagination.currentPage, ...pagination, onChange: (page) => getBalanceHistory(page) }))))) : null;
46
30
  };
47
31
  export default HistoryBalance;
@@ -1,7 +1,6 @@
1
1
  export default StatusBalance;
2
- declare function StatusBalance({ allItem, activeStatus, currency }: {
3
- allItem: any;
4
- activeStatus: any;
2
+ declare function StatusBalance({ balanceStatuses, currency }: {
3
+ balanceStatuses: any;
5
4
  currency: any;
6
5
  }): React.JSX.Element;
7
6
  import React from 'react';
@@ -1,11 +1,16 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Text, useResizeObserver, useUi } from '@weareconceptstudio/core';
3
3
  //* Styles
4
4
  import StatusBalanceStyle from './style';
5
5
  //* Component
6
6
  import ItemStatus from './ItemStatus';
7
- const StatusBalance = ({ allItem, activeStatus, currency }) => {
7
+ import { useBalance } from '../BalanceContext';
8
+ const StatusBalance = ({ balanceStatuses, currency }) => {
8
9
  const { winWidth } = useUi();
10
+ const data = useBalance();
11
+ const activeStatus = useMemo(() => {
12
+ return data.balance ? data.balance.info.status : null;
13
+ }, [data]);
9
14
  //! Refs
10
15
  const wrapperStatusRef = useRef();
11
16
  const statusActiveItem = useRef(false);
@@ -32,8 +37,8 @@ const StatusBalance = ({ allItem, activeStatus, currency }) => {
32
37
  contentRef.current.style.width = differences.length * 351 + 'px';
33
38
  }
34
39
  }
35
- if (allItem.length) {
36
- statusActiveItem.current = allItem.findIndex((item) => item.name?.toLowerCase() === activeStatus?.toLowerCase());
40
+ if (balanceStatuses.length) {
41
+ statusActiveItem.current = balanceStatuses.findIndex((item) => item.name?.toLowerCase() === activeStatus?.toLowerCase());
37
42
  }
38
43
  }, [resizes, winWidth]);
39
44
  return (React.createElement(StatusBalanceStyle, { ref: styleRef, className: 'account-progress-status-wrapper' },
@@ -42,15 +47,15 @@ const StatusBalance = ({ allItem, activeStatus, currency }) => {
42
47
  React.createElement("div", { className: 'line-title' })),
43
48
  React.createElement("div", { ref: outsideContentRef, className: 'outside-wrapper-content' },
44
49
  React.createElement("div", { ref: contentRef, className: 'content-wrapper' },
45
- React.createElement("div", { ref: wrapperStatusRef, className: 'wrapper-status' }, allItem.length &&
50
+ React.createElement("div", { ref: wrapperStatusRef, className: 'wrapper-status' }, balanceStatuses.length &&
46
51
  statusActiveItem.current !== false &&
47
- allItem.map((item, i, arr) => {
52
+ balanceStatuses.map((item, i, arr) => {
48
53
  return (React.createElement(ItemStatus, { key: i, title: item.name, value: item.value, currency: currency, cashback: item.cashback, className: `${i == 0 ? 'start-item' : i == arr.length - 1 ? 'end-item' : ''} ${i <= statusActiveItem.current ? 'active-status' : ''}` }));
49
54
  })),
50
- React.createElement("div", { className: 'wrapper-line-all' }, allItem.length &&
55
+ React.createElement("div", { className: 'wrapper-line-all' }, balanceStatuses.length &&
51
56
  statusActiveItem.current !== false &&
52
57
  sizeLine &&
53
- allItem.map((_, i, arr) => {
58
+ balanceStatuses.map((_, i, arr) => {
54
59
  return (i < arr.length - 1 && (React.createElement("div", { key: i, className: `line`, style: { width: sizeLine[i] + 'px' } },
55
60
  React.createElement("div", { className: `inner-line-background ${i < statusActiveItem.current ? 'active-status' : ''}` }))));
56
61
  }))))));
@@ -0,0 +1,3 @@
1
+ export default Voucher;
2
+ declare function Voucher(): React.JSX.Element;
3
+ import React from 'react';
@@ -0,0 +1,37 @@
1
+ import React, { useRef, useCallback } from 'react';
2
+ import { useBalance } from '../BalanceContext';
3
+ //* Components
4
+ import { Form, Input } from '@weareconceptstudio/form';
5
+ import { Text, useUi } from '@weareconceptstudio/core';
6
+ import { AccountButton, WarningMessageForPopup } from '../../../../components';
7
+ //* Style
8
+ import VoucherStyle from './style';
9
+ const Voucher = () => {
10
+ const { openPopup } = useUi();
11
+ const formRef = useRef();
12
+ const { redeemVoucher } = useBalance();
13
+ //! Handle Popup
14
+ const handleSuccessPopup = useCallback(() => {
15
+ openPopup(React.createElement(WarningMessageForPopup, { title: 'account.balance_promotions.voucher.redeemedTitle', description: 'account.balance_promotions.voucher.redeemedDescription' }), {
16
+ className: 'messagePopup',
17
+ accountIcon: true,
18
+ });
19
+ }, []);
20
+ const onSubmit = async (values) => {
21
+ return await redeemVoucher(values.code).then(() => {
22
+ formRef.current.reset();
23
+ handleSuccessPopup();
24
+ });
25
+ };
26
+ return (React.createElement(VoucherStyle, null,
27
+ React.createElement("div", { className: 'wrapper-title-section' },
28
+ React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p account-p1 first-letter status-title-section-progress', text: 'account.balance_promotions.voucher.title' }),
29
+ React.createElement("div", { className: 'line-title' })),
30
+ React.createElement(Text, { className: 'account-primary-color1 account-p account-p4', text: 'account.balance_promotions.voucher.description' }),
31
+ React.createElement("div", { className: 'voucher-form-container' },
32
+ React.createElement(Form, { ref: formRef, onSubmit: onSubmit, mode: 'onSubmit', className: 'voucher-form' },
33
+ React.createElement(Form.Item, { name: 'code', errorKey: 'account.balance_promotions.voucher.code' },
34
+ React.createElement(Input, { placeholder: 'account.balance_promotions.voucher.inputPlaceholder' })),
35
+ React.createElement(AccountButton, { type: 'submit', className: 'outline', text: 'account.general_actions.redeem' })))));
36
+ };
37
+ export default Voucher;
@@ -0,0 +1,2 @@
1
+ export default VoucherStyle;
2
+ declare const VoucherStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,68 @@
1
+ import styled from 'styled-components';
2
+ const VoucherStyle = styled.div `
3
+ --account_distance_section_voucher: var(--sp6x);
4
+ --account_distance_line_marginTB: var(--sp4x) 0;
5
+ --account_voucherInputPadTB: var(--sp2x);
6
+ --account_voucherInputPadLR: var(--sp2x);
7
+
8
+ --account_voucherButtonPadTB: var(--sp2x);
9
+ --account_voucherButtonPadLR: var(--sp7x);
10
+
11
+ margin-bottom: var(--account_distance_section_voucher);
12
+
13
+ .wrapper-title-section {
14
+ .line-title {
15
+ width: 100%;
16
+ height: 2px;
17
+ background-color: var(--account_primaryColor1);
18
+ margin: var(--account_distance_line_marginTB);
19
+ }
20
+ }
21
+
22
+ .voucher-form-container {
23
+ width: 50%;
24
+ margin-top: var(--sp2x);
25
+
26
+ .voucher-form {
27
+ display: flex;
28
+ gap: var(--sp2x);
29
+ justify-content: space-between;
30
+
31
+ .form-item {
32
+ flex: 1;
33
+
34
+ .base-input {
35
+ padding: var(--account_voucherInputPadTB) var(--account_voucherInputPadLR) !important;
36
+ font-size: var(--account_p3) !important;
37
+ line-height: var(--account_lineHeight) !important;
38
+ }
39
+ }
40
+
41
+ .btn-wrap {
42
+ width: fit-content !important;
43
+ height: fit-content !important;
44
+
45
+ button {
46
+ padding: var(--account_voucherButtonPadTB) var(--account_voucherButtonPadLR);
47
+ font-size: var(--account_p3);
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ /* //! mobile */
54
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
55
+ .voucher-form-container {
56
+ width: 100%;
57
+
58
+ .voucher-form {
59
+ flex-direction: column;
60
+
61
+ .btn-wrap {
62
+ width: 100% !important;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ `;
68
+ export default VoucherStyle;
@@ -1,7 +1,7 @@
1
1
  export default AccountBalanceTemplate;
2
- declare function AccountBalanceTemplate({ iconValue, dataItem, linkEarnPage, className }: {
2
+ declare function AccountBalanceTemplate({ iconValue, balanceStatuses, linkEarnPage, className }: {
3
3
  iconValue: any;
4
- dataItem: any;
4
+ balanceStatuses: any;
5
5
  linkEarnPage: any;
6
6
  className: any;
7
7
  }): React.JSX.Element;
@@ -1,33 +1,20 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { api, useTranslation } from '@weareconceptstudio/core';
1
+ import React from 'react';
3
2
  import { useAccountContext } from '../../../AccountProvider';
3
+ import { BalanceProvider } from './BalanceContext';
4
4
  //* Style
5
5
  import AccountBalanceTemplateStyle from './style';
6
6
  //* Component
7
7
  import HeroBalance from './HeroBalance';
8
8
  import HistoryBalance from './HistoryBalance';
9
9
  import StatusBalance from './StatusBalance';
10
- const AccountBalanceTemplate = ({ iconValue, dataItem, linkEarnPage, className }) => {
11
- const { selectedLang } = useTranslation();
10
+ import Voucher from './Voucher';
11
+ const AccountBalanceTemplate = ({ iconValue, balanceStatuses, linkEarnPage, className }) => {
12
12
  const { currency } = useAccountContext();
13
- //! State
14
- const [dataBalance, setDataBalance] = useState(false);
15
- useEffect(() => {
16
- api.get({ url: `balance`, lang: selectedLang }).then((data) => {
17
- setDataBalance(data);
18
- });
19
- }, []);
20
- return dataBalance ? (React.createElement(AccountBalanceTemplateStyle, { className: className || '' },
21
- React.createElement(HeroBalance, { currency: currency, iconValue: iconValue, nextStatusTitle: 'resident', balance: dataBalance.balance, cashback: dataBalance.cashback, progress: dataBalance.info.timeline, totalSpent: dataBalance.info.spent.current, title: dataBalance.info.status.toLowerCase(), nextStatusValue: dataBalance.info.spent.next, description: (() => {
22
- if (dataItem) {
23
- const { description } = dataItem.find((item) => item.name?.toLowerCase() === dataBalance.info.status?.toLowerCase()) || {};
24
- return { description };
25
- }
26
- else {
27
- return false;
28
- }
29
- })() }),
30
- React.createElement(StatusBalance, { allItem: dataItem, currency: currency, activeStatus: dataBalance.info.status }),
31
- React.createElement(HistoryBalance, { linkEarnPage: linkEarnPage }))) : null;
13
+ return (React.createElement(BalanceProvider, null,
14
+ React.createElement(AccountBalanceTemplateStyle, { className: className || '' },
15
+ React.createElement(HeroBalance, { currency: currency, iconValue: iconValue, balanceStatuses: balanceStatuses }),
16
+ React.createElement(Voucher, null),
17
+ React.createElement(StatusBalance, { balanceStatuses: balanceStatuses, currency: currency }),
18
+ React.createElement(HistoryBalance, { linkEarnPage: linkEarnPage }))));
32
19
  };
33
20
  export default AccountBalanceTemplate;
@@ -11,7 +11,7 @@ const AccountInfo = ({ user, onAccountUpdate, displayFields = defaultDisplayFiel
11
11
  const [edit, setEdit] = useState(false);
12
12
  //! Handle Popup
13
13
  const handleSuccessPopup = useCallback(() => {
14
- openPopup(React.createElement(WarningMessageForPopup, { title: 'account.order_balance.yourSettingsHaveBeenSaved', description: 'account.password_management.yourPasswordHaveBeenChanged' }), {
14
+ openPopup(React.createElement(WarningMessageForPopup, { title: 'account.account_info.yourSettingsHaveBeenSavedTitle', description: 'account.account_info.yourSettingsHaveBeenSavedDescription' }), {
15
15
  className: 'messagePopup',
16
16
  accountIcon: true,
17
17
  });
@@ -10,7 +10,7 @@ const AccountPassword = ({ formFields = defaultFormFields, onPasswordUpdate }) =
10
10
  const [edit, setEdit] = useState(false);
11
11
  //! Handle Popup
12
12
  const handleSuccessPopup = useCallback(() => {
13
- openPopup(React.createElement(WarningMessageForPopup, { title: 'account.order_balance.yourSettingsHaveBeenSaved', description: 'account.password_management.yourPasswordHaveBeenChanged' }), {
13
+ openPopup(React.createElement(WarningMessageForPopup, { title: 'account.password_management.successfullyMessage', description: 'account.password_management.yourPasswordHaveBeenChanged' }), {
14
14
  className: 'messagePopup',
15
15
  accountIcon: true,
16
16
  });
@@ -58,6 +58,8 @@ declare const _default: {
58
58
  emailPlaceholder: string;
59
59
  phone: string;
60
60
  phonePlaceholder: string;
61
+ yourSettingsHaveBeenSavedTitle: string;
62
+ yourSettingsHaveBeenSavedDescription: string;
61
63
  };
62
64
  cart_checkout: {
63
65
  editCart: string;
@@ -148,6 +150,7 @@ declare const _default: {
148
150
  restore: string;
149
151
  free: string;
150
152
  outOfStock: string;
153
+ redeem: string;
151
154
  };
152
155
  user_status: {
153
156
  tourist: string;
@@ -204,7 +207,6 @@ declare const _default: {
204
207
  item: string;
205
208
  price: string;
206
209
  total: string;
207
- yourSettingsHaveBeenSaved: string;
208
210
  billedTo: string;
209
211
  confirmation: string;
210
212
  selectShippingAddress: string;
@@ -234,6 +236,14 @@ declare const _default: {
234
236
  balanceCategoryAmount: string;
235
237
  useYourMoney: string;
236
238
  muramoney: string;
239
+ voucher: {
240
+ title: string;
241
+ description: string;
242
+ redeemedTitle: string;
243
+ redeemedDescription: string;
244
+ code: string;
245
+ inputPlaceholder: string;
246
+ };
237
247
  };
238
248
  };
239
249
  };
@@ -58,6 +58,8 @@ export default {
58
58
  emailPlaceholder: 'Email',
59
59
  phone: 'Phone',
60
60
  phonePlaceholder: 'Phone',
61
+ yourSettingsHaveBeenSavedTitle: 'Your settings have been saved.',
62
+ yourSettingsHaveBeenSavedDescription: 'Your settings have been saved.',
61
63
  },
62
64
  cart_checkout: {
63
65
  editCart: 'Edit cart',
@@ -148,6 +150,7 @@ export default {
148
150
  restore: 'Restore',
149
151
  free: 'Free',
150
152
  outOfStock: 'Out of stock',
153
+ redeem: 'Redeem',
151
154
  },
152
155
  user_status: {
153
156
  tourist: 'tourist',
@@ -204,7 +207,6 @@ export default {
204
207
  item: 'Item',
205
208
  price: 'Price',
206
209
  total: 'Total',
207
- yourSettingsHaveBeenSaved: 'Your settings have been saved.',
208
210
  billedTo: 'Billed to',
209
211
  confirmation: 'Confirmation',
210
212
  selectShippingAddress: 'Select shipping address',
@@ -234,6 +236,14 @@ export default {
234
236
  balanceCategoryAmount: 'amount',
235
237
  useYourMoney: 'Use your muramoney',
236
238
  muramoney: 'Muramoney',
239
+ voucher: {
240
+ title: 'Redeem a gift card',
241
+ description: 'Enter gift card code to add to your Muramoney balance.',
242
+ redeemedTitle: 'The code applied successfully',
243
+ redeemedDescription: 'Your balance updated',
244
+ code: 'code',
245
+ inputPlaceholder: 'Enter gift card code',
246
+ },
237
247
  },
238
248
  },
239
249
  };
@@ -58,6 +58,8 @@ declare const _default: {
58
58
  emailPlaceholder: string;
59
59
  phone: string;
60
60
  phonePlaceholder: string;
61
+ yourSettingsHaveBeenSavedTitle: string;
62
+ yourSettingsHaveBeenSavedDescription: string;
61
63
  };
62
64
  cart_checkout: {
63
65
  editCart: string;
@@ -148,6 +150,7 @@ declare const _default: {
148
150
  restore: string;
149
151
  free: string;
150
152
  outOfStock: string;
153
+ redeem: string;
151
154
  };
152
155
  user_status: {
153
156
  tourist: string;
@@ -204,7 +207,6 @@ declare const _default: {
204
207
  item: string;
205
208
  price: string;
206
209
  total: string;
207
- yourSettingsHaveBeenSaved: string;
208
210
  billedTo: string;
209
211
  confirmation: string;
210
212
  selectShippingAddress: string;
@@ -234,6 +236,14 @@ declare const _default: {
234
236
  balanceCategoryAmount: string;
235
237
  useYourMoney: string;
236
238
  muramoney: string;
239
+ voucher: {
240
+ title: string;
241
+ description: string;
242
+ redeemedTitle: string;
243
+ redeemedDescription: string;
244
+ code: string;
245
+ inputPlaceholder: string;
246
+ };
237
247
  };
238
248
  };
239
249
  };
@@ -50,14 +50,16 @@ export default {
50
50
  orderHistory: 'Պատվերների պատմություն',
51
51
  name: 'Անուն',
52
52
  namePlaceholder: 'Անուն',
53
- firstName: 'Անձնանուն',
54
- firstNamePlaceholder: 'Անձնանուն',
53
+ firstName: 'Անուն',
54
+ firstNamePlaceholder: 'Անուն',
55
55
  lastName: 'Ազգանուն',
56
56
  lastNamePlaceholder: 'Ազգանուն',
57
57
  email: 'Էլ. փոստ',
58
58
  emailPlaceholder: 'Էլ. փոստ',
59
59
  phone: 'Հեռախոս',
60
60
  phonePlaceholder: 'Հեռախոս',
61
+ yourSettingsHaveBeenSavedTitle: 'Ձեր կարգավորումները պահպանվել են։',
62
+ yourSettingsHaveBeenSavedDescription: 'Ձեր կարգավորումները պահպանվել են։',
61
63
  },
62
64
  cart_checkout: {
63
65
  editCart: 'Խմբագրել զամբյուղը',
@@ -148,6 +150,7 @@ export default {
148
150
  restore: 'Վերականգնել',
149
151
  free: 'Անվճար',
150
152
  outOfStock: 'Պահեստում չկա',
153
+ redeem: 'Փոխանակել',
151
154
  },
152
155
  user_status: {
153
156
  tourist: 'տուրիստ',
@@ -204,7 +207,6 @@ export default {
204
207
  item: 'Ապրանք',
205
208
  price: 'Գին',
206
209
  total: 'Ընդհանուր',
207
- yourSettingsHaveBeenSaved: 'Ձեր կարգավորումները պահպանվել են։',
208
210
  billedTo: 'Վճարվել է',
209
211
  confirmation: 'Հաստատում',
210
212
  selectShippingAddress: 'Ընտրեք առաքման հասցե',
@@ -234,6 +236,14 @@ export default {
234
236
  balanceCategoryAmount: 'Գումար',
235
237
  useYourMoney: 'Օգտագործեք ձեր muramoney-ն',
236
238
  muramoney: 'Muramoney',
239
+ voucher: {
240
+ title: 'Փոխանակեք նվեր քարտը',
241
+ description: 'Մուտքագրեք նվեր քարտի կոդը՝ ձեր Muramoney մնացորդին ավելացնելու համար։',
242
+ redeemedTitle: 'Կոդը հաջողությամբ կիրառվեց',
243
+ redeemedDescription: 'Ձեր մնացորդը թարմացվել է',
244
+ code: 'կոդ',
245
+ inputPlaceholder: 'Մուտքագրեք նվեր քարտի կոդը',
246
+ },
237
247
  },
238
248
  },
239
249
  };
@@ -59,6 +59,8 @@ declare const _default: {
59
59
  emailPlaceholder: string;
60
60
  phone: string;
61
61
  phonePlaceholder: string;
62
+ yourSettingsHaveBeenSavedTitle: string;
63
+ yourSettingsHaveBeenSavedDescription: string;
62
64
  };
63
65
  cart_checkout: {
64
66
  editCart: string;
@@ -149,6 +151,7 @@ declare const _default: {
149
151
  restore: string;
150
152
  free: string;
151
153
  outOfStock: string;
154
+ redeem: string;
152
155
  };
153
156
  user_status: {
154
157
  tourist: string;
@@ -205,7 +208,6 @@ declare const _default: {
205
208
  item: string;
206
209
  price: string;
207
210
  total: string;
208
- yourSettingsHaveBeenSaved: string;
209
211
  billedTo: string;
210
212
  confirmation: string;
211
213
  selectShippingAddress: string;
@@ -235,6 +237,14 @@ declare const _default: {
235
237
  balanceCategoryAmount: string;
236
238
  useYourMoney: string;
237
239
  muramoney: string;
240
+ voucher: {
241
+ title: string;
242
+ description: string;
243
+ redeemedTitle: string;
244
+ redeemedDescription: string;
245
+ code: string;
246
+ inputPlaceholder: string;
247
+ };
238
248
  };
239
249
  };
240
250
  };
@@ -298,6 +308,8 @@ declare const _default: {
298
308
  emailPlaceholder: string;
299
309
  phone: string;
300
310
  phonePlaceholder: string;
311
+ yourSettingsHaveBeenSavedTitle: string;
312
+ yourSettingsHaveBeenSavedDescription: string;
301
313
  };
302
314
  cart_checkout: {
303
315
  editCart: string;
@@ -388,6 +400,7 @@ declare const _default: {
388
400
  restore: string;
389
401
  free: string;
390
402
  outOfStock: string;
403
+ redeem: string;
391
404
  };
392
405
  user_status: {
393
406
  tourist: string;
@@ -444,7 +457,6 @@ declare const _default: {
444
457
  item: string;
445
458
  price: string;
446
459
  total: string;
447
- yourSettingsHaveBeenSaved: string;
448
460
  billedTo: string;
449
461
  confirmation: string;
450
462
  selectShippingAddress: string;
@@ -474,6 +486,14 @@ declare const _default: {
474
486
  balanceCategoryAmount: string;
475
487
  useYourMoney: string;
476
488
  muramoney: string;
489
+ voucher: {
490
+ title: string;
491
+ description: string;
492
+ redeemedTitle: string;
493
+ redeemedDescription: string;
494
+ code: string;
495
+ inputPlaceholder: string;
496
+ };
477
497
  };
478
498
  };
479
499
  };
@@ -538,6 +558,8 @@ declare const _default: {
538
558
  emailPlaceholder: string;
539
559
  phone: string;
540
560
  phonePlaceholder: string;
561
+ yourSettingsHaveBeenSavedTitle: string;
562
+ yourSettingsHaveBeenSavedDescription: string;
541
563
  };
542
564
  cart_checkout: {
543
565
  editCart: string;
@@ -628,6 +650,7 @@ declare const _default: {
628
650
  restore: string;
629
651
  free: string;
630
652
  outOfStock: string;
653
+ redeem: string;
631
654
  };
632
655
  user_status: {
633
656
  tourist: string;
@@ -684,7 +707,6 @@ declare const _default: {
684
707
  item: string;
685
708
  price: string;
686
709
  total: string;
687
- yourSettingsHaveBeenSaved: string;
688
710
  billedTo: string;
689
711
  confirmation: string;
690
712
  selectShippingAddress: string;
@@ -714,6 +736,14 @@ declare const _default: {
714
736
  balanceCategoryAmount: string;
715
737
  useYourMoney: string;
716
738
  muramoney: string;
739
+ voucher: {
740
+ title: string;
741
+ description: string;
742
+ redeemedTitle: string;
743
+ redeemedDescription: string;
744
+ code: string;
745
+ inputPlaceholder: string;
746
+ };
717
747
  };
718
748
  };
719
749
  };
@@ -59,6 +59,8 @@ declare const _default: {
59
59
  emailPlaceholder: string;
60
60
  phone: string;
61
61
  phonePlaceholder: string;
62
+ yourSettingsHaveBeenSavedTitle: string;
63
+ yourSettingsHaveBeenSavedDescription: string;
62
64
  };
63
65
  cart_checkout: {
64
66
  editCart: string;
@@ -149,6 +151,7 @@ declare const _default: {
149
151
  restore: string;
150
152
  free: string;
151
153
  outOfStock: string;
154
+ redeem: string;
152
155
  };
153
156
  user_status: {
154
157
  tourist: string;
@@ -205,7 +208,6 @@ declare const _default: {
205
208
  item: string;
206
209
  price: string;
207
210
  total: string;
208
- yourSettingsHaveBeenSaved: string;
209
211
  billedTo: string;
210
212
  confirmation: string;
211
213
  selectShippingAddress: string;
@@ -235,6 +237,14 @@ declare const _default: {
235
237
  balanceCategoryAmount: string;
236
238
  useYourMoney: string;
237
239
  muramoney: string;
240
+ voucher: {
241
+ title: string;
242
+ description: string;
243
+ redeemedTitle: string;
244
+ redeemedDescription: string;
245
+ code: string;
246
+ inputPlaceholder: string;
247
+ };
238
248
  };
239
249
  };
240
250
  };
@@ -59,6 +59,8 @@ export default {
59
59
  emailPlaceholder: 'Электронная почта',
60
60
  phone: 'Телефон',
61
61
  phonePlaceholder: 'Телефон',
62
+ yourSettingsHaveBeenSavedTitle: 'Ваши настройки были сохранены.',
63
+ yourSettingsHaveBeenSavedDescription: 'Ваши настройки были сохранены.',
62
64
  },
63
65
  cart_checkout: {
64
66
  editCart: 'Редактировать корзину',
@@ -149,6 +151,7 @@ export default {
149
151
  restore: 'Восстановить',
150
152
  free: 'Бесплатно',
151
153
  outOfStock: 'Распродано',
154
+ redeem: 'Активировать',
152
155
  },
153
156
  user_status: {
154
157
  tourist: 'Турист',
@@ -205,7 +208,6 @@ export default {
205
208
  item: 'Товар',
206
209
  price: 'Цена',
207
210
  total: 'Итого',
208
- yourSettingsHaveBeenSaved: 'Ваши настройки были сохранены.',
209
211
  billedTo: 'Выставлено на',
210
212
  confirmation: 'Подтверждение',
211
213
  selectShippingAddress: 'Выберите адрес доставки',
@@ -235,6 +237,14 @@ export default {
235
237
  balanceCategoryAmount: 'сумма',
236
238
  useYourMoney: 'Используйте свой muramoney',
237
239
  muramoney: 'Muramoney',
240
+ voucher: {
241
+ title: 'Активируйте подарочную карту',
242
+ description: 'Введите код подарочной карты, чтобы добавить средства на ваш баланс Muramoney.',
243
+ redeemedTitle: 'Код успешно применён',
244
+ redeemedDescription: 'Ваш баланс обновлён',
245
+ code: 'код',
246
+ inputPlaceholder: 'Введите код подарочной карты',
247
+ },
238
248
  },
239
249
  },
240
250
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/account",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "Concept Studio Account",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",