@weareconceptstudio/account 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Loader/index.d.ts +2 -0
- package/dist/components/Loader/index.js +7 -0
- package/dist/components/Loader/style.d.ts +2 -0
- package/dist/components/Loader/style.js +3 -0
- package/dist/components/TotalCheckout/MuramoneyComp/index.d.ts +2 -1
- package/dist/components/TotalCheckout/MuramoneyComp/index.js +2 -2
- package/dist/components/TotalCheckout/MuramoneyComp/utils.d.ts +1 -0
- package/dist/components/TotalCheckout/MuramoneyComp/utils.js +1 -0
- package/dist/components/TotalCheckout/PromoCodeComp/index.d.ts +2 -1
- package/dist/components/TotalCheckout/PromoCodeComp/index.js +2 -2
- package/dist/components/TotalCheckout/index.js +35 -4
- package/dist/components/TotalCheckout/style.js +10 -0
- package/dist/modules/account/AccountBalanceTemplate/HistoryBalance/ItemHistory/index.js +6 -1
- package/dist/modules/address/AddressForm/style.js +5 -0
- package/dist/modules/address/ShippingBillingForm/style.js +5 -0
- package/dist/modules/address/ShippingBillingInfo/index.js +1 -4
- package/dist/modules/checkout/CheckoutProvider.js +3 -2
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +4 -3
- package/dist/modules/order/OrderDetails/index.js +6 -1
- package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/index.d.ts +1 -2
- package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/index.js +2 -2
- package/dist/{components/TotalCheckout → modules/payment}/CardComp/index.d.ts +3 -2
- package/dist/{components/TotalCheckout → modules/payment}/CardComp/index.js +14 -18
- package/dist/{components/TotalCheckout → modules/payment}/CardComp/style.js +20 -6
- package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/index.js +4 -3
- package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/index.d.ts +2 -2
- package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/index.js +8 -10
- package/dist/modules/payment/PaymentMethodsTemplate/index.js +16 -20
- package/dist/modules/payment/PaymentMethodsTemplate/style.js +12 -16
- package/dist/modules/payment/PaymentWrap/index.d.ts +6 -0
- package/dist/modules/payment/PaymentWrap/index.js +26 -0
- package/dist/modules/payment/PaymentWrap/style.d.ts +2 -0
- package/dist/{components/TotalCheckout/SelectPaymentMethodPopup → modules/payment/PaymentWrap}/style.js +11 -55
- package/dist/modules/payment/SelectPaymentMethodPopup/index.d.ts +3 -0
- package/dist/modules/payment/SelectPaymentMethodPopup/index.js +25 -0
- package/dist/modules/payment/SelectPaymentMethodPopup/style.js +81 -0
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.js +4 -0
- package/dist/translations/hy.d.ts +3 -0
- package/dist/translations/hy.js +4 -0
- package/dist/translations/index.d.ts +9 -0
- package/dist/translations/ru.d.ts +3 -0
- package/dist/translations/ru.js +4 -0
- package/package.json +1 -1
- package/dist/components/TotalCheckout/SelectPaymentMethodPopup/index.d.ts +0 -3
- package/dist/components/TotalCheckout/SelectPaymentMethodPopup/index.js +0 -35
- /package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/style.d.ts +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/style.js +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/CardComp/style.d.ts +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/index.d.ts +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/style.d.ts +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/style.js +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/icons.d.ts +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/icons.js +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/style.d.ts +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/style.js +0 -0
- /package/dist/{components/TotalCheckout → modules/payment}/SelectPaymentMethodPopup/style.d.ts +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export default MuramoneyComp;
|
|
2
|
-
declare function MuramoneyComp({ isMuramoney, currency, balance, useBalance, balanceHandler }: {
|
|
2
|
+
declare function MuramoneyComp({ isMuramoney, currency, balance, useBalance, balanceHandler, getItemCount }: {
|
|
3
3
|
isMuramoney?: boolean;
|
|
4
4
|
currency: any;
|
|
5
5
|
balance: any;
|
|
6
6
|
useBalance: any;
|
|
7
7
|
balanceHandler: any;
|
|
8
|
+
getItemCount: any;
|
|
8
9
|
}): React.JSX.Element;
|
|
9
10
|
import React from 'react';
|
|
@@ -5,7 +5,7 @@ import AccountButton from '../../AccountButton';
|
|
|
5
5
|
import { balanceFields } from './utils';
|
|
6
6
|
//* Style
|
|
7
7
|
import MuramoneyCompStyle from './style';
|
|
8
|
-
const MuramoneyComp = ({ isMuramoney = true, currency, balance, useBalance, balanceHandler }) => {
|
|
8
|
+
const MuramoneyComp = ({ isMuramoney = true, currency, balance, useBalance, balanceHandler, getItemCount }) => {
|
|
9
9
|
const { translate } = useTranslation();
|
|
10
10
|
//! States
|
|
11
11
|
const [disable, setDisable] = useState(false);
|
|
@@ -14,7 +14,7 @@ const MuramoneyComp = ({ isMuramoney = true, currency, balance, useBalance, bala
|
|
|
14
14
|
setDisable(true);
|
|
15
15
|
balanceHandler(values.balance);
|
|
16
16
|
};
|
|
17
|
-
return isMuramoney ? (React.createElement(MuramoneyCompStyle, { className:
|
|
17
|
+
return isMuramoney ? (React.createElement(MuramoneyCompStyle, { className: `collapse-distance ${getItemCount && balance ? ' ' : 'disable'}` },
|
|
18
18
|
React.createElement(CollapseItem, { disable: disable,
|
|
19
19
|
// status={'open'}
|
|
20
20
|
title: React.createElement(React.Fragment, null,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default PromoCodeComp;
|
|
2
|
-
declare function PromoCodeComp({ isPromoCode, promo_code }: {
|
|
2
|
+
declare function PromoCodeComp({ isPromoCode, promo_code, getItemCount }: {
|
|
3
3
|
isPromoCode?: boolean;
|
|
4
4
|
promo_code: any;
|
|
5
|
+
getItemCount: any;
|
|
5
6
|
}): React.JSX.Element;
|
|
6
7
|
import React from 'react';
|
|
@@ -5,7 +5,7 @@ import AccountButton from '../../AccountButton';
|
|
|
5
5
|
import { promoCodeFields } from './utils';
|
|
6
6
|
//* Style
|
|
7
7
|
import PromoCodeCompStyle from './style';
|
|
8
|
-
const PromoCodeComp = ({ isPromoCode = true, promo_code }) => {
|
|
8
|
+
const PromoCodeComp = ({ isPromoCode = true, promo_code, getItemCount }) => {
|
|
9
9
|
//! States
|
|
10
10
|
const [couponCode, setCouponCode] = useState(false);
|
|
11
11
|
const [disable, setDisable] = useState(false);
|
|
@@ -14,7 +14,7 @@ const PromoCodeComp = ({ isPromoCode = true, promo_code }) => {
|
|
|
14
14
|
setCouponCode(true);
|
|
15
15
|
setDisable(true);
|
|
16
16
|
};
|
|
17
|
-
return isPromoCode ? (React.createElement(PromoCodeCompStyle, { className:
|
|
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' },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
1
|
+
import React, { memo, useEffect, useRef } from 'react';
|
|
2
2
|
import { Text, CollapseContainer, handlePriceCheckFunc, numToLocalString } from '@weareconceptstudio/core';
|
|
3
3
|
import { useAccountContext } from '../../AccountProvider';
|
|
4
4
|
import { useAddressContext, useCheckoutContext } from '../../modules';
|
|
@@ -11,7 +11,7 @@ import CommentComp from './CommentComp';
|
|
|
11
11
|
import TotalCheckoutStyle from './style';
|
|
12
12
|
//* Skeleton
|
|
13
13
|
import SkeletonTotalCheckout from './Skeleton';
|
|
14
|
-
// TODO:
|
|
14
|
+
// TODO: Promo code
|
|
15
15
|
const promo_code = '10% of first order';
|
|
16
16
|
const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, isCheckout = false }) => {
|
|
17
17
|
const { currency, useCart, useUser } = useAccountContext();
|
|
@@ -22,6 +22,36 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
22
22
|
const handleBalance = (amount) => {
|
|
23
23
|
fillCart('useBalance', amount);
|
|
24
24
|
};
|
|
25
|
+
const innerCollapseRef = useRef(null);
|
|
26
|
+
//! disable keypress on input
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const handleKeyDown = (event) => {
|
|
29
|
+
if (event.key === 'Enter') {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if ((!itemsCount || !user.balance) && innerCollapseRef.current) {
|
|
34
|
+
let inputField = innerCollapseRef.current.querySelectorAll('.base-input');
|
|
35
|
+
if (inputField.length) {
|
|
36
|
+
[...inputField].forEach((item, i) => {
|
|
37
|
+
if (!user.balance && itemsCount && i == 1) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
item.addEventListener('keydown', handleKeyDown);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
if ((!itemsCount || !user.balance) && innerCollapseRef.current) {
|
|
48
|
+
const inputField = innerCollapseRef.current.querySelectorAll('.base-input');
|
|
49
|
+
[...inputField].map((item) => {
|
|
50
|
+
item.removeEventListener('keydown', handleKeyDown);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
});
|
|
25
55
|
return (React.createElement(TotalCheckoutStyle, null,
|
|
26
56
|
React.createElement("div", { className: `cart-main-wrap` },
|
|
27
57
|
React.createElement("div", { className: `left-panel-wrap panel` }, children),
|
|
@@ -42,8 +72,9 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
42
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}` })),
|
|
43
73
|
!isCheckout ? (React.createElement(FreeShippingComp, { currency: currency, shippingCost: shippingCost, shippingCostValue: shippingCostValue, freeShippingRange: freeShippingRange })) : null,
|
|
44
74
|
user ? (React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
|
|
45
|
-
React.createElement(
|
|
46
|
-
|
|
75
|
+
React.createElement("div", { ref: innerCollapseRef },
|
|
76
|
+
React.createElement(MuramoneyComp, { getItemCount: itemsCount, balance: user.balance, currency: currency, balanceHandler: handleBalance, useBalance: useBalance }),
|
|
77
|
+
React.createElement(PromoCodeComp, { getItemCount: itemsCount, promo_code: promo_code })))) : null,
|
|
47
78
|
isCheckout && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, { fillCheckoutData: fillCheckoutData }) : null,
|
|
48
79
|
React.createElement(AccountButton, { 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))))));
|
|
49
80
|
});
|
|
@@ -172,6 +172,16 @@ const TotalCheckoutStyle = styled.section `
|
|
|
172
172
|
.collapse-distance {
|
|
173
173
|
margin-top: var(--account_collapseSmallDistance);
|
|
174
174
|
padding-top: var(--account_collapseSmallDistance);
|
|
175
|
+
|
|
176
|
+
&.disable {
|
|
177
|
+
#collapse-description {
|
|
178
|
+
button {
|
|
179
|
+
pointer-events: none;
|
|
180
|
+
border-color: var(--account_primaryColor5);
|
|
181
|
+
color: var(--account_primaryColor5);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
.muramoney-container,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { Text, useTranslation } from '@weareconceptstudio/core';
|
|
3
|
+
import { useAccountContext } from '../../../../../AccountProvider';
|
|
3
4
|
//* Styles
|
|
4
5
|
import ItemHistoryStyle from './style';
|
|
5
6
|
const ItemHistory = ({ date, activity, value, action_type }) => {
|
|
6
7
|
const { translate } = useTranslation();
|
|
8
|
+
const { useCart } = useAccountContext();
|
|
9
|
+
const { currency } = useCart();
|
|
7
10
|
//! Refs
|
|
8
11
|
const titleWrapperRef = useRef();
|
|
9
12
|
const getSizeItem = useRef();
|
|
@@ -36,7 +39,9 @@ const ItemHistory = ({ date, activity, value, action_type }) => {
|
|
|
36
39
|
React.createElement(Text, { className: `account-primary-color1 account-font-medium account-p account-p1 amount-info-text ${action_type}` },
|
|
37
40
|
React.createElement(Text, { className: 'account-primary-color1 account-font-medium account-p1 mobile-amount-info-text first-letter', tag: 'span' }, translate('balanceCategoryAmount')),
|
|
38
41
|
' ',
|
|
39
|
-
value
|
|
42
|
+
value,
|
|
43
|
+
" ",
|
|
44
|
+
currency)),
|
|
40
45
|
React.createElement("div", { className: 'line-info' })));
|
|
41
46
|
};
|
|
42
47
|
export default ItemHistory;
|
|
@@ -24,6 +24,11 @@ const ShippingBillingFormStyle = styled.div `
|
|
|
24
24
|
--account_antFormItemWidth: 100%;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
.empty-form-item {
|
|
29
|
+
width: var(--account_antFormItemWidth);
|
|
30
|
+
padding: 0 calc(var(--account_formItemDistance) / 2);
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
|
|
@@ -11,9 +11,6 @@ const ShippingBillingInfo = memo(({ className, shipping_address, billing_address
|
|
|
11
11
|
React.createElement("div", { className: `info-space-line` }),
|
|
12
12
|
React.createElement("div", { className: `info-wrap shipped` },
|
|
13
13
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 value`, text: `shippedTo` }),
|
|
14
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 nowrap`, text:
|
|
15
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 nowrap`, text: `${shipping_address.address_1}, ${shipping_address.address_2 ? shipping_address.address_2 + ',' : ''}` }),
|
|
16
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 nowrap`, text: `${shipping_address.city}` }),
|
|
17
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 phone`, text: `${shipping_address.phone}` }))));
|
|
14
|
+
shipping_address.map((item) => (React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 nowrap`, text: item }))))));
|
|
18
15
|
});
|
|
19
16
|
export default ShippingBillingInfo;
|
|
@@ -8,13 +8,14 @@ export const useCheckoutContext = () => {
|
|
|
8
8
|
};
|
|
9
9
|
export const CheckoutProvider = ({ children }) => {
|
|
10
10
|
const { selectedLang } = useTranslation();
|
|
11
|
-
const { useCart } = useAccountContext();
|
|
11
|
+
const { useCart, useUser } = useAccountContext();
|
|
12
12
|
const { getCart } = useCart();
|
|
13
|
+
const { user } = useUser();
|
|
13
14
|
const [checkoutData, setCheckoutData] = useState({
|
|
14
15
|
addressId: null,
|
|
15
16
|
useBalance: null,
|
|
16
17
|
note: '',
|
|
17
|
-
paymentType:
|
|
18
|
+
paymentType: user.default_payment_method,
|
|
18
19
|
});
|
|
19
20
|
const form = useRef();
|
|
20
21
|
const [idramForm, setIdramForm] = useState();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useCallback
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { useUi } from '@weareconceptstudio/core';
|
|
3
|
+
//* Components
|
|
3
4
|
import { SelectAddress } from '../../../address';
|
|
4
5
|
import { SimpleCartItems } from '../../../cart';
|
|
5
|
-
import PaymentComp from '
|
|
6
|
-
import SelectPaymentMethodPopup from '
|
|
6
|
+
import PaymentComp from '../../../payment/PaymentComp';
|
|
7
|
+
import SelectPaymentMethodPopup from '../../../payment/SelectPaymentMethodPopup';
|
|
7
8
|
const StepReview = ({ items }) => {
|
|
8
9
|
const { openPopup } = useUi();
|
|
9
10
|
const handleSelectPopup = useCallback(() => {
|
|
@@ -3,7 +3,7 @@ import { handlePriceCheckFunc, numToLocalString, Text, useTranslation } from '@w
|
|
|
3
3
|
import { useAccountContext } from '../../../AccountProvider';
|
|
4
4
|
import OrderDetailsStyle from './style';
|
|
5
5
|
import OrderStatus from '../OrderStatus';
|
|
6
|
-
const OrderDetails = memo(({ className, status, date, orderNumber, itemsCount, total, shippingCost }) => {
|
|
6
|
+
const OrderDetails = memo(({ className, status, date, orderNumber, itemsCount, total, shippingCost, usedBalance }) => {
|
|
7
7
|
const { translate } = useTranslation();
|
|
8
8
|
const { currency } = useAccountContext();
|
|
9
9
|
return (React.createElement(OrderDetailsStyle, { className: `${className || ''}` },
|
|
@@ -34,6 +34,11 @@ const OrderDetails = memo(({ className, status, date, orderNumber, itemsCount, t
|
|
|
34
34
|
translate('shippingCost'),
|
|
35
35
|
":"),
|
|
36
36
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 value`, text: `${shippingCost == 0 ? 'free' : handlePriceCheckFunc(shippingCost, currency)}` })),
|
|
37
|
+
usedBalance ? (React.createElement("div", { className: `order-detail-item-wrap` },
|
|
38
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1` },
|
|
39
|
+
translate('usedBalance'),
|
|
40
|
+
":"),
|
|
41
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 value` }, handlePriceCheckFunc(usedBalance, currency)))) : null,
|
|
37
42
|
React.createElement("div", { className: `order-detail-item-wrap` },
|
|
38
43
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1` },
|
|
39
44
|
translate('totalPrice'),
|
|
@@ -3,7 +3,7 @@ import { Text, api } from '@weareconceptstudio/core';
|
|
|
3
3
|
import { popupCardSVG } from '../PaymentMethodsComp/icons';
|
|
4
4
|
//* Style
|
|
5
5
|
import AddNewCardStyle from './style';
|
|
6
|
-
const AddNewCard = ({
|
|
6
|
+
const AddNewCard = ({ className }) => {
|
|
7
7
|
const addNew = async () => {
|
|
8
8
|
return await api.post('add-card').then((res) => {
|
|
9
9
|
if (res.redirect_url) {
|
|
@@ -14,6 +14,6 @@ const AddNewCard = ({ title, className }) => {
|
|
|
14
14
|
return (React.createElement(AddNewCardStyle, { className: `new-card-container ${className || ''}`, onClick: addNew },
|
|
15
15
|
React.createElement("div", { className: `new-card-wrap` },
|
|
16
16
|
React.createElement("div", { className: 'account-card-add-icon' }, popupCardSVG),
|
|
17
|
-
React.createElement(Text, { className: `account-add-card-text account-p account-p3 account-font-medium account-primary-color1`, text:
|
|
17
|
+
React.createElement(Text, { className: `account-add-card-text account-p account-p3 account-font-medium account-primary-color1`, text: 'addNewCard' }))));
|
|
18
18
|
};
|
|
19
19
|
export default AddNewCard;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export default CardComp;
|
|
2
|
-
declare function CardComp({ cardOption, className, selectedPayment,
|
|
2
|
+
declare function CardComp({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard }: {
|
|
3
3
|
cardOption: any;
|
|
4
4
|
className: any;
|
|
5
5
|
selectedPayment: any;
|
|
6
|
-
|
|
6
|
+
setSelectedPayment: any;
|
|
7
|
+
deleteCard: any;
|
|
7
8
|
}): React.JSX.Element;
|
|
8
9
|
import React from 'react';
|
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import { Text,
|
|
3
|
-
import WarningMessageForPopup from '../../WarningMessageForPopup';
|
|
4
|
-
import AccountButton from '../../AccountButton';
|
|
2
|
+
import { Text, useUi } from '@weareconceptstudio/core';
|
|
5
3
|
import { mastercardSVG, visaSVG } from '../PaymentMethodsComp/icons';
|
|
4
|
+
//* Components
|
|
5
|
+
import WarningMessageForPopup from '../../../components/WarningMessageForPopup';
|
|
6
|
+
import AccountButton from '../../../components/AccountButton';
|
|
6
7
|
//* Style
|
|
7
8
|
import CardCompStyle from './style';
|
|
8
|
-
const CardComp = ({ cardOption, className, selectedPayment,
|
|
9
|
-
const expired = cardOption.expired;
|
|
9
|
+
const CardComp = ({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard }) => {
|
|
10
10
|
const { openPopup } = useUi();
|
|
11
11
|
const formatCardNumber = (number) => {
|
|
12
12
|
if (!number)
|
|
13
13
|
return '';
|
|
14
14
|
return number.replace(/(.{4})/g, '$1 ').trim();
|
|
15
15
|
};
|
|
16
|
-
const handleDelete = () => {
|
|
17
|
-
console.log('test', cardOption.id);
|
|
18
|
-
};
|
|
19
16
|
//! Handle Popups
|
|
20
17
|
const handleDeletePopup = useCallback(() => {
|
|
21
|
-
openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteCardMessage', description: 'confirmDeleteCard', onRemove:
|
|
18
|
+
openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteCardMessage', description: 'confirmDeleteCard', onRemove: () => deleteCard(cardOption.id) }), {
|
|
22
19
|
className: 'messagePopup',
|
|
23
20
|
accountIcon: true,
|
|
24
21
|
});
|
|
25
|
-
}, [cardOption.id]);
|
|
26
|
-
return (React.createElement(CardCompStyle, { className: `card-container ${cardOption.
|
|
22
|
+
}, [cardOption.id, deleteCard]);
|
|
23
|
+
return (React.createElement(CardCompStyle, { className: `card-container ${cardOption.is_expired ? 'expired' : ''} ${className || ''}` },
|
|
27
24
|
React.createElement("div", { className: `card-wrap-top` },
|
|
28
|
-
React.createElement("div", { className: 'card-svg' }, cardOption && cardOption.
|
|
29
|
-
!
|
|
25
|
+
React.createElement("div", { className: 'card-svg' }, cardOption && cardOption.brand === 'MasterCard' ? React.createElement("div", null, mastercardSVG) : React.createElement("div", null, visaSVG)),
|
|
26
|
+
!cardOption.is_expired ? (React.createElement("div", { key: cardOption.number, className: `circle-selected-wrap cursor-pointer ${selectedPayment == cardOption.id ? 'active' : ''}`, onClick: () => setSelectedPayment(cardOption.id) },
|
|
30
27
|
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedPayment === cardOption.number ? 'selected' : 'note-selected'}` },
|
|
31
28
|
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' })))) : null),
|
|
32
29
|
React.createElement("div", { className: `card-wrap-center` },
|
|
33
|
-
React.createElement(Text, { className: `card-full-name account-p account-p3 account-font-regular
|
|
34
|
-
React.createElement(Text, { className: `card-number
|
|
35
|
-
account-p account-p1 account-font-regular ${expired ? 'account-primary-color3' : 'account_backgroundColor'}`, text: formatCardNumber(cardOption.number) })),
|
|
30
|
+
React.createElement(Text, { className: `card-full-name account-p account-p3 account-font-regular`, text: cardOption.name }),
|
|
31
|
+
React.createElement(Text, { className: `card-number account-p account-p1 account-font-regular`, text: formatCardNumber(cardOption.number) })),
|
|
36
32
|
React.createElement("div", { className: `card-wrap-bottom` },
|
|
37
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular
|
|
38
|
-
React.createElement(AccountButton, { text: `remove`, onClick: handleDeletePopup, btnType: `green-small-text`, className: `account-card-remove-btn account-p account-p3 account-font-regular
|
|
33
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular`, text: cardOption.is_expired ? 'cardExpired' : `Exp. Date ${cardOption.exp_date}` }),
|
|
34
|
+
React.createElement(AccountButton, { text: `remove`, onClick: handleDeletePopup, btnType: `green-small-text`, className: `account-card-remove-btn account-p account-p3 account-font-regular` }))));
|
|
39
35
|
};
|
|
40
36
|
export default CardComp;
|
|
@@ -17,12 +17,6 @@ const CardCompStyle = styled.div `
|
|
|
17
17
|
flex-direction: column;
|
|
18
18
|
justify-content: space-between;
|
|
19
19
|
|
|
20
|
-
&.expired {
|
|
21
|
-
background: #fff4f8;
|
|
22
|
-
border: 2px solid var(--account_primaryColor3);
|
|
23
|
-
width: calc(50% - (var(--account_itemDistance) / 2) - 2px);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
20
|
.card-wrap-top,
|
|
27
21
|
.card-wrap-bottom {
|
|
28
22
|
display: flex;
|
|
@@ -35,6 +29,13 @@ const CardCompStyle = styled.div `
|
|
|
35
29
|
gap: 22px;
|
|
36
30
|
}
|
|
37
31
|
|
|
32
|
+
.card-full-name,
|
|
33
|
+
.card-number,
|
|
34
|
+
.account-card-remove-btn > button,
|
|
35
|
+
.card-wrap-bottom > p {
|
|
36
|
+
color: var(--account_backgroundColor);
|
|
37
|
+
}
|
|
38
|
+
|
|
38
39
|
.card-svg {
|
|
39
40
|
background-color: var(--account_backgroundColor);
|
|
40
41
|
border-radius: 4px;
|
|
@@ -109,6 +110,19 @@ const CardCompStyle = styled.div `
|
|
|
109
110
|
color: var(--account_backgroundColor) !important;
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
&.expired {
|
|
114
|
+
background: #fff4f8;
|
|
115
|
+
border: 2px solid var(--account_primaryColor3);
|
|
116
|
+
width: calc(50% - (var(--account_itemDistance) / 2) - 2px);
|
|
117
|
+
|
|
118
|
+
.card-full-name,
|
|
119
|
+
.card-number,
|
|
120
|
+
.account-card-remove-btn > button,
|
|
121
|
+
.card-wrap-bottom > p {
|
|
122
|
+
color: var(--account_primaryColor3);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
112
126
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
|
|
113
127
|
--account_addCardTextMTop: var(--sp2x);
|
|
114
128
|
--account_itemInternalWrapPad: var(--sp3x);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text } from '@weareconceptstudio/core';
|
|
3
|
-
import
|
|
3
|
+
import { useCheckoutContext } from '../../checkout';
|
|
4
|
+
//* Components
|
|
5
|
+
import AccountButton from '../../../components/AccountButton';
|
|
4
6
|
import PaymentMethodsComp from '../PaymentMethodsComp';
|
|
5
7
|
//* Style
|
|
6
8
|
import PaymentCompStyle from './style';
|
|
7
|
-
import { useCheckoutContext } from '../../../modules';
|
|
8
9
|
const PaymentComp = ({ title, onClick, className }) => {
|
|
9
10
|
const { checkoutData, fillCheckoutData } = useCheckoutContext();
|
|
10
11
|
return (React.createElement(PaymentCompStyle, { className: `item-container ${className || ''}` },
|
|
11
12
|
React.createElement("div", { className: `change-payment-wrap` },
|
|
12
13
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1`, text: title }),
|
|
13
14
|
checkoutData.paymentType && (React.createElement(AccountButton, { text: `change`, btnType: `green-small-text`, onClick: onClick }))),
|
|
14
|
-
React.createElement(PaymentMethodsComp, { showAll: false, selectedPayment: checkoutData.paymentType,
|
|
15
|
+
React.createElement(PaymentMethodsComp, { showAll: false, selectedPayment: checkoutData.paymentType, setSelectedPayment: (value) => fillCheckoutData('paymentType', value) })));
|
|
15
16
|
};
|
|
16
17
|
export default PaymentComp;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default PaymentMethodsComp;
|
|
2
|
-
declare function PaymentMethodsComp({ className, showAll, selectedPayment,
|
|
2
|
+
declare function PaymentMethodsComp({ className, showAll, selectedPayment, setSelectedPayment }: {
|
|
3
3
|
className: any;
|
|
4
4
|
showAll: any;
|
|
5
5
|
selectedPayment: any;
|
|
6
|
-
|
|
6
|
+
setSelectedPayment: any;
|
|
7
7
|
}): React.JSX.Element;
|
|
8
8
|
import React from 'react';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Text } from '@weareconceptstudio/core';
|
|
3
|
-
import { cardSVG, idramSVG, telcellSVG, cashSVG, posTerminalSVG, inecopaySVG } from '
|
|
4
|
-
import { useCheckoutContext } from '
|
|
3
|
+
import { cardSVG, idramSVG, telcellSVG, cashSVG, posTerminalSVG, inecopaySVG } from './icons';
|
|
4
|
+
import { useCheckoutContext } from '../../checkout';
|
|
5
5
|
//* Style
|
|
6
6
|
import PaymentMethodsCompStyle from './style';
|
|
7
|
-
const
|
|
7
|
+
const isNumeric = (value) => !isNaN(value) && !isNaN(parseFloat(value));
|
|
8
|
+
const PaymentMethodsComp = ({ className, showAll, selectedPayment, setSelectedPayment }) => {
|
|
8
9
|
let paymentOptions = [
|
|
9
10
|
{
|
|
10
11
|
label: 'Cash',
|
|
@@ -43,7 +44,7 @@ const PaymentMethodsComp = ({ className, showAll, selectedPayment, selectPayment
|
|
|
43
44
|
];
|
|
44
45
|
}
|
|
45
46
|
const { checkoutData } = useCheckoutContext();
|
|
46
|
-
const cardDetails = checkoutData.paymentType
|
|
47
|
+
const cardDetails = isNumeric(checkoutData.paymentType)
|
|
47
48
|
? {
|
|
48
49
|
card_type: 'MasterCard', // Or 'Visa', based on your logic
|
|
49
50
|
number: '**** **** **** 1234',
|
|
@@ -55,7 +56,7 @@ const PaymentMethodsComp = ({ className, showAll, selectedPayment, selectPayment
|
|
|
55
56
|
filteredOptions = paymentOptions;
|
|
56
57
|
}
|
|
57
58
|
else if (checkoutData.paymentType) {
|
|
58
|
-
filteredOptions = paymentOptions.filter((option) => option.value === checkoutData.paymentType);
|
|
59
|
+
filteredOptions = paymentOptions.filter((option) => option.value === (isNumeric(checkoutData.paymentType) ? 'credit_card' : checkoutData.paymentType));
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
62
|
filteredOptions = paymentOptions;
|
|
@@ -68,15 +69,12 @@ const PaymentMethodsComp = ({ className, showAll, selectedPayment, selectPayment
|
|
|
68
69
|
}
|
|
69
70
|
: option);
|
|
70
71
|
}
|
|
71
|
-
const handleSelect = (value) => {
|
|
72
|
-
selectPayment(value);
|
|
73
|
-
};
|
|
74
72
|
return (React.createElement(PaymentMethodsCompStyle, { className: `payment-item-container ${className || ''}`, "$singlePayment": !!checkoutData.paymentType }, filteredOptions.map((option, index) => (React.createElement("div", { className: 'custom-payment-options', key: index },
|
|
75
73
|
React.createElement("div", { className: 'payment-option-top' },
|
|
76
74
|
React.createElement("div", { className: 'payment-item-left' },
|
|
77
75
|
React.createElement("div", null, option.svg),
|
|
78
76
|
React.createElement(Text, { className: 'payment-label account-p account-p3 account-font-regular account-primary-color1' }, option.label)),
|
|
79
|
-
React.createElement("div", { key: option.value, className: `circle-selected-wrap cursor-pointer ${selectedPayment === option.value ? 'active' : ''}`, onClick: () =>
|
|
77
|
+
React.createElement("div", { key: option.value, className: `circle-selected-wrap cursor-pointer ${selectedPayment === option.value || (option.value == 'credit_card' && isNumeric(selectedPayment)) ? 'active' : ''}`, onClick: () => showAll && setSelectedPayment(option.value) },
|
|
80
78
|
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedPayment === option.value ? 'selected' : 'note-selected'}` },
|
|
81
79
|
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' })))),
|
|
82
80
|
option.value === 'credit_card' && cardDetails && !showAll && (React.createElement("div", { className: 'card-details' },
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import { Text } from '@weareconceptstudio/core';
|
|
4
|
-
import PaymentStyle from './style';
|
|
5
|
-
import AddNewCard from '../../../components/TotalCheckout/AddNewCard';
|
|
6
|
-
import CardComp from '../../../components/TotalCheckout/CardComp';
|
|
7
|
-
import PaymentMethodsComp from '../../../components/TotalCheckout/PaymentMethodsComp';
|
|
3
|
+
import { api, Text } from '@weareconceptstudio/core';
|
|
8
4
|
import { useAccountContext } from '../../../AccountProvider';
|
|
5
|
+
import { useCheckoutContext } from '../../checkout';
|
|
6
|
+
//* Components
|
|
7
|
+
import { AccountButton } from '../../../components';
|
|
8
|
+
import PaymentWrap from '../PaymentWrap';
|
|
9
|
+
//* Style
|
|
10
|
+
import PaymentStyle from './style';
|
|
9
11
|
const PaymentMethodsTemplate = () => {
|
|
10
|
-
const [selectedCard, setSelectedCard] = useState('');
|
|
11
12
|
const { useUser } = useAccountContext();
|
|
12
13
|
const { user } = useUser();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
...prev,
|
|
20
|
-
[key]: value,
|
|
21
|
-
}));
|
|
14
|
+
const { fillCheckoutData } = useCheckoutContext();
|
|
15
|
+
const [selectedPayment, setSelectedPayment] = useState(user.default_payment_method);
|
|
16
|
+
const handlePaymentMethodChangeSubmit = async () => {
|
|
17
|
+
await api.post('update-payment-method', { payment_method: selectedPayment }).then(() => {
|
|
18
|
+
fillCheckoutData('paymentType', selectedPayment);
|
|
19
|
+
});
|
|
22
20
|
};
|
|
23
21
|
return (React.createElement(PaymentStyle, null,
|
|
24
22
|
React.createElement("div", { className: 'account-payment-block' },
|
|
25
23
|
React.createElement(Text, { tag: `h6`, className: `account-font-medium account-primary-color1 title`, text: `myCards` }),
|
|
26
|
-
React.createElement(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
React.createElement("div", { className: 'line' }),
|
|
30
|
-
React.createElement(PaymentMethodsComp, { checkoutData: checkoutData, fillCheckoutData: fillCheckoutData, showAll: true }))));
|
|
24
|
+
React.createElement(PaymentWrap, { selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment }),
|
|
25
|
+
React.createElement("div", { className: 'account-payment-btn-wrapper' },
|
|
26
|
+
React.createElement(AccountButton, { btnType: `full-width`, text: `saveAndApply`, onClick: handlePaymentMethodChangeSubmit })))));
|
|
31
27
|
};
|
|
32
28
|
export default PaymentMethodsTemplate;
|