@weareconceptstudio/account 0.3.4 → 0.3.5

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 (35) hide show
  1. package/dist/AccountProvider.js +23 -1
  2. package/dist/components/TotalCheckout/index.js +6 -6
  3. package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +2 -2
  4. package/dist/modules/payment/AddNewCard/index.d.ts +2 -1
  5. package/dist/modules/payment/AddNewCard/index.js +3 -3
  6. package/dist/modules/payment/{CardComp → Card}/index.d.ts +2 -2
  7. package/dist/modules/payment/{CardComp → Card}/index.js +6 -6
  8. package/dist/modules/payment/Card/style.d.ts +2 -0
  9. package/dist/modules/payment/{CardComp → Card}/style.js +2 -2
  10. package/dist/modules/payment/{PaymentComp → Payment}/index.d.ts +2 -2
  11. package/dist/modules/payment/{PaymentComp → Payment}/index.js +7 -6
  12. package/dist/modules/payment/Payment/style.d.ts +2 -0
  13. package/dist/modules/payment/{PaymentComp → Payment}/style.js +2 -2
  14. package/dist/modules/payment/PaymentMethodItem/index.d.ts +9 -0
  15. package/dist/modules/payment/PaymentMethodItem/index.js +31 -0
  16. package/dist/modules/payment/PaymentMethodItem/style.d.ts +2 -0
  17. package/dist/modules/payment/{PaymentMethodsComp → PaymentMethodItem}/style.js +37 -53
  18. package/dist/modules/payment/PaymentMethods/index.d.ts +7 -0
  19. package/dist/modules/payment/PaymentMethods/index.js +11 -0
  20. package/dist/modules/payment/PaymentMethods/style.d.ts +2 -0
  21. package/dist/modules/payment/PaymentMethods/style.js +46 -0
  22. package/dist/modules/payment/PaymentMethodsTemplate/index.js +12 -3
  23. package/dist/modules/payment/PaymentWrap/index.d.ts +2 -1
  24. package/dist/modules/payment/PaymentWrap/index.js +7 -7
  25. package/dist/modules/payment/SelectPaymentMethodPopup/index.js +1 -1
  26. package/dist/modules/payment/SelectedPayment/index.d.ts +3 -0
  27. package/dist/modules/payment/SelectedPayment/index.js +45 -0
  28. package/package.json +1 -1
  29. package/dist/modules/payment/CardComp/style.d.ts +0 -2
  30. package/dist/modules/payment/PaymentComp/style.d.ts +0 -2
  31. package/dist/modules/payment/PaymentMethodsComp/index.d.ts +0 -8
  32. package/dist/modules/payment/PaymentMethodsComp/index.js +0 -86
  33. package/dist/modules/payment/PaymentMethodsComp/style.d.ts +0 -2
  34. /package/dist/modules/payment/{PaymentMethodsComp/icons.d.ts → icons.d.ts} +0 -0
  35. /package/dist/modules/payment/{PaymentMethodsComp/icons.js → icons.js} +0 -0
@@ -18,6 +18,28 @@ export const useAccountContext = () => {
18
18
  export const AccountProvider = ({ fontFamily = 'core_Font', shopUrl = '/', children, maxQty = 99, currency, addressType, addressFormFields, useUser, useCart, productPopup, productUrlPrefix }) => {
19
19
  const { addTranslation } = useTranslation();
20
20
  const { openPopup } = useUi();
21
+ const paymentOptions = [
22
+ {
23
+ label: 'Cash',
24
+ value: 'cash_on_delivery',
25
+ },
26
+ {
27
+ label: 'Idram',
28
+ value: 'idram',
29
+ },
30
+ {
31
+ label: 'POS TERMINAL',
32
+ value: 'pos_terminal',
33
+ },
34
+ {
35
+ label: 'Telcell',
36
+ value: 'telcell',
37
+ },
38
+ {
39
+ label: 'Inecopay',
40
+ value: 'inecopay',
41
+ },
42
+ ];
21
43
  useEffect(() => {
22
44
  addTranslation(translations, 'prepend');
23
45
  }, []);
@@ -29,7 +51,7 @@ export const AccountProvider = ({ fontFamily = 'core_Font', shopUrl = '/', child
29
51
  openPopup(productPopup, { ...product, className: 'popup-product-block' });
30
52
  }
31
53
  }, [productUrlPrefix, productPopup]);
32
- return (React.createElement(AccountContext.Provider, { value: { currency, maxQty, shopUrl, useUser, useCart, handleProductClick } },
54
+ return (React.createElement(AccountContext.Provider, { value: { currency, maxQty, shopUrl, useUser, useCart, handleProductClick, paymentOptions } },
33
55
  React.createElement(CheckoutProvider, null,
34
56
  React.createElement(AddressProvider, { useUser: useUser, useCart: useCart, addressType: addressType, addressFormFields: addressFormFields },
35
57
  React.createElement(ThemeProvider, { theme: theme },
@@ -30,11 +30,11 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
30
30
  event.preventDefault();
31
31
  }
32
32
  };
33
- if ((!itemsCount || !user.balance) && innerCollapseRef.current) {
33
+ if ((!itemsCount || !user?.balance) && innerCollapseRef.current) {
34
34
  let inputField = innerCollapseRef.current.querySelectorAll('.base-input');
35
35
  if (inputField.length) {
36
36
  [...inputField].forEach((item, i) => {
37
- if (!user.balance && itemsCount && i == 1) {
37
+ if (!user?.balance && itemsCount && i == 1) {
38
38
  return;
39
39
  }
40
40
  else {
@@ -44,7 +44,7 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
44
44
  }
45
45
  }
46
46
  return () => {
47
- if ((!itemsCount || !user.balance) && innerCollapseRef.current) {
47
+ if ((!itemsCount || !user?.balance) && innerCollapseRef.current) {
48
48
  const inputField = innerCollapseRef.current.querySelectorAll('.base-input');
49
49
  [...inputField].map((item) => {
50
50
  item.removeEventListener('keydown', handleKeyDown);
@@ -71,10 +71,10 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
71
71
  React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-total`, text: `total` }),
72
72
  React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-currency2`, text: itemsCount ? handlePriceCheckFunc(total, currency) : `0 ${currency}` })),
73
73
  !isCheckout ? (React.createElement(FreeShippingComp, { currency: currency, shippingCost: shippingCost, shippingCostValue: shippingCostValue, freeShippingRange: freeShippingRange })) : null,
74
- user ? (React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
74
+ React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
75
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,
76
+ React.createElement(MuramoneyComp, { getItemCount: itemsCount, balance: user?.balance || 0, currency: currency, balanceHandler: handleBalance, useBalance: useBalance }),
77
+ React.createElement(PromoCodeComp, { getItemCount: itemsCount, promo_code: promo_code }))),
78
78
  isCheckout && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, { fillCheckoutData: fillCheckoutData }) : null,
79
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))))));
80
80
  });
@@ -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 PaymentComp from '../../../payment/PaymentComp';
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(PaymentComp, { title: 'payment', onClick: handleSelectPopup }),
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,6 @@
1
1
  export default AddNewCard;
2
- declare function AddNewCard({ className }: {
2
+ declare function AddNewCard({ className, isCheckout }: {
3
3
  className: any;
4
+ isCheckout: any;
4
5
  }): React.JSX.Element;
5
6
  import React from 'react';
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { Text, api } from '@weareconceptstudio/core';
3
- import { popupCardSVG } from '../PaymentMethodsComp/icons';
3
+ import { popupCardSVG } from '../icons';
4
4
  //* Style
5
5
  import AddNewCardStyle from './style';
6
- const AddNewCard = ({ className }) => {
6
+ const AddNewCard = ({ className, isCheckout }) => {
7
7
  const addNew = async () => {
8
- return await api.post('add-card').then((res) => {
8
+ return await api.post('add-card', { backUrl: `${window.location.href}${isCheckout ? '?c=paymentMethods' : ''}` }).then((res) => {
9
9
  if (res.redirect_url) {
10
10
  window.location.href = res.redirect_url;
11
11
  }
@@ -1,5 +1,5 @@
1
- export default CardComp;
2
- declare function CardComp({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard }: {
1
+ export default Card;
2
+ declare function Card({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard }: {
3
3
  cardOption: any;
4
4
  className: any;
5
5
  selectedPayment: any;
@@ -1,12 +1,12 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { Text, useUi } from '@weareconceptstudio/core';
3
- import { mastercardSVG, visaSVG } from '../PaymentMethodsComp/icons';
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 CardCompStyle from './style';
9
- const CardComp = ({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard }) => {
8
+ import CardStyle from './style';
9
+ const Card = ({ cardOption, className, selectedPayment, setSelectedPayment, deleteCard }) => {
10
10
  const { openPopup } = useUi();
11
11
  const formatCardNumber = (number) => {
12
12
  if (!number)
@@ -20,11 +20,11 @@ const CardComp = ({ cardOption, className, selectedPayment, setSelectedPayment,
20
20
  accountIcon: true,
21
21
  });
22
22
  }, [cardOption.id, deleteCard]);
23
- return (React.createElement(CardCompStyle, { className: `card-container ${cardOption.is_expired ? 'expired' : ''} ${className || ''}` },
23
+ return (React.createElement(CardStyle, { className: `card-container ${cardOption.is_expired ? 'expired' : ''} ${className || ''}` },
24
24
  React.createElement("div", { className: `card-wrap-top` },
25
25
  React.createElement("div", { className: 'card-svg' }, cardOption && cardOption.brand === 'MasterCard' ? React.createElement("div", null, mastercardSVG) : React.createElement("div", null, visaSVG)),
26
26
  !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.number ? 'selected' : 'note-selected'}` },
27
+ 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
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),
29
29
  React.createElement("div", { className: `card-wrap-center` },
30
30
  React.createElement(Text, { className: `card-full-name account-p account-p3 account-font-regular`, text: cardOption.name }),
@@ -33,4 +33,4 @@ const CardComp = ({ cardOption, className, selectedPayment, setSelectedPayment,
33
33
  React.createElement(Text, { className: `account-p account-p3 account-font-regular`, text: cardOption.is_expired ? 'cardExpired' : `Exp. Date ${cardOption.exp_date}` }),
34
34
  React.createElement(AccountButton, { text: `remove`, onClick: handleDeletePopup, btnType: `green-small-text`, className: `account-card-remove-btn account-p account-p3 account-font-regular` }))));
35
35
  };
36
- export default CardComp;
36
+ export default Card;
@@ -0,0 +1,2 @@
1
+ export default CardStyle;
2
+ declare const CardStyle: 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 CardCompStyle = styled.div `
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 CardCompStyle;
217
+ export default CardStyle;
@@ -1,5 +1,5 @@
1
- export default PaymentComp;
2
- declare function PaymentComp({ title, onClick, className }: {
1
+ export default Payment;
2
+ declare function Payment({ title, onClick, className }: {
3
3
  title: any;
4
4
  onClick: any;
5
5
  className: any;
@@ -3,15 +3,16 @@ import { Text } from '@weareconceptstudio/core';
3
3
  import { useCheckoutContext } from '../../checkout';
4
4
  //* Components
5
5
  import AccountButton from '../../../components/AccountButton';
6
- import PaymentMethodsComp from '../PaymentMethodsComp';
6
+ import PaymentMethods from '../PaymentMethods';
7
+ import SelectedPayment from '../SelectedPayment';
7
8
  //* Style
8
- import PaymentCompStyle from './style';
9
- const PaymentComp = ({ title, onClick, className }) => {
9
+ import PaymentStyle from './style';
10
+ const Payment = ({ title, onClick, className }) => {
10
11
  const { checkoutData, fillCheckoutData } = useCheckoutContext();
11
- return (React.createElement(PaymentCompStyle, { className: `item-container ${className || ''}` },
12
+ return (React.createElement(PaymentStyle, { className: `item-container ${className || ''}` },
12
13
  React.createElement("div", { className: `change-payment-wrap` },
13
14
  React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1`, text: title }),
14
15
  checkoutData.paymentType && (React.createElement(AccountButton, { text: `change`, btnType: `green-small-text`, onClick: onClick }))),
15
- React.createElement(PaymentMethodsComp, { showAll: false, selectedPayment: checkoutData.paymentType, setSelectedPayment: (value) => fillCheckoutData('paymentType', value) })));
16
+ checkoutData.paymentType ? (React.createElement(SelectedPayment, null)) : (React.createElement(PaymentMethods, { selectedPayment: checkoutData.paymentType, setSelectedPayment: (value) => fillCheckoutData('paymentType', value) }))));
16
17
  };
17
- export default PaymentComp;
18
+ 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 PaymentCompStyle = styled.div `
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 PaymentCompStyle;
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,31 @@
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.number),
27
+ React.createElement("span", { className: 'card-exp-date' },
28
+ "Exp. Date ",
29
+ item.card.exp_date)))));
30
+ };
31
+ 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 PaymentMethodsCompStyle = styled.div `
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
- display: flex;
12
- flex-wrap: wrap;
13
- row-gap: var(--account_flexWrapperMTop);
14
- column-gap: var(--account_itemDistance);
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
- .custom-payment-options {
17
- width: ${(props) => (props.$singlePayment ? '100%' : 'calc(50% - var(--account_itemDistance) / 2)')};
18
- border: 2px solid var(--account_primaryColor5);
19
- border-radius: var(--account_itemBorderRadius);
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-option-top {
21
+ .payment-item-left {
24
22
  display: flex;
25
- justify-content: space-between;
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
- .card-details {
37
- display: flex;
38
- flex-direction: column;
39
- gap: var(--sp1x);
40
- margin-top: var(--sp1x);
41
- color: var(--account_primaryColor1);
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
- line-height: var(--account_lineHeight);
44
- font-family: var(--account_Font);
45
- font-weight: 400;
46
-
47
- .card-exp-date {
48
- font-size: var(--account_p);
49
- }
50
- .card-number {
51
- display: inline-flex; /* Align items inline and center vertically */
52
- align-items: center;
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 PaymentMethodsCompStyle;
146
+ export default PaymentMethodItemStyle;
@@ -0,0 +1,7 @@
1
+ export default PaymentMethods;
2
+ declare function PaymentMethods({ className, selectedPayment, setSelectedPayment }: {
3
+ className: any;
4
+ selectedPayment: any;
5
+ setSelectedPayment: any;
6
+ }): React.JSX.Element;
7
+ import React from 'react';
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ //* Components
3
+ import PaymentMethodItem from '../PaymentMethodItem';
4
+ //* Style
5
+ import PaymentMethodsStyle from './style';
6
+ import { useAccountContext } from '../../../AccountProvider';
7
+ const PaymentMethods = ({ className, selectedPayment, setSelectedPayment }) => {
8
+ const { paymentOptions } = useAccountContext();
9
+ return (React.createElement(PaymentMethodsStyle, { className: `payment-item-container ${className || ''}` }, paymentOptions.map((item, index) => (React.createElement(PaymentMethodItem, { item: item, index: index, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment })))));
10
+ };
11
+ 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 CardComp from '../CardComp';
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
- import { api } from '@weareconceptstudio/core';
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, null),
22
- cards?.map((card, index) => (React.createElement(CardComp, { key: index, cardOption: card, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment, deleteCard: deleteCard })))),
21
+ React.createElement(AddNewCard, { isCheckout: isCheckout }),
22
+ cards?.map((card, index) => (React.createElement(Card, { key: index, cardOption: card, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment, deleteCard: deleteCard })))),
23
23
  React.createElement("div", { className: 'line' }),
24
- React.createElement(PaymentMethodsComp, { showAll: true, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment })));
24
+ React.createElement(PaymentMethods, { selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment })));
25
25
  };
26
26
  export default PaymentWrap;
@@ -17,7 +17,7 @@ const SelectPaymentMethodPopup = () => {
17
17
  return (React.createElement(SelectPaymentMethodPopupStyle, null,
18
18
  React.createElement("div", { className: `select-payment-wrap` },
19
19
  React.createElement(Text, { tag: `h6`, className: 'account-p account-p2 account-font-bold account-primary-color1', text: 'selectPaymentMethod' })),
20
- React.createElement(PaymentWrap, { selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment }),
20
+ React.createElement(PaymentWrap, { selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment, isCheckout: true }),
21
21
  React.createElement("div", { className: `cancel-and-save-wrap` },
22
22
  React.createElement(AccountButton, { btnType: `green-large-text`, text: `cancel`, onClick: closePopup }),
23
23
  React.createElement(AccountButton, { btnType: `full-width`, text: `saveAndApply`, onClick: handlePaymentMethodChangeSubmit }))));
@@ -0,0 +1,3 @@
1
+ export default SelectedPayment;
2
+ declare function SelectedPayment(): React.JSX.Element;
3
+ import React from 'react';
@@ -0,0 +1,45 @@
1
+ import React, { useMemo } from 'react';
2
+ import PaymentMethodItem from '../PaymentMethodItem';
3
+ import { useAccountContext } from '../../../AccountProvider';
4
+ import { useCheckoutContext } from '../../checkout';
5
+ const isNumeric = (value) => !isNaN(value) && !isNaN(parseFloat(value));
6
+ // if (cardDetails && !showAll) {
7
+ // filteredOptions = filteredOptions.map((option) =>
8
+ // option.value === 'credit_card'
9
+ // ? {
10
+ // ...option,
11
+ // label: <span className='card-type'>{cardDetails.card_type}</span>,
12
+ // }
13
+ // : option
14
+ // );
15
+ // }
16
+ // const cardDetails = isNumeric(checkoutData.paymentType)
17
+ // ? {
18
+ // card_type: 'MasterCard', // Or 'Visa', based on your logic
19
+ // number: '**** **** **** 1234',
20
+ // expDate: '12/24',
21
+ // }
22
+ // : null;
23
+ const SelectedPayment = () => {
24
+ const { paymentOptions, useUser } = useAccountContext();
25
+ const { checkoutData } = useCheckoutContext();
26
+ const { user } = useUser();
27
+ const isCardType = useMemo(() => {
28
+ return isNumeric(checkoutData.paymentType);
29
+ }, [checkoutData.paymentType]);
30
+ const selectedItem = useMemo(() => {
31
+ if (isCardType) {
32
+ const selectedCard = user.cards.find((item) => item.id == checkoutData.paymentType);
33
+ return {
34
+ label: selectedCard.name,
35
+ value: selectedCard.brand,
36
+ card: selectedCard,
37
+ };
38
+ }
39
+ else {
40
+ return paymentOptions.find((item) => item.value == checkoutData.paymentType);
41
+ }
42
+ }, [isCardType, checkoutData.paymentType]);
43
+ return (React.createElement(PaymentMethodItem, { singlePayment: true, isCardType: isCardType, item: selectedItem }));
44
+ };
45
+ export default SelectedPayment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/account",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Concept Studio Account",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",
@@ -1,2 +0,0 @@
1
- export default CardCompStyle;
2
- declare const CardCompStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -1,2 +0,0 @@
1
- export default PaymentCompStyle;
2
- declare const PaymentCompStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -1,8 +0,0 @@
1
- export default PaymentMethodsComp;
2
- declare function PaymentMethodsComp({ className, showAll, selectedPayment, setSelectedPayment }: {
3
- className: any;
4
- showAll: any;
5
- selectedPayment: any;
6
- setSelectedPayment: any;
7
- }): React.JSX.Element;
8
- import React from 'react';
@@ -1,86 +0,0 @@
1
- import React from 'react';
2
- import { Text } from '@weareconceptstudio/core';
3
- import { cardSVG, idramSVG, telcellSVG, cashSVG, posTerminalSVG, inecopaySVG } from './icons';
4
- import { useCheckoutContext } from '../../checkout';
5
- //* Style
6
- import PaymentMethodsCompStyle from './style';
7
- const isNumeric = (value) => !isNaN(value) && !isNaN(parseFloat(value));
8
- const PaymentMethodsComp = ({ className, showAll, selectedPayment, setSelectedPayment }) => {
9
- let paymentOptions = [
10
- {
11
- label: 'Cash',
12
- value: 'cash_on_delivery',
13
- svg: cashSVG,
14
- },
15
- {
16
- label: 'Idram',
17
- value: 'idram',
18
- svg: idramSVG,
19
- },
20
- {
21
- label: 'POS TERMINAL',
22
- value: 'pos_terminal',
23
- svg: posTerminalSVG,
24
- },
25
- {
26
- label: 'Telcell',
27
- value: 'telcell',
28
- svg: telcellSVG,
29
- },
30
- {
31
- label: 'Inecopay',
32
- value: 'inecopay',
33
- svg: inecopaySVG,
34
- },
35
- ];
36
- if (!showAll) {
37
- paymentOptions = [
38
- {
39
- label: 'Card',
40
- value: 'credit_card',
41
- svg: cardSVG,
42
- },
43
- ...paymentOptions,
44
- ];
45
- }
46
- const { checkoutData } = useCheckoutContext();
47
- const cardDetails = isNumeric(checkoutData.paymentType)
48
- ? {
49
- card_type: 'MasterCard', // Or 'Visa', based on your logic
50
- number: '**** **** **** 1234',
51
- expDate: '12/24',
52
- }
53
- : null;
54
- let filteredOptions;
55
- if (showAll) {
56
- filteredOptions = paymentOptions;
57
- }
58
- else if (checkoutData.paymentType) {
59
- filteredOptions = paymentOptions.filter((option) => option.value === (isNumeric(checkoutData.paymentType) ? 'credit_card' : checkoutData.paymentType));
60
- }
61
- else {
62
- filteredOptions = paymentOptions;
63
- }
64
- if (cardDetails && !showAll) {
65
- filteredOptions = filteredOptions.map((option) => option.value === 'credit_card'
66
- ? {
67
- ...option,
68
- label: React.createElement("span", { className: 'card-type' }, cardDetails.card_type),
69
- }
70
- : option);
71
- }
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 },
73
- React.createElement("div", { className: 'payment-option-top' },
74
- React.createElement("div", { className: 'payment-item-left' },
75
- React.createElement("div", null, option.svg),
76
- React.createElement(Text, { className: 'payment-label account-p account-p3 account-font-regular account-primary-color1' }, option.label)),
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) },
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'}` },
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' })))),
80
- option.value === 'credit_card' && cardDetails && !showAll && (React.createElement("div", { className: 'card-details' },
81
- React.createElement("span", { className: 'card-number' }, cardDetails.number),
82
- React.createElement("span", { className: 'card-exp-date' },
83
- "Exp. Date ",
84
- cardDetails.expDate))))))));
85
- };
86
- export default PaymentMethodsComp;
@@ -1,2 +0,0 @@
1
- export default PaymentMethodsCompStyle;
2
- declare const PaymentMethodsCompStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;