@weareconceptstudio/account 0.3.4 → 0.3.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.
- package/dist/AccountProvider.js +23 -1
- package/dist/components/AccountButton/index.js +6 -4
- package/dist/components/AccountButton/style.js +61 -1
- package/dist/components/Loader/index.d.ts +4 -1
- package/dist/components/Loader/index.js +19 -3
- package/dist/components/Loader/style.js +152 -1
- package/dist/components/TotalCheckout/BalanceComp/index.d.ts +10 -0
- package/dist/components/TotalCheckout/{MuramoneyComp → BalanceComp}/index.js +10 -10
- package/dist/{modules/payment/PaymentComp → components/TotalCheckout/BalanceComp}/style.d.ts +2 -2
- package/dist/components/TotalCheckout/{MuramoneyComp → BalanceComp}/style.js +30 -30
- package/dist/components/TotalCheckout/index.js +8 -8
- package/dist/components/TotalCheckout/style.js +4 -4
- package/dist/modules/account/AccountTemplate/index.js +2 -0
- package/dist/modules/account/AccountTemplate/style.js +29 -0
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +2 -2
- package/dist/modules/checkout/CheckoutTemplate/index.js +15 -3
- package/dist/modules/payment/AddNewCard/index.d.ts +2 -1
- package/dist/modules/payment/AddNewCard/index.js +5 -5
- package/dist/modules/payment/{CardComp → Card}/index.d.ts +3 -2
- package/dist/modules/payment/{CardComp → Card}/index.js +8 -13
- package/dist/modules/payment/Card/style.d.ts +2 -0
- package/dist/modules/payment/{CardComp → Card}/style.js +2 -2
- package/dist/modules/payment/{PaymentComp → Payment}/index.d.ts +2 -2
- package/dist/modules/payment/Payment/index.js +34 -0
- package/dist/modules/payment/Payment/style.d.ts +2 -0
- package/dist/modules/payment/{PaymentComp → Payment}/style.js +2 -2
- package/dist/modules/payment/PaymentMethodItem/index.d.ts +9 -0
- package/dist/modules/payment/PaymentMethodItem/index.js +29 -0
- package/dist/modules/payment/PaymentMethodItem/style.d.ts +2 -0
- package/dist/modules/payment/{PaymentMethodsComp → PaymentMethodItem}/style.js +37 -53
- package/dist/modules/payment/PaymentMethods/index.d.ts +7 -0
- package/dist/modules/payment/PaymentMethods/index.js +15 -0
- package/dist/modules/payment/PaymentMethods/style.d.ts +2 -0
- package/dist/modules/payment/PaymentMethods/style.js +46 -0
- package/dist/modules/payment/PaymentMethodsTemplate/index.js +12 -3
- package/dist/modules/payment/PaymentWrap/index.d.ts +2 -1
- package/dist/modules/payment/PaymentWrap/index.js +7 -7
- package/dist/modules/payment/SelectPaymentMethodPopup/index.js +1 -1
- package/dist/modules/payment/SelectedPayment/index.d.ts +3 -0
- package/dist/modules/payment/SelectedPayment/index.js +45 -0
- package/package.json +1 -1
- package/dist/components/TotalCheckout/MuramoneyComp/index.d.ts +0 -10
- package/dist/components/TotalCheckout/MuramoneyComp/style.d.ts +0 -2
- package/dist/modules/payment/CardComp/style.d.ts +0 -2
- package/dist/modules/payment/PaymentComp/index.js +0 -17
- package/dist/modules/payment/PaymentMethodsComp/index.d.ts +0 -8
- package/dist/modules/payment/PaymentMethodsComp/index.js +0 -86
- package/dist/modules/payment/PaymentMethodsComp/style.d.ts +0 -2
- /package/dist/components/TotalCheckout/{MuramoneyComp → BalanceComp}/utils.d.ts +0 -0
- /package/dist/components/TotalCheckout/{MuramoneyComp → BalanceComp}/utils.js +0 -0
- /package/dist/modules/payment/{PaymentMethodsComp/icons.d.ts → icons.d.ts} +0 -0
- /package/dist/modules/payment/{PaymentMethodsComp/icons.js → icons.js} +0 -0
|
@@ -90,6 +90,7 @@ const AccountStyle = styled.section `
|
|
|
90
90
|
width: var(--account_rightBarWidth);
|
|
91
91
|
padding: 0 calc(var(--account_colDistance) / 2);
|
|
92
92
|
margin-top: var(--account_stickyMarTop);
|
|
93
|
+
position: relative;
|
|
93
94
|
|
|
94
95
|
.max-width-wrap {
|
|
95
96
|
width: 100%;
|
|
@@ -239,6 +240,20 @@ const AccountStyle = styled.section `
|
|
|
239
240
|
padding: 0 var(--account_contPaddingLR);
|
|
240
241
|
}
|
|
241
242
|
|
|
243
|
+
.right-bar {
|
|
244
|
+
height: 100vh;
|
|
245
|
+
animation: heightMobile 1s ease-out 1.8s forwards;
|
|
246
|
+
|
|
247
|
+
@keyframes heightMobile {
|
|
248
|
+
0% {
|
|
249
|
+
height: 100vh;
|
|
250
|
+
}
|
|
251
|
+
100% {
|
|
252
|
+
height: auto;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
242
257
|
.space-line {
|
|
243
258
|
width: 100%;
|
|
244
259
|
border-bottom: 1px solid var(--account_primaryColor5);
|
|
@@ -277,6 +292,20 @@ const AccountStyle = styled.section `
|
|
|
277
292
|
padding: 0 var(--account_contPaddingLR);
|
|
278
293
|
}
|
|
279
294
|
|
|
295
|
+
.right-bar {
|
|
296
|
+
height: 150vh;
|
|
297
|
+
animation: heightMobile 1s ease-out 1.8s forwards;
|
|
298
|
+
|
|
299
|
+
@keyframes heightMobile {
|
|
300
|
+
0% {
|
|
301
|
+
height: 100vh;
|
|
302
|
+
}
|
|
303
|
+
100% {
|
|
304
|
+
height: auto;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
280
309
|
.space-line {
|
|
281
310
|
width: 100%;
|
|
282
311
|
border-bottom: 1px solid var(--account_primaryColor5);
|
|
@@ -3,7 +3,7 @@ import { useUi } from '@weareconceptstudio/core';
|
|
|
3
3
|
//* Components
|
|
4
4
|
import { SelectAddress } from '../../../address';
|
|
5
5
|
import { SimpleCartItems } from '../../../cart';
|
|
6
|
-
import
|
|
6
|
+
import Payment from '../../../payment/Payment';
|
|
7
7
|
import SelectPaymentMethodPopup from '../../../payment/SelectPaymentMethodPopup';
|
|
8
8
|
const StepReview = ({ items }) => {
|
|
9
9
|
const { openPopup } = useUi();
|
|
@@ -12,7 +12,7 @@ const StepReview = ({ items }) => {
|
|
|
12
12
|
}, []);
|
|
13
13
|
return (React.createElement("div", { className: 'step-review' },
|
|
14
14
|
React.createElement(SelectAddress, null),
|
|
15
|
-
React.createElement(
|
|
15
|
+
React.createElement(Payment, { title: 'payment', onClick: handleSelectPopup }),
|
|
16
16
|
React.createElement(SimpleCartItems, { data: items, smallFontSize: true, title: 'orderItems', className: `checkout-mt`, additionalParameters: {
|
|
17
17
|
remove: false,
|
|
18
18
|
select: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
2
|
-
import {
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { Page } from '@weareconceptstudio/core';
|
|
3
3
|
import { Sequence, TotalCheckout } from '../../../components';
|
|
4
4
|
import { useAddressContext } from '../../address';
|
|
5
5
|
import { useAccountContext } from '../../../AccountProvider';
|
|
@@ -26,8 +26,19 @@ const CheckoutTemplate = () => {
|
|
|
26
26
|
const handleCheckoutFirstStep = () => {
|
|
27
27
|
firstStepFormRef.current.submit();
|
|
28
28
|
};
|
|
29
|
+
const [loadingProcessToPayment, setLoadingProcessToPayment] = useState(false);
|
|
29
30
|
const handleCheckoutBtn = useCallback(() => {
|
|
30
|
-
checkStep.isShipping
|
|
31
|
+
if (checkStep.isShipping) {
|
|
32
|
+
handleCheckoutFirstStep();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setLoadingProcessToPayment(true);
|
|
36
|
+
handleCheckout().finally(() => {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
setLoadingProcessToPayment(false);
|
|
39
|
+
}, 1000);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
31
42
|
}, [checkStep]);
|
|
32
43
|
return (React.createElement(Page, { className: 'checkout use-account' },
|
|
33
44
|
React.createElement(AccountContainer, { className: `second-version` },
|
|
@@ -38,6 +49,7 @@ const CheckoutTemplate = () => {
|
|
|
38
49
|
handleClick: handleCheckoutBtn,
|
|
39
50
|
type: checkStep.isShipping ? 'submit' : 'button',
|
|
40
51
|
text: checkStep.isShipping ? 'proceedToCheckout' : 'proceedToPayment',
|
|
52
|
+
loadingButton: loadingProcessToPayment,
|
|
41
53
|
} }, !addressLoading ? (React.createElement(React.Fragment, null,
|
|
42
54
|
React.createElement(Sequence, { step: checkStep.isShipping ? 'shipping' : 'review' }),
|
|
43
55
|
checkStep.isShipping ? React.createElement(StepShipping, { firstStepFormRef: firstStepFormRef }) : React.createElement(StepReview, { items: items }))) : (React.createElement(React.Fragment, null,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, api } from '@weareconceptstudio/core';
|
|
3
|
-
import { popupCardSVG } from '../
|
|
3
|
+
import { popupCardSVG } from '../icons';
|
|
4
4
|
//* Style
|
|
5
5
|
import AddNewCardStyle from './style';
|
|
6
|
-
const AddNewCard = ({ className }) => {
|
|
7
|
-
const
|
|
8
|
-
return await api.post('add-card').then((res) => {
|
|
6
|
+
const AddNewCard = ({ className, isCheckout }) => {
|
|
7
|
+
const addNewCard = async () => {
|
|
8
|
+
return await api.post('add-card', { backUrl: `${window.location.href}`, isCheckout }).then((res) => {
|
|
9
9
|
if (res.redirect_url) {
|
|
10
10
|
window.location.href = res.redirect_url;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
-
return (React.createElement(AddNewCardStyle, { className: `new-card-container ${className || ''}`, onClick:
|
|
14
|
+
return (React.createElement(AddNewCardStyle, { className: `new-card-container ${className || ''}`, onClick: addNewCard },
|
|
15
15
|
React.createElement("div", { className: `new-card-wrap` },
|
|
16
16
|
React.createElement("div", { className: 'account-card-add-icon' }, popupCardSVG),
|
|
17
17
|
React.createElement(Text, { className: `account-add-card-text account-p account-p3 account-font-medium account-primary-color1`, text: 'addNewCard' }))));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export default
|
|
2
|
-
declare function
|
|
1
|
+
export default Card;
|
|
2
|
+
declare function Card({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard, isCheckout }: {
|
|
3
3
|
cardOption: any;
|
|
4
4
|
className: any;
|
|
5
5
|
selectedPayment: any;
|
|
6
6
|
setSelectedPayment: any;
|
|
7
7
|
deleteCard: any;
|
|
8
|
+
isCheckout: any;
|
|
8
9
|
}): React.JSX.Element;
|
|
9
10
|
import React from 'react';
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
|
-
import { mastercardSVG, visaSVG } from '../
|
|
3
|
+
import { mastercardSVG, visaSVG } from '../icons';
|
|
4
4
|
//* Components
|
|
5
5
|
import WarningMessageForPopup from '../../../components/WarningMessageForPopup';
|
|
6
6
|
import AccountButton from '../../../components/AccountButton';
|
|
7
7
|
//* Style
|
|
8
|
-
import
|
|
9
|
-
const
|
|
8
|
+
import CardStyle from './style';
|
|
9
|
+
const Card = ({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard, isCheckout }) => {
|
|
10
10
|
const { openPopup } = useUi();
|
|
11
|
-
const formatCardNumber = (number) => {
|
|
12
|
-
if (!number)
|
|
13
|
-
return '';
|
|
14
|
-
return number.replace(/(.{4})/g, '$1 ').trim();
|
|
15
|
-
};
|
|
16
11
|
//! Handle Popups
|
|
17
12
|
const handleDeletePopup = useCallback(() => {
|
|
18
13
|
openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteCardMessage', description: 'confirmDeleteCard', onRemove: () => deleteCard(cardOption.id) }), {
|
|
@@ -20,17 +15,17 @@ const CardComp = ({ cardOption, className, selectedPayment, setSelectedPayment,
|
|
|
20
15
|
accountIcon: true,
|
|
21
16
|
});
|
|
22
17
|
}, [cardOption.id, deleteCard]);
|
|
23
|
-
return (React.createElement(
|
|
18
|
+
return (React.createElement(CardStyle, { className: `card-container ${cardOption.is_expired ? 'expired' : ''} ${className || ''}` },
|
|
24
19
|
React.createElement("div", { className: `card-wrap-top` },
|
|
25
20
|
React.createElement("div", { className: 'card-svg' }, cardOption && cardOption.brand === 'MasterCard' ? React.createElement("div", null, mastercardSVG) : React.createElement("div", null, visaSVG)),
|
|
26
21
|
!cardOption.is_expired ? (React.createElement("div", { key: cardOption.number, className: `circle-selected-wrap cursor-pointer ${selectedPayment == cardOption.id ? 'active' : ''}`, onClick: () => setSelectedPayment(cardOption.id) },
|
|
27
|
-
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedPayment === cardOption.
|
|
22
|
+
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedPayment === cardOption.id ? 'selected' : 'note-selected'}` },
|
|
28
23
|
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),
|
|
29
24
|
React.createElement("div", { className: `card-wrap-center` },
|
|
30
25
|
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:
|
|
26
|
+
React.createElement(Text, { className: `card-number account-p account-p1 account-font-regular`, text: cardOption.number })),
|
|
32
27
|
React.createElement("div", { className: `card-wrap-bottom` },
|
|
33
28
|
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` }))));
|
|
29
|
+
!isCheckout && selectedPayment != cardOption.id ? (React.createElement(AccountButton, { text: `remove`, onClick: handleDeletePopup, btnType: `green-small-text`, className: `account-card-remove-btn account-p account-p3 account-font-regular` })) : null)));
|
|
35
30
|
};
|
|
36
|
-
export default
|
|
31
|
+
export default Card;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
const
|
|
2
|
+
const CardStyle = styled.div `
|
|
3
3
|
--account_addCardTextMTop: var(--sp2x);
|
|
4
4
|
--account_itemBorderRadius: var(--sp1-5x);
|
|
5
5
|
--account_itemInternalWrapPad: var(--sp4x);
|
|
@@ -214,4 +214,4 @@ const CardCompStyle = styled.div `
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
`;
|
|
217
|
-
export default
|
|
217
|
+
export default CardStyle;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, api } from '@weareconceptstudio/core';
|
|
3
|
+
import { useCheckoutContext } from '../../checkout';
|
|
4
|
+
//* Components
|
|
5
|
+
import AccountButton from '../../../components/AccountButton';
|
|
6
|
+
import PaymentMethods from '../PaymentMethods';
|
|
7
|
+
import SelectedPayment from '../SelectedPayment';
|
|
8
|
+
//* Style
|
|
9
|
+
import PaymentStyle from './style';
|
|
10
|
+
import { useAccountContext } from '../../../AccountProvider';
|
|
11
|
+
const Payment = ({ title, onClick, className }) => {
|
|
12
|
+
const { useUser } = useAccountContext();
|
|
13
|
+
const { checkoutData, fillCheckoutData } = useCheckoutContext();
|
|
14
|
+
const { user } = useUser();
|
|
15
|
+
const addNewCard = async () => {
|
|
16
|
+
return await api.post('add-card', { backUrl: `${window.location.href}`, isCheckout: true }).then((res) => {
|
|
17
|
+
if (res.redirect_url) {
|
|
18
|
+
window.location.href = res.redirect_url;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const setSelectedPayment = (value) => {
|
|
23
|
+
fillCheckoutData('paymentType', value);
|
|
24
|
+
if (value == 'card') {
|
|
25
|
+
addNewCard();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return (React.createElement(PaymentStyle, { className: `item-container ${className || ''}` },
|
|
29
|
+
React.createElement("div", { className: `change-payment-wrap` },
|
|
30
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1`, text: title }),
|
|
31
|
+
user.default_payment_method && (React.createElement(AccountButton, { text: `change`, btnType: `green-small-text`, onClick: onClick }))),
|
|
32
|
+
user.default_payment_method ? (React.createElement(SelectedPayment, null)) : (React.createElement(PaymentMethods, { selectedPayment: checkoutData.paymentType, setSelectedPayment: setSelectedPayment }))));
|
|
33
|
+
};
|
|
34
|
+
export default Payment;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default PaymentStyle;
|
|
2
|
+
declare const PaymentStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
const
|
|
2
|
+
const PaymentStyle = styled.div `
|
|
3
3
|
--account_checkoutMTop: var(--sp16x);
|
|
4
4
|
--account_changePaymentWrapMBot: var(--sp5x);
|
|
5
5
|
|
|
@@ -47,4 +47,4 @@ const PaymentCompStyle = styled.div `
|
|
|
47
47
|
--account_changePaymentWrapMBot: var(--sp2x);
|
|
48
48
|
}
|
|
49
49
|
`;
|
|
50
|
-
export default
|
|
50
|
+
export default PaymentStyle;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default PaymentMethodItem;
|
|
2
|
+
declare function PaymentMethodItem({ item, selectedPayment, setSelectedPayment, singlePayment, isCardType }: {
|
|
3
|
+
item: any;
|
|
4
|
+
selectedPayment: any;
|
|
5
|
+
setSelectedPayment: any;
|
|
6
|
+
singlePayment: any;
|
|
7
|
+
isCardType: any;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
import React from 'react';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from '@weareconceptstudio/core';
|
|
3
|
+
import { cardSVG, idramSVG, telcellSVG, cashSVG, posTerminalSVG, inecopaySVG, mastercardSVG, visaSVG } from '../icons';
|
|
4
|
+
import PaymentMethodItemStyle from './style';
|
|
5
|
+
const icons = {
|
|
6
|
+
card: cardSVG,
|
|
7
|
+
idram: idramSVG,
|
|
8
|
+
telcell: telcellSVG,
|
|
9
|
+
cash_on_delivery: cashSVG,
|
|
10
|
+
pos_terminal: posTerminalSVG,
|
|
11
|
+
inecopay: inecopaySVG,
|
|
12
|
+
'MasterCard': mastercardSVG,
|
|
13
|
+
'Visa': visaSVG,
|
|
14
|
+
};
|
|
15
|
+
const isNumeric = (value) => !isNaN(value) && !isNaN(parseFloat(value));
|
|
16
|
+
const PaymentMethodItem = ({ item, selectedPayment, setSelectedPayment, singlePayment, isCardType }) => {
|
|
17
|
+
return (React.createElement(PaymentMethodItemStyle, { "$singlePayment": singlePayment },
|
|
18
|
+
React.createElement("div", { className: 'payment-option-top' },
|
|
19
|
+
React.createElement("div", { className: 'payment-item-left' },
|
|
20
|
+
React.createElement("div", null, icons[item.value]),
|
|
21
|
+
React.createElement(Text, { className: 'payment-label account-p account-p3 account-font-regular account-primary-color1' }, item.label)),
|
|
22
|
+
React.createElement("div", { key: item.value, className: `circle-selected-wrap cursor-pointer ${selectedPayment === item.value || (item.value == 'card' && isNumeric(selectedPayment)) || singlePayment ? 'active' : ''}`, onClick: () => !singlePayment && setSelectedPayment(item.value) },
|
|
23
|
+
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedPayment === item.value || (item.value == 'card' && isNumeric(selectedPayment)) || singlePayment ? 'selected' : 'note-selected'}` },
|
|
24
|
+
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' })))),
|
|
25
|
+
isCardType && singlePayment && (React.createElement("div", { className: 'card-details' },
|
|
26
|
+
React.createElement("span", { className: 'card-number' }, item.card.short_number),
|
|
27
|
+
item.card.is_expired ? (React.createElement(Text, { tag: 'span', className: 'card-exp-date', text: 'cardExpired' })) : null))));
|
|
28
|
+
};
|
|
29
|
+
export default PaymentMethodItem;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default PaymentMethodItemStyle;
|
|
2
|
+
declare const PaymentMethodItemStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -1,62 +1,54 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
const
|
|
2
|
+
const PaymentMethodItemStyle = styled.div `
|
|
3
3
|
--account_itemBorderRadius: var(--sp1-5x);
|
|
4
4
|
--account_itemInternalPadTB: var(--sp2x);
|
|
5
5
|
--account_itemInternalPadLR: var(--sp4x);
|
|
6
|
-
--account_flexWrapperMTop: var(--sp2x);
|
|
7
6
|
--account_itemDistance: var(--sp5x);
|
|
8
7
|
--account_circleSize: var(--sp4x);
|
|
9
8
|
--account_checkSize: var(--sp2x);
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
width: ${(props) => (props.$singlePayment ? '100%' : 'calc(50% - var(--account_itemDistance) / 2)')};
|
|
11
|
+
border: 2px solid var(--account_primaryColor5);
|
|
12
|
+
border-radius: var(--account_itemBorderRadius);
|
|
13
|
+
padding: var(--account_itemInternalPadTB) var(--account_itemInternalPadLR);
|
|
14
|
+
padding-left: calc(var(--account_itemInternalPadLR) - 4px);
|
|
15
15
|
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
padding: var(--account_itemInternalPadTB) var(--account_itemInternalPadLR);
|
|
21
|
-
padding-left: calc(var(--account_itemInternalPadLR) - 4px);
|
|
16
|
+
.payment-option-top {
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
align-items: center;
|
|
22
20
|
|
|
23
|
-
.payment-
|
|
21
|
+
.payment-item-left {
|
|
24
22
|
display: flex;
|
|
25
|
-
justify-content:
|
|
23
|
+
justify-content: flex-start;
|
|
26
24
|
align-items: center;
|
|
27
|
-
|
|
28
|
-
.payment-item-left {
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: flex-start;
|
|
31
|
-
align-items: center;
|
|
32
|
-
gap: var(--sp1x);
|
|
33
|
-
}
|
|
25
|
+
gap: var(--sp1x);
|
|
34
26
|
}
|
|
27
|
+
}
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
.card-details {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: var(--sp1x);
|
|
33
|
+
margin-top: var(--sp1x);
|
|
34
|
+
color: var(--account_primaryColor1);
|
|
35
|
+
font-size: var(--account_p);
|
|
36
|
+
line-height: var(--account_lineHeight);
|
|
37
|
+
font-family: var(--account_Font);
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
|
|
40
|
+
.card-exp-date {
|
|
42
41
|
font-size: var(--account_p);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
.card-number .star {
|
|
55
|
-
display: inline-block;
|
|
56
|
-
align-self: center; /* Center the * vertically */
|
|
57
|
-
font-size: inherit; /* Match the font size of the card number */
|
|
58
|
-
line-height: inherit; /* Match the line height */
|
|
59
|
-
}
|
|
42
|
+
}
|
|
43
|
+
.card-number {
|
|
44
|
+
display: inline-flex; /* Align items inline and center vertically */
|
|
45
|
+
align-items: center;
|
|
46
|
+
}
|
|
47
|
+
.card-number .star {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
align-self: center; /* Center the * vertically */
|
|
50
|
+
font-size: inherit; /* Match the font size of the card number */
|
|
51
|
+
line-height: inherit; /* Match the line height */
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
54
|
|
|
@@ -93,7 +85,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
93
85
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
|
|
94
86
|
--account_itemInternalPadTB: var(--sp2x);
|
|
95
87
|
--account_itemInternalPadLR: var(--sp3x);
|
|
96
|
-
--account_flexWrapperMTop: var(--sp2x);
|
|
97
88
|
--account_itemDistance: var(--sp5x);
|
|
98
89
|
--account_circleSize: var(--sp3x);
|
|
99
90
|
--account_checkSize: var(--sp1-5x);
|
|
@@ -102,7 +93,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
102
93
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
|
|
103
94
|
--account_itemInternalPadTB: var(--sp1-5x);
|
|
104
95
|
--account_itemInternalPadLR: var(--sp3x);
|
|
105
|
-
--account_flexWrapperMTop: var(--sp1-5x);
|
|
106
96
|
--account_itemDistance: var(--sp4x);
|
|
107
97
|
--account_circleSize: var(--sp3x);
|
|
108
98
|
--account_checkSize: var(--sp1-5x);
|
|
@@ -111,7 +101,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
111
101
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
|
|
112
102
|
--account_itemInternalPadTB: var(--sp1-5x);
|
|
113
103
|
--account_itemInternalPadLR: var(--sp3x);
|
|
114
|
-
--account_flexWrapperMTop: var(--sp1-5x);
|
|
115
104
|
--account_itemDistance: var(--sp3x);
|
|
116
105
|
--account_circleSize: var(--sp3x);
|
|
117
106
|
--account_checkSize: var(--sp1-5x);
|
|
@@ -120,7 +109,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
120
109
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
|
|
121
110
|
--account_itemInternalPadTB: var(--sp1-5x);
|
|
122
111
|
--account_itemInternalPadLR: var(--sp2x);
|
|
123
|
-
--account_flexWrapperMTop: var(--sp1-5x);
|
|
124
112
|
--account_itemDistance: var(--sp2x);
|
|
125
113
|
--account_circleSize: var(--sp2-5x);
|
|
126
114
|
--account_checkSize: var(--sp1x);
|
|
@@ -129,7 +117,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
129
117
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
|
|
130
118
|
--account_itemInternalPadTB: var(--sp1-5x);
|
|
131
119
|
--account_itemInternalPadLR: var(--sp2x);
|
|
132
|
-
--account_flexWrapperMTop: var(--sp1-5x);
|
|
133
120
|
--account_itemDistance: var(--sp3x);
|
|
134
121
|
--account_circleSize: var(--sp2-5x);
|
|
135
122
|
--account_checkSize: var(--sp1x);
|
|
@@ -139,8 +126,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
139
126
|
--account_itemInternalPadTB: var(--sp1-5x);
|
|
140
127
|
--account_itemInternalPadLR: var(--sp1-5x);
|
|
141
128
|
--account_itemBorderRadius: var(--sp1x);
|
|
142
|
-
--account_flexWrapperMTop: var(--sp1-5x);
|
|
143
|
-
--account_flexWrapperMTop: var(--sp2x);
|
|
144
129
|
--account_itemDistance: var(--sp2x);
|
|
145
130
|
--account_circleSize: var(--sp2-5x);
|
|
146
131
|
--account_checkSize: var(--sp1x);
|
|
@@ -149,7 +134,6 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
149
134
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
|
|
150
135
|
--account_itemInternalPadTB: var(--sp1-5x);
|
|
151
136
|
--account_itemInternalPadLR: var(--sp1-5x);
|
|
152
|
-
--account_flexWrapperMTop: var(--sp1-5x);
|
|
153
137
|
--account_itemDistance: var(--sp1x);
|
|
154
138
|
--account_circleSize: var(--sp2-5x);
|
|
155
139
|
--account_checkSize: var(--sp1x);
|
|
@@ -159,4 +143,4 @@ const PaymentMethodsCompStyle = styled.div `
|
|
|
159
143
|
}
|
|
160
144
|
}
|
|
161
145
|
`;
|
|
162
|
-
export default
|
|
146
|
+
export default PaymentMethodItemStyle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useAccountContext } from '../../../AccountProvider';
|
|
3
|
+
//* Components
|
|
4
|
+
import PaymentMethodItem from '../PaymentMethodItem';
|
|
5
|
+
//* Style
|
|
6
|
+
import PaymentMethodsStyle from './style';
|
|
7
|
+
const PaymentMethods = ({ className, selectedPayment, setSelectedPayment }) => {
|
|
8
|
+
const { paymentOptions, useUser } = useAccountContext();
|
|
9
|
+
const { user } = useUser();
|
|
10
|
+
const paymentMethods = useMemo(() => {
|
|
11
|
+
return !!user.default_payment_method ? paymentOptions : [{ label: 'Card', value: 'card' }, ...paymentOptions];
|
|
12
|
+
}, [user, paymentOptions]);
|
|
13
|
+
return (React.createElement(PaymentMethodsStyle, { className: `payment-item-container ${className || ''}` }, paymentMethods.map((item, index) => (React.createElement(PaymentMethodItem, { key: index, item: item, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment })))));
|
|
14
|
+
};
|
|
15
|
+
export default PaymentMethods;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default PaymentMethodsStyle;
|
|
2
|
+
declare const PaymentMethodsStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const PaymentMethodsStyle = styled.div `
|
|
3
|
+
--account_flexWrapperMTop: var(--sp2x);
|
|
4
|
+
--account_itemDistance: var(--sp5x);
|
|
5
|
+
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
row-gap: var(--account_flexWrapperMTop);
|
|
9
|
+
column-gap: var(--account_itemDistance);
|
|
10
|
+
|
|
11
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
|
|
12
|
+
--account_flexWrapperMTop: var(--sp2x);
|
|
13
|
+
--account_itemDistance: var(--sp5x);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
|
|
17
|
+
--account_flexWrapperMTop: var(--sp1-5x);
|
|
18
|
+
--account_itemDistance: var(--sp4x);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
|
|
22
|
+
--account_flexWrapperMTop: var(--sp1-5x);
|
|
23
|
+
--account_itemDistance: var(--sp3x);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
|
|
27
|
+
--account_flexWrapperMTop: var(--sp1-5x);
|
|
28
|
+
--account_itemDistance: var(--sp2x);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
|
|
32
|
+
--account_flexWrapperMTop: var(--sp1-5x);
|
|
33
|
+
--account_itemDistance: var(--sp3x);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeS}) {
|
|
37
|
+
--account_flexWrapperMTop: var(--sp2x);
|
|
38
|
+
--account_itemDistance: var(--sp2x);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
|
|
42
|
+
--account_flexWrapperMTop: var(--sp1-5x);
|
|
43
|
+
--account_itemDistance: var(--sp1x);
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
export default PaymentMethodsStyle;
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { api, Text } from '@weareconceptstudio/core';
|
|
2
|
+
import React, { useState, useCallback } from 'react';
|
|
3
|
+
import { api, Text, useUi } from '@weareconceptstudio/core';
|
|
4
4
|
import { useAccountContext } from '../../../AccountProvider';
|
|
5
5
|
import { useCheckoutContext } from '../../checkout';
|
|
6
6
|
//* Components
|
|
7
|
-
import { AccountButton } from '../../../components';
|
|
7
|
+
import { AccountButton, WarningMessageForPopup } from '../../../components';
|
|
8
8
|
import PaymentWrap from '../PaymentWrap';
|
|
9
9
|
//* Style
|
|
10
10
|
import PaymentStyle from './style';
|
|
11
11
|
const PaymentMethodsTemplate = () => {
|
|
12
|
+
const { openPopup } = useUi();
|
|
12
13
|
const { useUser } = useAccountContext();
|
|
13
14
|
const { user } = useUser();
|
|
14
15
|
const { fillCheckoutData } = useCheckoutContext();
|
|
15
16
|
const [selectedPayment, setSelectedPayment] = useState(user.default_payment_method);
|
|
17
|
+
//! Handle Popup
|
|
18
|
+
const handleSuccessPopup = useCallback(() => {
|
|
19
|
+
openPopup(React.createElement(WarningMessageForPopup, { title: 'yourSettingsHaveBeenSaved', description: 'yourSettingsHaveBeenSaved' }), {
|
|
20
|
+
className: 'messagePopup',
|
|
21
|
+
accountIcon: true,
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
16
24
|
const handlePaymentMethodChangeSubmit = async () => {
|
|
17
25
|
await api.post('update-payment-method', { payment_method: selectedPayment }).then(() => {
|
|
18
26
|
fillCheckoutData('paymentType', selectedPayment);
|
|
27
|
+
handleSuccessPopup();
|
|
19
28
|
});
|
|
20
29
|
};
|
|
21
30
|
return (React.createElement(PaymentStyle, null,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default PaymentWrap;
|
|
2
|
-
declare function PaymentWrap({ selectedPayment, setSelectedPayment }: {
|
|
2
|
+
declare function PaymentWrap({ selectedPayment, setSelectedPayment, isCheckout }: {
|
|
3
3
|
selectedPayment: any;
|
|
4
4
|
setSelectedPayment: any;
|
|
5
|
+
isCheckout?: boolean;
|
|
5
6
|
}): React.JSX.Element;
|
|
6
7
|
import React from 'react';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import { api } from '@weareconceptstudio/core';
|
|
2
3
|
//* Components
|
|
3
|
-
import PaymentMethodsComp from '../PaymentMethodsComp';
|
|
4
4
|
import AddNewCard from '../AddNewCard';
|
|
5
|
-
import
|
|
5
|
+
import Card from '../Card';
|
|
6
|
+
import PaymentMethods from '../PaymentMethods';
|
|
6
7
|
//* Style
|
|
7
8
|
import PaymentWrapStyle from './style';
|
|
8
9
|
import { useAccountContext } from '../../../AccountProvider';
|
|
9
|
-
|
|
10
|
-
const PaymentWrap = ({ selectedPayment, setSelectedPayment }) => {
|
|
10
|
+
const PaymentWrap = ({ selectedPayment, setSelectedPayment, isCheckout = false }) => {
|
|
11
11
|
const { useUser } = useAccountContext();
|
|
12
12
|
const { user } = useUser();
|
|
13
13
|
const [cards, setCards] = useState(user.cards);
|
|
@@ -18,9 +18,9 @@ const PaymentWrap = ({ selectedPayment, setSelectedPayment }) => {
|
|
|
18
18
|
};
|
|
19
19
|
return (React.createElement(PaymentWrapStyle, null,
|
|
20
20
|
React.createElement("div", { className: `flex-wrapper` },
|
|
21
|
-
React.createElement(AddNewCard,
|
|
22
|
-
cards?.map((card, index) => (React.createElement(
|
|
21
|
+
React.createElement(AddNewCard, { isCheckout: isCheckout }),
|
|
22
|
+
cards?.map((card, index) => (React.createElement(Card, { key: index, cardOption: card, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment, deleteCard: deleteCard, isCheckout: isCheckout })))),
|
|
23
23
|
React.createElement("div", { className: 'line' }),
|
|
24
|
-
React.createElement(
|
|
24
|
+
React.createElement(PaymentMethods, { selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment })));
|
|
25
25
|
};
|
|
26
26
|
export default PaymentWrap;
|