@weareconceptstudio/account 0.3.1 → 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.
Files changed (78) hide show
  1. package/dist/AccountProvider.js +8 -6
  2. package/dist/components/Loader/index.d.ts +2 -0
  3. package/dist/components/Loader/index.js +7 -0
  4. package/dist/components/Loader/style.d.ts +2 -0
  5. package/dist/components/Loader/style.js +3 -0
  6. package/dist/components/TotalCheckout/CommentComp/index.js +1 -1
  7. package/dist/components/TotalCheckout/MuramoneyComp/index.d.ts +2 -1
  8. package/dist/components/TotalCheckout/MuramoneyComp/index.js +7 -4
  9. package/dist/components/TotalCheckout/MuramoneyComp/utils.d.ts +1 -0
  10. package/dist/components/TotalCheckout/MuramoneyComp/utils.js +1 -0
  11. package/dist/components/TotalCheckout/PromoCodeComp/index.d.ts +2 -1
  12. package/dist/components/TotalCheckout/PromoCodeComp/index.js +4 -3
  13. package/dist/components/TotalCheckout/index.js +44 -16
  14. package/dist/components/TotalCheckout/style.js +50 -0
  15. package/dist/modules/account/AccountBalanceTemplate/HistoryBalance/ItemHistory/index.js +6 -1
  16. package/dist/modules/address/AddressForm/style.js +5 -0
  17. package/dist/modules/address/AddressItem/index.js +4 -8
  18. package/dist/modules/address/AddressItem/style.js +10 -0
  19. package/dist/modules/address/AddressProvider.d.ts +1 -2
  20. package/dist/modules/address/AddressProvider.js +7 -7
  21. package/dist/modules/address/SelectAddress/index.js +2 -3
  22. package/dist/modules/address/SelectAddressPopup/index.js +3 -19
  23. package/dist/modules/address/ShippingBillingForm/style.js +5 -0
  24. package/dist/modules/address/ShippingBillingInfo/index.js +1 -4
  25. package/dist/modules/cart/CartTemplate/index.d.ts +2 -1
  26. package/dist/modules/cart/CartTemplate/index.js +3 -2
  27. package/dist/modules/cart/EmptyCart/icons.js +1 -1
  28. package/dist/modules/checkout/CheckoutProvider.d.ts +5 -0
  29. package/dist/modules/checkout/CheckoutProvider.js +66 -0
  30. package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +7 -19
  31. package/dist/modules/checkout/CheckoutTemplate/index.js +6 -26
  32. package/dist/modules/checkout/ThankYouTemplate/icons.js +1 -1
  33. package/dist/modules/checkout/index.d.ts +1 -0
  34. package/dist/modules/checkout/index.js +1 -0
  35. package/dist/modules/order/OrderDetails/index.js +7 -2
  36. package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/index.d.ts +1 -2
  37. package/dist/modules/payment/AddNewCard/index.js +19 -0
  38. package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/style.js +13 -6
  39. package/dist/{components/TotalCheckout → modules/payment}/CardComp/index.d.ts +3 -3
  40. package/dist/modules/payment/CardComp/index.js +36 -0
  41. package/dist/{components/TotalCheckout → modules/payment}/CardComp/style.js +28 -14
  42. package/dist/modules/payment/PaymentComp/index.d.ts +7 -0
  43. package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/index.js +6 -3
  44. package/dist/modules/payment/PaymentMethodsComp/icons.d.ts +10 -0
  45. package/dist/modules/payment/PaymentMethodsComp/icons.js +56 -0
  46. package/dist/modules/payment/PaymentMethodsComp/index.d.ts +8 -0
  47. package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/index.js +29 -25
  48. package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/style.js +7 -7
  49. package/dist/modules/payment/PaymentMethodsTemplate/index.d.ts +1 -1
  50. package/dist/modules/payment/PaymentMethodsTemplate/index.js +21 -34
  51. package/dist/modules/payment/PaymentMethodsTemplate/style.js +43 -11
  52. package/dist/modules/payment/PaymentWrap/index.d.ts +6 -0
  53. package/dist/modules/payment/PaymentWrap/index.js +26 -0
  54. package/dist/modules/payment/PaymentWrap/style.d.ts +2 -0
  55. package/dist/{components/TotalCheckout/SelectPaymentMethodPopup → modules/payment/PaymentWrap}/style.js +29 -79
  56. package/dist/modules/payment/SelectPaymentMethodPopup/index.d.ts +3 -0
  57. package/dist/modules/payment/SelectPaymentMethodPopup/index.js +25 -0
  58. package/dist/modules/payment/SelectPaymentMethodPopup/style.js +81 -0
  59. package/dist/translations/en.d.ts +3 -0
  60. package/dist/translations/en.js +4 -0
  61. package/dist/translations/hy.d.ts +3 -0
  62. package/dist/translations/hy.js +4 -0
  63. package/dist/translations/index.d.ts +9 -0
  64. package/dist/translations/ru.d.ts +3 -0
  65. package/dist/translations/ru.js +4 -0
  66. package/package.json +1 -1
  67. package/dist/components/TotalCheckout/AddNewCard/index.js +0 -11
  68. package/dist/components/TotalCheckout/CardComp/index.js +0 -36
  69. package/dist/components/TotalCheckout/PaymentComp/index.d.ts +0 -9
  70. package/dist/components/TotalCheckout/PaymentMethodsComp/index.d.ts +0 -8
  71. package/dist/components/TotalCheckout/SelectPaymentMethodPopup/index.d.ts +0 -3
  72. package/dist/components/TotalCheckout/SelectPaymentMethodPopup/index.js +0 -65
  73. /package/dist/{components/TotalCheckout → modules/payment}/AddNewCard/style.d.ts +0 -0
  74. /package/dist/{components/TotalCheckout → modules/payment}/CardComp/style.d.ts +0 -0
  75. /package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/style.d.ts +0 -0
  76. /package/dist/{components/TotalCheckout → modules/payment}/PaymentComp/style.js +0 -0
  77. /package/dist/{components/TotalCheckout → modules/payment}/PaymentMethodsComp/style.d.ts +0 -0
  78. /package/dist/{components/TotalCheckout → modules/payment}/SelectPaymentMethodPopup/style.d.ts +0 -0
@@ -1,44 +1,52 @@
1
- import React, { useState } from 'react';
1
+ import React from 'react';
2
2
  import { Text } from '@weareconceptstudio/core';
3
+ import { cardSVG, idramSVG, telcellSVG, cashSVG, posTerminalSVG, inecopaySVG } from './icons';
4
+ import { useCheckoutContext } from '../../checkout';
3
5
  //* Style
4
6
  import PaymentMethodsCompStyle from './style';
5
- const PaymentMethodsComp = ({ className, fillCheckoutData, checkoutData, showAll }) => {
6
- const paymentOptions = [
7
+ const isNumeric = (value) => !isNaN(value) && !isNaN(parseFloat(value));
8
+ const PaymentMethodsComp = ({ className, showAll, selectedPayment, setSelectedPayment }) => {
9
+ let paymentOptions = [
7
10
  {
8
11
  label: 'Cash',
9
12
  value: 'cash_on_delivery',
10
- svg: '/images/payment/cash.svg',
11
- },
12
- {
13
- label: 'Card',
14
- value: 'credit_card',
15
- svg: '/images/payment/card.svg',
13
+ svg: cashSVG,
16
14
  },
17
15
  {
18
16
  label: 'Idram',
19
17
  value: 'idram',
20
- svg: '/images/payment/idram.svg',
18
+ svg: idramSVG,
21
19
  },
22
20
  {
23
21
  label: 'POS TERMINAL',
24
22
  value: 'pos_terminal',
25
- svg: '/images/payment/pos-terminal.svg',
23
+ svg: posTerminalSVG,
26
24
  },
27
25
  {
28
26
  label: 'Telcell',
29
27
  value: 'telcell',
30
- svg: '/images/payment/telcell.svg',
28
+ svg: telcellSVG,
31
29
  },
32
30
  {
33
31
  label: 'Inecopay',
34
32
  value: 'inecopay',
35
- svg: '/images/payment/inecopay.svg',
33
+ svg: inecopaySVG,
36
34
  },
37
35
  ];
38
- const [selectedPayment, setSelectedPayment] = useState(checkoutData.paymentType || '');
39
- const cardDetails = checkoutData.paymentType === 'credit_card'
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)
40
48
  ? {
41
- type: 'MasterCard', // Or 'Visa', based on your logic
49
+ card_type: 'MasterCard', // Or 'Visa', based on your logic
42
50
  number: '**** **** **** 1234',
43
51
  expDate: '12/24',
44
52
  }
@@ -48,7 +56,7 @@ const PaymentMethodsComp = ({ className, fillCheckoutData, checkoutData, showAll
48
56
  filteredOptions = paymentOptions;
49
57
  }
50
58
  else if (checkoutData.paymentType) {
51
- filteredOptions = paymentOptions.filter((option) => option.value === checkoutData.paymentType);
59
+ filteredOptions = paymentOptions.filter((option) => option.value === (isNumeric(checkoutData.paymentType) ? 'credit_card' : checkoutData.paymentType));
52
60
  }
53
61
  else {
54
62
  filteredOptions = paymentOptions;
@@ -57,20 +65,16 @@ const PaymentMethodsComp = ({ className, fillCheckoutData, checkoutData, showAll
57
65
  filteredOptions = filteredOptions.map((option) => option.value === 'credit_card'
58
66
  ? {
59
67
  ...option,
60
- label: React.createElement("span", { className: 'card-type' }, cardDetails.type),
68
+ label: React.createElement("span", { className: 'card-type' }, cardDetails.card_type),
61
69
  }
62
70
  : option);
63
71
  }
64
- const handleSelect = (value) => {
65
- setSelectedPayment(value);
66
- fillCheckoutData('paymentType', value);
67
- };
68
- return (React.createElement(PaymentMethodsCompStyle, { className: `payment-item-container ${className || ''}`, singlePayment: !!checkoutData.paymentType }, filteredOptions.map((option) => (React.createElement("div", { className: 'custom-payment-options', key: option.value },
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 },
69
73
  React.createElement("div", { className: 'payment-option-top' },
70
74
  React.createElement("div", { className: 'payment-item-left' },
71
- React.createElement("img", { src: option.svg, alt: `${option.label} icon` }),
75
+ React.createElement("div", null, option.svg),
72
76
  React.createElement(Text, { className: 'payment-label account-p account-p3 account-font-regular account-primary-color1' }, option.label)),
73
- React.createElement("div", { key: option.value, className: `circle-selected-wrap cursor-pointer ${selectedPayment === option.value ? 'active' : ''}`, onClick: () => handleSelect(option.value) },
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) },
74
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'}` },
75
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' })))),
76
80
  option.value === 'credit_card' && cardDetails && !showAll && (React.createElement("div", { className: 'card-details' },
@@ -4,7 +4,7 @@ const PaymentMethodsCompStyle = styled.div `
4
4
  --account_itemInternalPadTB: var(--sp2x);
5
5
  --account_itemInternalPadLR: var(--sp4x);
6
6
  --account_flexWrapperMTop: var(--sp2x);
7
- --account_itemDistance: var(--sp3x);
7
+ --account_itemDistance: var(--sp5x);
8
8
  --account_circleSize: var(--sp4x);
9
9
  --account_checkSize: var(--sp2x);
10
10
 
@@ -14,7 +14,7 @@ const PaymentMethodsCompStyle = styled.div `
14
14
  column-gap: var(--account_itemDistance);
15
15
 
16
16
  .custom-payment-options {
17
- width: ${(props) => (props.singlePayment ? '100%' : 'calc(50% - var(--account_itemDistance) / 2)')};
17
+ width: ${(props) => (props.$singlePayment ? '100%' : 'calc(50% - var(--account_itemDistance) / 2)')};
18
18
  border: 2px solid var(--account_primaryColor5);
19
19
  border-radius: var(--account_itemBorderRadius);
20
20
  padding: var(--account_itemInternalPadTB) var(--account_itemInternalPadLR);
@@ -94,7 +94,7 @@ const PaymentMethodsCompStyle = styled.div `
94
94
  --account_itemInternalPadTB: var(--sp2x);
95
95
  --account_itemInternalPadLR: var(--sp3x);
96
96
  --account_flexWrapperMTop: var(--sp2x);
97
- --account_itemDistance: var(--sp3x);
97
+ --account_itemDistance: var(--sp5x);
98
98
  --account_circleSize: var(--sp3x);
99
99
  --account_checkSize: var(--sp1-5x);
100
100
  }
@@ -103,7 +103,7 @@ const PaymentMethodsCompStyle = styled.div `
103
103
  --account_itemInternalPadTB: var(--sp1-5x);
104
104
  --account_itemInternalPadLR: var(--sp3x);
105
105
  --account_flexWrapperMTop: var(--sp1-5x);
106
- --account_itemDistance: var(--sp3x);
106
+ --account_itemDistance: var(--sp4x);
107
107
  --account_circleSize: var(--sp3x);
108
108
  --account_checkSize: var(--sp1-5x);
109
109
  }
@@ -112,7 +112,7 @@ const PaymentMethodsCompStyle = styled.div `
112
112
  --account_itemInternalPadTB: var(--sp1-5x);
113
113
  --account_itemInternalPadLR: var(--sp3x);
114
114
  --account_flexWrapperMTop: var(--sp1-5x);
115
- --account_itemDistance: var(--sp2x);
115
+ --account_itemDistance: var(--sp3x);
116
116
  --account_circleSize: var(--sp3x);
117
117
  --account_checkSize: var(--sp1-5x);
118
118
  }
@@ -130,7 +130,7 @@ const PaymentMethodsCompStyle = styled.div `
130
130
  --account_itemInternalPadTB: var(--sp1-5x);
131
131
  --account_itemInternalPadLR: var(--sp2x);
132
132
  --account_flexWrapperMTop: var(--sp1-5x);
133
- --account_itemDistance: var(--sp2x);
133
+ --account_itemDistance: var(--sp3x);
134
134
  --account_circleSize: var(--sp2-5x);
135
135
  --account_checkSize: var(--sp1x);
136
136
  }
@@ -150,7 +150,7 @@ const PaymentMethodsCompStyle = styled.div `
150
150
  --account_itemInternalPadTB: var(--sp1-5x);
151
151
  --account_itemInternalPadLR: var(--sp1-5x);
152
152
  --account_flexWrapperMTop: var(--sp1-5x);
153
- --account_itemDistance: var(--sp2x);
153
+ --account_itemDistance: var(--sp1x);
154
154
  --account_circleSize: var(--sp2-5x);
155
155
  --account_checkSize: var(--sp1x);
156
156
 
@@ -1,3 +1,3 @@
1
1
  export default PaymentMethodsTemplate;
2
- declare function PaymentMethodsTemplate({}: {}): React.JSX.Element;
2
+ declare function PaymentMethodsTemplate(): React.JSX.Element;
3
3
  import React from 'react';
@@ -1,41 +1,28 @@
1
1
  'use client';
2
2
  import React, { useState } from 'react';
3
- import { Text } from '@weareconceptstudio/core';
3
+ import { api, Text } from '@weareconceptstudio/core';
4
+ import { useAccountContext } from '../../../AccountProvider';
5
+ import { useCheckoutContext } from '../../checkout';
6
+ //* Components
7
+ import { AccountButton } from '../../../components';
8
+ import PaymentWrap from '../PaymentWrap';
9
+ //* Style
4
10
  import PaymentStyle from './style';
5
- import AddNewCard from '../../../components/TotalCheckout/AddNewCard';
6
- import CardComp from '../../../components/TotalCheckout/CardComp';
7
- const PaymentMethodsTemplate = ({}) => {
8
- const [selectedCard, setSelectedCard] = useState('');
9
- const [cardOptions, setCardOptions] = useState([
10
- {
11
- id: 1,
12
- type: 'MasterCard',
13
- number: '3122 4577 8799 8877',
14
- fullName: 'Sasoun Papelyan',
15
- expDate: '12/24',
16
- },
17
- {
18
- id: 2,
19
- type: 'Visa',
20
- number: '4577 1234 3122 1234',
21
- fullName: 'Gohar Vardevanyan',
22
- expDate: '12/25',
23
- },
24
- {
25
- id: 3,
26
- type: 'MasterCard',
27
- number: '8799 1234 3122 1234',
28
- fullName: 'Sasoun Papelyan',
29
- expDate: '12/27',
30
- },
31
- ]);
32
- const handleDelete = (cardId) => {
33
- setCardOptions((prevOptions) => prevOptions.filter((card) => card.id !== cardId));
11
+ const PaymentMethodsTemplate = () => {
12
+ const { useUser } = useAccountContext();
13
+ const { user } = useUser();
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
+ });
34
20
  };
35
21
  return (React.createElement(PaymentStyle, null,
36
- React.createElement(Text, { tag: `h6`, className: `account-font-medium account-primary-color1 title`, text: `myCards` }),
37
- React.createElement("div", { className: `flex-wrapper` },
38
- React.createElement(AddNewCard, { title: 'addNewCard' }),
39
- cardOptions.map((card, index) => (React.createElement(CardComp, { key: index, cardOption: card, selectedPayment: selectedCard, onSelect: setSelectedCard, onDelete: handleDelete }))))));
22
+ React.createElement("div", { className: 'account-payment-block' },
23
+ React.createElement(Text, { tag: `h6`, className: `account-font-medium account-primary-color1 title`, text: `myCards` }),
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 })))));
40
27
  };
41
28
  export default PaymentMethodsTemplate;
@@ -1,7 +1,11 @@
1
1
  import styled from 'styled-components';
2
2
  const PaymentStyle = styled.div `
3
- --account_payMethodsItemDistance: var(--sp3x);
4
3
  --account_payMethodsWrapMarginT: var(--sp4x);
4
+ --account_payButtonMarginT: var(--sp6x);
5
+ --account_lineMTop: var(--sp4x);
6
+ --account_lineMBottom: var(--sp4x);
7
+ --account_payMethodsItemDistance: var(--sp5x);
8
+ --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
5
9
 
6
10
  .account-payment-method {
7
11
  margin-top: unset;
@@ -12,42 +16,70 @@ const PaymentStyle = styled.div `
12
16
  }
13
17
 
14
18
  .flex-wrapper {
15
- display: flex;
16
- flex-wrap: wrap;
17
- gap: var(--account_payMethodsItemDistance);
18
19
  margin-top: var(--account_payMethodsWrapMarginT);
19
20
  }
20
21
 
21
- .new-card-container {
22
- position: relative;
22
+ .account-payment-btn-wrapper {
23
+ display: flex;
24
+ justify-content: end;
25
+ margin-top: var(--account_payButtonMarginT);
23
26
  }
24
27
 
25
28
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
26
- --account_payMethodsItemDistance: var(--sp3x);
29
+ --account_payMethodsItemDistance: var(--sp5x);
30
+ --account_payButtonMarginT: var(--sp5x);
31
+ --account_payMethodsWrapMarginT: var(--sp4x);
32
+ --account_lineMTop: var(--sp3x);
33
+ --account_lineMBottom: var(--sp4x);
27
34
  }
28
35
 
29
36
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
30
- --account_payMethodsItemDistance: var(--sp2x);
37
+ --account_payMethodsItemDistance: var(--sp4x);
38
+ --account_payButtonMarginT: var(--sp4x);
39
+ --account_payMethodsWrapMarginT: var(--sp3x);
40
+ --account_lineMTop: var(--sp3x);
41
+ --account_lineMBottom: var(--sp4x);
31
42
  }
32
43
 
33
44
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
34
- --account_payMethodsItemDistance: var(--sp2x);
45
+ --account_payMethodsItemDistance: var(--sp3x);
46
+ --account_payButtonMarginT: var(--sp4x);
47
+ --account_payMethodsWrapMarginT: var(--sp3x);
48
+ --account_lineMTop: var(--sp3x);
49
+ --account_lineMBottom: var(--sp3x);
35
50
  }
36
51
 
37
52
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
38
53
  --account_payMethodsItemDistance: var(--sp2x);
54
+ --account_payButtonMarginT: var(--sp3x);
55
+ --account_payMethodsWrapMarginT: var(--sp3x);
56
+ --account_lineMTop: var(--sp2-5x);
57
+ --account_lineMBottom: var(--sp2x);
39
58
  }
40
59
 
41
60
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
42
- --account_payMethodsItemDistance: var(--sp2x);
61
+ --account_payMethodsItemDistance: var(--sp3x);
62
+ --account_payButtonMarginT: var(--sp3x);
63
+ --account_payMethodsWrapMarginT: var(--sp2x);
64
+ --account_lineMTop: var(--sp2-5x);
65
+ --account_lineMBottom: var(--sp2x);
43
66
  }
44
67
 
45
68
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeS}) {
46
69
  --account_payMethodsItemDistance: var(--sp2x);
70
+ --account_payButtonMarginT: var(--sp2x);
71
+ --account_payMethodsWrapMarginT: var(--sp3x);
72
+ --account_lineMTop: var(--sp2x);
73
+ --account_lineMBottom: var(--sp3x);
47
74
  }
48
75
 
49
76
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
50
- --account_payMethodsItemDistance: var(--sp2x);
77
+ --account_payMethodsItemDistance: var(--sp1x);
78
+ --account_payButtonMarginT: var(--sp1-5x);
79
+ --account_payMethodsWrapMarginT: var(--sp2x);
80
+ --account_lineMTop: var(--sp2x);
81
+ --account_lineMBottom: var(--sp2x);
82
+ --account_radioWrapperWidth: 100%;
51
83
  }
52
84
  `;
53
85
  export default PaymentStyle;
@@ -0,0 +1,6 @@
1
+ export default PaymentWrap;
2
+ declare function PaymentWrap({ selectedPayment, setSelectedPayment }: {
3
+ selectedPayment: any;
4
+ setSelectedPayment: any;
5
+ }): React.JSX.Element;
6
+ import React from 'react';
@@ -0,0 +1,26 @@
1
+ import React, { useState } from 'react';
2
+ //* Components
3
+ import PaymentMethodsComp from '../PaymentMethodsComp';
4
+ import AddNewCard from '../AddNewCard';
5
+ import CardComp from '../CardComp';
6
+ //* Style
7
+ import PaymentWrapStyle from './style';
8
+ import { useAccountContext } from '../../../AccountProvider';
9
+ import { api } from '@weareconceptstudio/core';
10
+ const PaymentWrap = ({ selectedPayment, setSelectedPayment }) => {
11
+ const { useUser } = useAccountContext();
12
+ const { user } = useUser();
13
+ const [cards, setCards] = useState(user.cards);
14
+ const deleteCard = async (cardId) => {
15
+ await api.post('delete-card', { card_id: cardId }).then(() => {
16
+ setCards((prev) => prev.filter((item) => item.id != cardId));
17
+ });
18
+ };
19
+ return (React.createElement(PaymentWrapStyle, null,
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 })))),
23
+ React.createElement("div", { className: 'line' }),
24
+ React.createElement(PaymentMethodsComp, { showAll: true, selectedPayment: selectedPayment, setSelectedPayment: setSelectedPayment })));
25
+ };
26
+ export default PaymentWrap;
@@ -0,0 +1,2 @@
1
+ export default PaymentWrapStyle;
2
+ declare const PaymentWrapStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
@@ -1,12 +1,10 @@
1
1
  import styled from 'styled-components';
2
- const SelectPaymentMethodPopupStyle = styled.section `
3
- --account_cancelAndSaveWrapMTop: var(--sp5x);
4
- --account_cancelDistance: var(--sp5x);
5
- --account_selectAddressWrapMBot: var(--sp5x);
6
- --account_payMethodsItemDistance: var(--sp3x);
2
+ const PaymentWrapStyle = styled.section `
3
+ --account_selectPaymentWrapMBot: var(--sp5x);
4
+ --account_payMethodsItemDistance: var(--sp5x);
7
5
  --account_payMethodsItemInternalPad: var(--sp2x);
8
6
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
9
- --account_lineMTop: var(--sp3x);
7
+ --account_lineMTop: var(--sp4x);
10
8
  --account_lineMBottom: var(--sp4x);
11
9
 
12
10
  .new-card-container {
@@ -18,19 +16,13 @@ const SelectPaymentMethodPopupStyle = styled.section `
18
16
  flex-wrap: wrap;
19
17
  justify-content: space-between;
20
18
  align-items: center;
21
- margin-bottom: var(--account_selectAddressWrapMBot);
19
+ margin-bottom: var(--account_selectPaymentWrapMBot);
22
20
  }
23
21
 
24
22
  .flex-wrapper {
25
23
  display: flex;
26
24
  flex-wrap: wrap;
27
25
  gap: var(--account_payMethodsItemDistance);
28
-
29
- /* .item-container {
30
- &:not(:nth-child(1), :nth-child(2)) {
31
- margin-top: var(--account_payMethodsItemDistance) !important;
32
- }
33
- } */
34
26
  }
35
27
 
36
28
  .custom-payment-options {
@@ -38,19 +30,6 @@ const SelectPaymentMethodPopupStyle = styled.section `
38
30
  padding: var(--account_payMethodsItemInternalPad) !important;
39
31
  }
40
32
 
41
- .cancel-and-save-wrap {
42
- display: flex;
43
- justify-content: flex-end;
44
- align-items: center;
45
- margin-top: var(--account_cancelAndSaveWrapMTop);
46
-
47
- .btn-wrap {
48
- &:first-child {
49
- margin-right: var(--account_cancelDistance);
50
- }
51
- }
52
- }
53
-
54
33
  .line {
55
34
  width: 100%;
56
35
  height: 2px;
@@ -59,95 +38,66 @@ const SelectPaymentMethodPopupStyle = styled.section `
59
38
  }
60
39
 
61
40
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
62
- --account_cancelAndSaveWrapMTop: var(--sp4x);
63
- --account_cancelDistance: var(--sp3x);
64
- --account_selectAddressWrapMBot: var(--sp4x);
65
- --account_payMethodsItemDistance: var(--sp3x);
41
+ --account_selectPaymentWrapMBot: var(--sp4x);
42
+ --account_payMethodsItemDistance: var(--sp5x);
66
43
  --account_payMethodsItemInternalPad: var(--sp2x);
67
44
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
68
- --account_lineMTop: var(--sp2-5x);
69
- --account_lineMBottom: var(--sp3x);
45
+ --account_lineMTop: var(--sp3x);
46
+ --account_lineMBottom: var(--sp4x);
70
47
  }
71
48
 
72
49
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
73
- --account_cancelAndSaveWrapMTop: var(--sp3x);
74
- --account_cancelDistance: var(--sp3x);
75
- --account_selectAddressWrapMBot: var(--sp3x);
76
- --account_payMethodsItemDistance: var(--sp2x);
50
+ --account_selectPaymentWrapMBot: var(--sp3x);
51
+ --account_payMethodsItemDistance: var(--sp4x);
77
52
  --account_payMethodsItemInternalPad: var(--sp1-5x);
78
53
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
79
- --account_lineMTop: var(--sp2x);
80
- --account_lineMBottom: var(--sp3x);
54
+ --account_lineMTop: var(--sp3x);
55
+ --account_lineMBottom: var(--sp4x);
81
56
  }
82
57
 
83
58
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
84
- --account_cancelAndSaveWrapMTop: var(--sp3x);
85
- --account_cancelDistance: var(--sp3x);
86
- --account_selectAddressWrapMBot: var(--sp3x);
87
- --account_payMethodsItemDistance: var(--sp2x);
59
+ --account_selectPaymentWrapMBot: var(--sp3x);
60
+ --account_payMethodsItemDistance: var(--sp3x);
88
61
  --account_payMethodsItemInternalPad: var(--sp1-5x);
89
62
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
90
- --account_lineMTop: var(--sp2x);
63
+ --account_lineMTop: var(--sp3x);
91
64
  --account_lineMBottom: var(--sp3x);
92
65
  }
93
66
 
94
67
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
95
- --account_cancelAndSaveWrapMTop: var(--sp3x);
96
- --account_cancelDistance: var(--sp2-5x);
97
- --account_selectAddressWrapMBot: var(--sp3x);
68
+ --account_selectPaymentWrapMBot: var(--sp3x);
98
69
  --account_payMethodsItemDistance: var(--sp2x);
99
70
  --account_payMethodsItemInternalPad: var(--sp1-5x);
100
71
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
101
- --account_lineMTop: var(--sp2x);
72
+ --account_lineMTop: var(--sp2-5x);
102
73
  --account_lineMBottom: var(--sp2x);
103
74
  }
104
75
 
105
76
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
106
- --account_cancelAndSaveWrapMTop: var(--sp3x);
107
- --account_cancelDistance: var(--sp2-5x);
108
- --account_selectAddressWrapMBot: var(--sp3x);
109
- --account_payMethodsItemDistance: var(--sp2x);
77
+ --account_selectPaymentWrapMBot: var(--sp3x);
78
+ --account_payMethodsItemDistance: var(--sp3x);
110
79
  --account_payMethodsItemInternalPad: var(--sp1-5x);
111
80
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
112
- --account_lineMTop: var(--sp2x);
81
+ --account_lineMTop: var(--sp2-5x);
113
82
  --account_lineMBottom: var(--sp2x);
114
83
  }
115
84
 
116
85
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeS}) {
117
- --account_cancelAndSaveWrapMTop: var(--sp3x);
118
- --account_cancelDistance: var(--sp2-5x);
119
- --account_selectAddressWrapMBot: var(--sp3x);
86
+ --account_selectPaymentWrapMBot: var(--sp3x);
120
87
  --account_payMethodsItemDistance: var(--sp2x);
121
88
  --account_payMethodsItemInternalPad: var(--sp1-5x);
122
89
  --account_radioWrapperWidth: calc(50% - var(--account_payMethodsItemDistance) / 2);
123
- --account_lineMTop: var(--sp1-5x);
124
- --account_lineMBottom: var(--sp2x);
90
+ --account_lineMTop: var(--sp2x);
91
+ --account_lineMBottom: var(--sp3x);
125
92
  }
126
93
 
127
94
  @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
128
- --account_cancelAndSaveWrapMTop: var(--sp3x);
129
- --account_cancelDistance: var(--sp2x);
130
- --account_selectAddressWrapMBot: var(--sp3x);
131
- --account_payMethodsItemDistance: var(--sp2x);
95
+ --account_selectPaymentWrapMBot: var(--sp3x);
96
+ --account_payMethodsItemDistance: var(--sp1x);
132
97
  --account_payMethodsItemInternalPad: var(--sp1-5x);
133
98
  --account_radioWrapperWidth: 100%;
134
- --account_lineMTop: var(--sp1-5x);
135
- --account_lineMBottom: var(--sp1-5x);
136
-
137
- .cancel-and-save-wrap {
138
- flex-direction: column-reverse;
139
-
140
- .btn-wrap {
141
- &:first-child {
142
- margin-right: 0;
143
- margin-top: var(--account_cancelDistance);
144
- }
145
-
146
- &:last-child {
147
- width: 100%;
148
- }
149
- }
150
- }
99
+ --account_lineMTop: var(--sp2x);
100
+ --account_lineMBottom: var(--sp2x);
151
101
  }
152
102
  `;
153
- export default SelectPaymentMethodPopupStyle;
103
+ export default PaymentWrapStyle;
@@ -0,0 +1,3 @@
1
+ export default SelectPaymentMethodPopup;
2
+ declare function SelectPaymentMethodPopup(): React.JSX.Element;
3
+ import React from 'react';
@@ -0,0 +1,25 @@
1
+ import React, { useState } from 'react';
2
+ import { useUi, Text } from '@weareconceptstudio/core';
3
+ import { useCheckoutContext } from '../../checkout';
4
+ //* Components
5
+ import AccountButton from '../../../components/AccountButton';
6
+ import PaymentWrap from '../PaymentWrap';
7
+ //* Style
8
+ import SelectPaymentMethodPopupStyle from './style';
9
+ const SelectPaymentMethodPopup = () => {
10
+ const { closePopup } = useUi();
11
+ const { checkoutData, fillCheckoutData } = useCheckoutContext();
12
+ const [selectedPayment, setSelectedPayment] = useState(checkoutData.paymentType);
13
+ const handlePaymentMethodChangeSubmit = () => {
14
+ fillCheckoutData('paymentType', selectedPayment);
15
+ closePopup();
16
+ };
17
+ return (React.createElement(SelectPaymentMethodPopupStyle, null,
18
+ React.createElement("div", { className: `select-payment-wrap` },
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 }),
21
+ React.createElement("div", { className: `cancel-and-save-wrap` },
22
+ React.createElement(AccountButton, { btnType: `green-large-text`, text: `cancel`, onClick: closePopup }),
23
+ React.createElement(AccountButton, { btnType: `full-width`, text: `saveAndApply`, onClick: handlePaymentMethodChangeSubmit }))));
24
+ };
25
+ export default SelectPaymentMethodPopup;
@@ -0,0 +1,81 @@
1
+ import styled from 'styled-components';
2
+ const SelectPaymentMethodPopupStyle = styled.section `
3
+ --account_selectPaymentTitleMBot: var(--sp4x);
4
+ --account_cancelAndSaveWrapMTop: var(--sp5x);
5
+ --account_cancelDistance: var(--sp5x);
6
+
7
+ .cancel-and-save-wrap {
8
+ display: flex;
9
+ justify-content: flex-end;
10
+ align-items: center;
11
+ margin-top: var(--account_cancelAndSaveWrapMTop);
12
+
13
+ .btn-wrap {
14
+ &:first-child {
15
+ margin-right: var(--account_cancelDistance);
16
+ }
17
+ }
18
+ }
19
+
20
+ .select-payment-wrap {
21
+ margin-bottom: var(--account_selectPaymentTitleMBot);
22
+ }
23
+
24
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
25
+ --account_selectPaymentTitleMBot: var(--sp4x);
26
+ --account_cancelAndSaveWrapMTop: var(--sp4x);
27
+ --account_cancelDistance: var(--sp3x);
28
+ }
29
+
30
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
31
+ --account_selectPaymentTitleMBot: var(--sp4x);
32
+ --account_cancelAndSaveWrapMTop: var(--sp3x);
33
+ --account_cancelDistance: var(--sp3x);
34
+ }
35
+
36
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
37
+ --account_selectPaymentTitleMBot: var(--sp4x);
38
+ --account_cancelAndSaveWrapMTop: var(--sp3x);
39
+ --account_cancelDistance: var(--sp3x);
40
+ }
41
+
42
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
43
+ --account_selectPaymentTitleMBot: var(--sp3x);
44
+ --account_cancelAndSaveWrapMTop: var(--sp3x);
45
+ --account_cancelDistance: var(--sp2-5x);
46
+ }
47
+
48
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
49
+ --account_selectPaymentTitleMBot: var(--sp2-5x);
50
+ --account_cancelAndSaveWrapMTop: var(--sp3x);
51
+ --account_cancelDistance: var(--sp2-5x);
52
+ }
53
+
54
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeS}) {
55
+ --account_selectPaymentTitleMBot: var(--sp3x);
56
+ --account_cancelAndSaveWrapMTop: var(--sp3x);
57
+ --account_cancelDistance: var(--sp2-5x);
58
+ }
59
+
60
+ @media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
61
+ --account_selectPaymentTitleMBot: var(--sp2x);
62
+ --account_cancelAndSaveWrapMTop: var(--sp3x);
63
+ --account_cancelDistance: var(--sp2x);
64
+
65
+ .cancel-and-save-wrap {
66
+ flex-direction: column-reverse;
67
+
68
+ .btn-wrap {
69
+ &:first-child {
70
+ margin-right: 0;
71
+ margin-top: var(--account_cancelDistance);
72
+ }
73
+
74
+ &:last-child {
75
+ width: 100%;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ `;
81
+ export default SelectPaymentMethodPopupStyle;