@weareconceptstudio/account 0.5.3 → 0.5.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.
- package/dist/components/TotalCheckout/BalanceComp/index.d.ts +1 -3
- package/dist/components/TotalCheckout/BalanceComp/index.js +9 -13
- package/dist/components/TotalCheckout/CommentComp/index.d.ts +3 -1
- package/dist/components/TotalCheckout/CommentComp/index.js +4 -4
- package/dist/components/TotalCheckout/PromoCodeComp/index.d.ts +1 -3
- package/dist/components/TotalCheckout/PromoCodeComp/index.js +6 -11
- package/dist/components/TotalCheckout/index.js +9 -40
- package/dist/components/TotalCheckout/style.js +9 -5
- package/dist/modules/cart/CartItems/Item/index.js +49 -0
- package/dist/modules/cart/CartItems/ItemMobile/index.js +46 -0
- package/dist/modules/cart/{SimpleItems → CartItems}/index.js +7 -9
- package/dist/modules/cart/{SimpleItems → CartItems}/style.js +46 -69
- package/dist/modules/cart/CartTemplate/Skeleton/SkeletonItem/index.js +1 -2
- package/dist/modules/cart/CartTemplate/Skeleton/index.js +3 -6
- package/dist/modules/cart/CartTemplate/Skeleton/style.js +11 -10
- package/dist/modules/cart/CartTemplate/index.d.ts +1 -2
- package/dist/modules/cart/CartTemplate/index.js +8 -5
- package/dist/modules/cart/index.d.ts +1 -1
- package/dist/modules/cart/index.js +1 -1
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +2 -2
- package/dist/modules/order/OrderDetails/index.js +15 -6
- package/dist/modules/order/OrderedItems/Item/index.d.ts +3 -0
- package/dist/modules/order/OrderedItems/Item/index.js +42 -0
- package/dist/modules/order/OrderedItems/ItemMobile/index.d.ts +3 -0
- package/dist/modules/order/OrderedItems/ItemMobile/index.js +47 -0
- package/dist/modules/order/OrderedItems/index.d.ts +1 -2
- package/dist/modules/order/OrderedItems/index.js +7 -59
- package/dist/modules/order/OrderedItems/style.js +85 -9
- package/dist/modules/order/OrderedItems/util.d.ts +2 -0
- package/dist/modules/order/OrderedItems/util.js +3 -0
- package/dist/modules/order/OrdersList/{OrderItem → Item}/index.js +5 -3
- package/dist/modules/order/OrdersList/ItemMobile/index.d.ts +3 -0
- package/dist/modules/order/OrdersList/ItemMobile/index.js +39 -0
- package/dist/modules/order/OrdersList/index.js +10 -41
- package/dist/modules/order/OrdersList/style.js +2 -2
- package/dist/translations/en.d.ts +2 -0
- package/dist/translations/en.js +2 -0
- package/dist/translations/hy.d.ts +2 -0
- package/dist/translations/hy.js +3 -1
- package/dist/translations/index.d.ts +6 -0
- package/dist/translations/ru.d.ts +2 -0
- package/dist/translations/ru.js +2 -0
- package/package.json +1 -1
- package/dist/modules/cart/SimpleItems/Item/index.js +0 -38
- package/dist/modules/cart/SimpleItems/ItemMobile/index.js +0 -41
- /package/dist/modules/cart/{SimpleItems → CartItems}/Item/index.d.ts +0 -0
- /package/dist/modules/cart/{SimpleItems → CartItems}/ItemMobile/index.d.ts +0 -0
- /package/dist/modules/cart/{SimpleItems → CartItems}/index.d.ts +0 -0
- /package/dist/modules/cart/{SimpleItems → CartItems}/style.d.ts +0 -0
- /package/dist/modules/cart/{SimpleItems → CartItems}/util.d.ts +0 -0
- /package/dist/modules/cart/{SimpleItems → CartItems}/util.js +0 -0
- /package/dist/modules/order/OrdersList/{OrderItem → Item}/index.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Text, CollapseItem, handlePriceCheckFunc, useTranslation } from '@weareconceptstudio/core';
|
|
3
3
|
import { FormBuilder } from '@weareconceptstudio/form';
|
|
4
4
|
import { useAccountContext } from '../../../AccountProvider';
|
|
@@ -7,35 +7,31 @@ import AccountButton from '../../AccountButton';
|
|
|
7
7
|
import { balanceFields } from './utils';
|
|
8
8
|
//* Style
|
|
9
9
|
import BalanceCompStyle from './style';
|
|
10
|
-
const BalanceComp = (
|
|
10
|
+
const BalanceComp = () => {
|
|
11
11
|
const { translate } = useTranslation();
|
|
12
12
|
const { useCart, useUser } = useAccountContext();
|
|
13
13
|
const { currency, itemsCount, useBalance } = useCart();
|
|
14
14
|
const { fillCart } = useCheckoutContext();
|
|
15
15
|
const { user } = useUser();
|
|
16
|
-
const balance = user?.balance || 0;
|
|
17
|
-
const [disable, setDisable] = useState(false);
|
|
18
16
|
const handleBalance = (amount) => {
|
|
19
17
|
fillCart('useBalance', amount);
|
|
20
18
|
};
|
|
21
19
|
const onFinish = (values) => {
|
|
22
|
-
|
|
20
|
+
if (!user || !user?.balance)
|
|
21
|
+
return;
|
|
23
22
|
handleBalance(values.balance);
|
|
24
23
|
};
|
|
25
|
-
return
|
|
26
|
-
React.createElement(CollapseItem, {
|
|
24
|
+
return (React.createElement(BalanceCompStyle, { className: `collapse-distance ${itemsCount && user.balance ? '' : 'disable'}` },
|
|
25
|
+
React.createElement(CollapseItem, { title: React.createElement(React.Fragment, null,
|
|
27
26
|
React.createElement("div", { className: 'inner-wrapper-icon' },
|
|
28
27
|
React.createElement("svg", { width: '12', height: '12', fill: 'none', viewBox: '0 0 12 12', xmlns: 'http://www.w3.org/2000/svg' },
|
|
29
28
|
React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
|
|
30
29
|
React.createElement("path", { d: 'M6 12L6 0', stroke: 'black', strokeWidth: '2' }))),
|
|
31
|
-
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium balance-text' }, `${translate('account.balance_promotions.useYourMoney')} (${handlePriceCheckFunc(balance, currency)} ${translate('account.balance_promotions.balance')})`)), description: React.createElement(React.Fragment, null, useBalance ? (React.createElement("div", { className: `balance-success-block` },
|
|
30
|
+
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium balance-text' }, `${translate('account.balance_promotions.useYourMoney')} (${handlePriceCheckFunc(user.balance, currency)} ${translate('account.balance_promotions.balance')})`)), description: React.createElement(React.Fragment, null, useBalance ? (React.createElement("div", { className: `balance-success-block` },
|
|
32
31
|
React.createElement(Text, { className: 'account-p account-p4 account-primary-color2 account-font-medium balance-success-text' }, handlePriceCheckFunc(useBalance, currency)),
|
|
33
|
-
React.createElement(Text, { text: 'account.general_actions.remove', className: 'account-p account-p4 account-primary-color2 account-font-medium balance-remove-text', onClick: () => {
|
|
34
|
-
handleBalance(null);
|
|
35
|
-
setDisable(false);
|
|
36
|
-
} }))) : (React.createElement(FormBuilder, { onSubmit: onFinish, fields: balanceFields, className: `balance-block`, formOptions: {
|
|
32
|
+
React.createElement(Text, { text: 'account.general_actions.remove', className: 'account-p account-p4 account-primary-color2 account-font-medium balance-remove-text', onClick: () => handleBalance(null) }))) : (React.createElement(FormBuilder, { onSubmit: onFinish, fields: balanceFields, className: `balance-block`, formOptions: {
|
|
37
33
|
className: 'balance-container',
|
|
38
34
|
} },
|
|
39
|
-
React.createElement(AccountButton, {
|
|
35
|
+
React.createElement(AccountButton, { type: 'submit', disabled: !user.balance, btnType: `balance-version`, text: `account.general_actions.add` })))) })));
|
|
40
36
|
};
|
|
41
37
|
export default BalanceComp;
|
|
@@ -3,15 +3,15 @@ import { CollapseContainer, CollapseItem, Text } from '@weareconceptstudio/core'
|
|
|
3
3
|
import { Input } from '@weareconceptstudio/form';
|
|
4
4
|
import { useCheckoutContext } from '../../../modules';
|
|
5
5
|
import CommentCompStyle from './style';
|
|
6
|
-
const CommentComp = () => {
|
|
7
|
-
const { fillCheckoutData } = useCheckoutContext();
|
|
8
|
-
return (React.createElement(CommentCompStyle, { className: 'collapse-distance' },
|
|
6
|
+
const CommentComp = ({ isShipping }) => {
|
|
7
|
+
const { fillCheckoutData, isCheckoutPage } = useCheckoutContext();
|
|
8
|
+
return isCheckoutPage && typeof isShipping === 'boolean' && !isShipping ? (React.createElement(CommentCompStyle, { className: 'collapse-distance' },
|
|
9
9
|
React.createElement(CollapseContainer, null,
|
|
10
10
|
React.createElement(CollapseItem, { status: 'open', title: React.createElement(React.Fragment, null,
|
|
11
11
|
React.createElement("div", { className: 'inner-wrapper-icon' },
|
|
12
12
|
React.createElement("svg", { width: '12', height: '12', fill: 'none', viewBox: '0 0 12 12', xmlns: 'http://www.w3.org/2000/svg' },
|
|
13
13
|
React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
|
|
14
14
|
React.createElement("path", { d: 'M6 12L6 0', stroke: 'black', strokeWidth: '2' }))),
|
|
15
|
-
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium comment-text', text: 'account.order_balance.comment' })), description: React.createElement(Input.TextArea, { containerClassName: `comment-field`, placeholder: 'account.cart_checkout.checkoutCommentPlaceholder', onChange: (e) => fillCheckoutData('note', e.target.value), className: `account-p account-p3 account-font-regular account-primary-color1` }) }))));
|
|
15
|
+
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium comment-text', text: 'account.order_balance.comment' })), description: React.createElement(Input.TextArea, { containerClassName: `comment-field`, placeholder: 'account.cart_checkout.checkoutCommentPlaceholder', onChange: (e) => fillCheckoutData('note', e.target.value), className: `account-p account-p3 account-font-regular account-primary-color1` }) })))) : null;
|
|
16
16
|
};
|
|
17
17
|
export default CommentComp;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { Text, CollapseItem } from '@weareconceptstudio/core';
|
|
3
3
|
import { FormBuilder } from '@weareconceptstudio/form';
|
|
4
4
|
import { useAccountContext } from '../../../AccountProvider';
|
|
@@ -8,35 +8,30 @@ import AppliedPromotion from './AppliedPromotion';
|
|
|
8
8
|
import { promoCodeFields } from './utils';
|
|
9
9
|
//* Style
|
|
10
10
|
import PromoCodeCompStyle from './style';
|
|
11
|
-
const PromoCodeComp = (
|
|
11
|
+
const PromoCodeComp = () => {
|
|
12
12
|
const { useCart } = useAccountContext();
|
|
13
13
|
const { itemsCount, usePromotion, appliedPromotions } = useCart();
|
|
14
14
|
const { fillCart } = useCheckoutContext();
|
|
15
|
-
const [disable, setDisable] = useState(false);
|
|
16
15
|
const handlePromotion = (promotion) => {
|
|
17
16
|
fillCart('usePromotion', promotion);
|
|
18
17
|
};
|
|
19
18
|
const onFinish = (values) => {
|
|
20
|
-
setDisable(true);
|
|
21
19
|
handlePromotion(values.promo_code);
|
|
22
20
|
};
|
|
23
21
|
const promotions = useMemo(() => {
|
|
24
22
|
return appliedPromotions?.map((promotion, index) => (React.createElement(AppliedPromotion, { key: index, ...promotion })));
|
|
25
23
|
}, [appliedPromotions]);
|
|
26
|
-
return
|
|
27
|
-
React.createElement(CollapseItem, { status: appliedPromotions?.length ? 'open' : 'close',
|
|
24
|
+
return (React.createElement(PromoCodeCompStyle, { className: `collapse-distance ${itemsCount ? '' : 'disable'}` },
|
|
25
|
+
React.createElement(CollapseItem, { status: appliedPromotions?.length ? 'open' : 'close', title: React.createElement(React.Fragment, null,
|
|
28
26
|
React.createElement("div", { className: 'inner-wrapper-icon' },
|
|
29
27
|
React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '12', height: '12', viewBox: '0 0 12 12', fill: 'none' },
|
|
30
28
|
React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
|
|
31
29
|
React.createElement("path", { d: 'M6 12L6 0', stroke: 'black', strokeWidth: '2' }))),
|
|
32
30
|
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium promo-code-text', text: 'account.balance_promotions.gotPromotionCode' })), description: React.createElement(React.Fragment, null,
|
|
33
31
|
promotions,
|
|
34
|
-
usePromotion ? (React.createElement(AppliedPromotion, { name: usePromotion, onClick: () => {
|
|
35
|
-
handlePromotion(null);
|
|
36
|
-
setDisable(false);
|
|
37
|
-
} })) : (React.createElement(FormBuilder, { onSubmit: onFinish, fields: promoCodeFields, className: `promo-code-block`, formOptions: {
|
|
32
|
+
usePromotion ? (React.createElement(AppliedPromotion, { name: usePromotion, onClick: () => handlePromotion(null) })) : (React.createElement(FormBuilder, { onSubmit: onFinish, fields: promoCodeFields, className: `promo-code-block`, formOptions: {
|
|
38
33
|
className: 'promo-code-container',
|
|
39
34
|
} },
|
|
40
|
-
React.createElement(AccountButton, { type: 'submit', btnType: `promo-code-version`, text: `account.general_actions.add` })))) })))
|
|
35
|
+
React.createElement(AccountButton, { type: 'submit', btnType: `promo-code-version`, text: `account.general_actions.add` })))) })));
|
|
41
36
|
};
|
|
42
37
|
export default PromoCodeComp;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
2
|
import { Text, CollapseContainer, handlePriceCheckFunc, numToLocalString } from '@weareconceptstudio/core';
|
|
3
3
|
import { useAccountContext } from '../../AccountProvider';
|
|
4
4
|
import { useAddressContext, useCheckoutContext } from '../../modules';
|
|
@@ -14,40 +14,10 @@ import TotalCheckoutStyle from './style';
|
|
|
14
14
|
import SkeletonTotalCheckout from './Skeleton';
|
|
15
15
|
const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps }) => {
|
|
16
16
|
const { useCart, useUser } = useAccountContext();
|
|
17
|
-
const { checkoutBtnDisabled
|
|
17
|
+
const { checkoutBtnDisabled } = useCheckoutContext();
|
|
18
18
|
const { addressLoading } = useAddressContext();
|
|
19
19
|
const { user } = useUser();
|
|
20
20
|
const { itemsCount, shippingCost, total, subtotal, useBalance, loading, discount, currency } = useCart();
|
|
21
|
-
const innerCollapseRef = useRef(null);
|
|
22
|
-
//! disable keypress on input
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const handleKeyDown = (event) => {
|
|
25
|
-
if (event.key === 'Enter') {
|
|
26
|
-
event.preventDefault();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
if ((!itemsCount || !user?.balance) && innerCollapseRef.current) {
|
|
30
|
-
let inputField = innerCollapseRef.current.querySelectorAll('.base-input');
|
|
31
|
-
if (inputField.length) {
|
|
32
|
-
[...inputField].forEach((item, i) => {
|
|
33
|
-
if (!user?.balance && itemsCount && i == 1) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
item.addEventListener('keydown', handleKeyDown);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return () => {
|
|
43
|
-
if ((!itemsCount || !user?.balance) && innerCollapseRef.current) {
|
|
44
|
-
const inputField = innerCollapseRef.current.querySelectorAll('.base-input');
|
|
45
|
-
[...inputField].map((item) => {
|
|
46
|
-
item.removeEventListener('keydown', handleKeyDown);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
21
|
return (React.createElement(TotalCheckoutStyle, null,
|
|
52
22
|
React.createElement("div", { className: `cart-main-wrap` },
|
|
53
23
|
React.createElement("div", { className: `left-panel-wrap panel` }, children),
|
|
@@ -60,12 +30,12 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
60
30
|
React.createElement("div", { className: `od-item-wrap` },
|
|
61
31
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-subtotal`, text: `account.cart_checkout.subtotal` }),
|
|
62
32
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-currency`, text: itemsCount ? handlePriceCheckFunc(subtotal, currency) : `0 ${currency}` })),
|
|
63
|
-
user && useBalance ? (React.createElement("div", { className: `od-item-wrap` },
|
|
64
|
-
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `account.balance_promotions.muramoney` }),
|
|
65
|
-
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(useBalance, currency)}` }))) : null,
|
|
66
33
|
user && discount ? (React.createElement("div", { className: `od-item-wrap` },
|
|
67
34
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `account.order_balance.discount` }),
|
|
68
35
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(discount, currency)}` }))) : null,
|
|
36
|
+
user && useBalance ? (React.createElement("div", { className: `od-item-wrap` },
|
|
37
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `account.balance_promotions.muramoney` }),
|
|
38
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(useBalance, currency)}` }))) : null,
|
|
69
39
|
React.createElement("div", { className: `od-item-wrap` },
|
|
70
40
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-shipping`, text: `account.address_management.shipping` }),
|
|
71
41
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-shipping-cost`, text: `${String(shippingCost).toLowerCase() === 'free' ? `account.general_actions.${shippingCost}` : shippingCost === '-' ? shippingCost : `${numToLocalString(shippingCost)} ${currency}`}` })),
|
|
@@ -74,11 +44,10 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
74
44
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-currency2`, text: itemsCount ? handlePriceCheckFunc(total, currency) : `0 ${currency}` })),
|
|
75
45
|
React.createElement(GiftComp, null),
|
|
76
46
|
React.createElement(FreeShippingComp, null),
|
|
77
|
-
React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
|
|
78
|
-
React.createElement(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
isCheckoutPage && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, null) : null,
|
|
47
|
+
user ? (React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
|
|
48
|
+
React.createElement(PromoCodeComp, null),
|
|
49
|
+
React.createElement(BalanceComp, null))) : null,
|
|
50
|
+
React.createElement(CommentComp, { isShipping: isShipping }),
|
|
82
51
|
React.createElement(AccountButton, { url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, disabled: checkoutBtnDisabled, loading: buttonProps.loadingButton, className: `sticky-wrap-btn text-center`, onClick: () => buttonProps.handleClick && buttonProps.handleClick() })))))) : (React.createElement(SkeletonTotalCheckout, null))))));
|
|
83
52
|
});
|
|
84
53
|
export default TotalCheckout;
|
|
@@ -176,9 +176,13 @@ const TotalCheckoutStyle = styled.section `
|
|
|
176
176
|
&.disable {
|
|
177
177
|
#collapse-description {
|
|
178
178
|
button {
|
|
179
|
-
pointer-events: none;
|
|
180
|
-
border-color: var(--account_primaryColor5);
|
|
181
|
-
color: var(--account_primaryColor5);
|
|
179
|
+
pointer-events: none !important;
|
|
180
|
+
border-color: var(--account_primaryColor5) !important;
|
|
181
|
+
color: var(--account_primaryColor5) !important;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.disabled {
|
|
185
|
+
opacity: 1 !important;
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
}
|
|
@@ -192,7 +196,7 @@ const TotalCheckoutStyle = styled.section `
|
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
/* //! Scroll logic */
|
|
195
|
-
.scroll-block {
|
|
199
|
+
/* .scroll-block {
|
|
196
200
|
overflow-x: hidden;
|
|
197
201
|
overflow-y: auto;
|
|
198
202
|
max-height: calc(100vh - var(--sp27x));
|
|
@@ -203,7 +207,7 @@ const TotalCheckoutStyle = styled.section `
|
|
|
203
207
|
&::-webkit-scrollbar {
|
|
204
208
|
display: none;
|
|
205
209
|
}
|
|
206
|
-
}
|
|
210
|
+
} */
|
|
207
211
|
|
|
208
212
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
|
|
209
213
|
--account_distance: var(--sp8x);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { handlePriceCheckFunc, Image, Text, useTranslation } from '@weareconceptstudio/core';
|
|
3
|
+
import { AccountButton, AccountCounter } from '../../../../components';
|
|
4
|
+
import { useAccountContext } from '../../../../AccountProvider';
|
|
5
|
+
import { useCheckoutContext } from '../../../checkout';
|
|
6
|
+
import { defaultIconGift } from '../util';
|
|
7
|
+
const Item = memo(({ data, remove, select, isLast, actions }) => {
|
|
8
|
+
const { checkoutData, setCheckGift } = useCheckoutContext();
|
|
9
|
+
const { currency, handleProductClick } = useAccountContext();
|
|
10
|
+
const { translate } = useTranslation();
|
|
11
|
+
return (React.createElement("div", { className: `item-wrap user-select-none` },
|
|
12
|
+
React.createElement("div", { className: 'line' }),
|
|
13
|
+
React.createElement("div", { className: `item-inner-wrapper` },
|
|
14
|
+
React.createElement("div", { className: `col-item tl-col-1 col-item-1` },
|
|
15
|
+
React.createElement("div", { className: `image-wrapper` },
|
|
16
|
+
data.is_gift ? React.createElement("div", { className: 'wrapper-gift-icon' }, defaultIconGift) : null,
|
|
17
|
+
React.createElement(Image, { src: data.product.image.src, alt: data.product.image.alt })),
|
|
18
|
+
React.createElement("div", { className: `col-1-right-wrap` },
|
|
19
|
+
React.createElement(AccountButton, { text: data.product.name, btnType: `green-large-text`, className: `capitalize title-btn`, onClick: () => handleProductClick(data.product) }),
|
|
20
|
+
data.color ? (React.createElement("div", { className: `right-first-item-wrap` },
|
|
21
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: `account.general_actions.color` }),
|
|
22
|
+
"\u00A0",
|
|
23
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 capitalize`, text: data.color }))) : data.product.short_info_1 ? (React.createElement("div", { className: `right-first-item-wrap` },
|
|
24
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1`, text: data.product.short_info_1 }))) : null,
|
|
25
|
+
data.size ? (React.createElement("div", { className: `right-second-item-wrap` },
|
|
26
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: `account.general_actions.size` }),
|
|
27
|
+
"\u00A0",
|
|
28
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: data.size }))) : data.product.short_info_2 ? (React.createElement("div", { className: `right-second-item-wrap` },
|
|
29
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1`, text: data.product.short_info_2 }))) : null)),
|
|
30
|
+
React.createElement("div", { className: `col-item tl-col-2` }, select && !data.is_gift ? (React.createElement("div", { className: `select-and-out-of-stock-wrap` }, !data.product.out_of_stock ? (React.createElement(AccountCounter, { productId: data.product.id })) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: 'account.general_actions.outOfStock' })))) : data.is_gift ? (React.createElement("div", { className: 'wrapper-gift-button' }, checkoutData.checkGift ? (React.createElement(AccountCounter, { maxQty: 1, productId: -1, isGift: data.is_gift })) : (React.createElement(AccountButton, { className: `button-gift`, text: 'account.general_actions.restore', onClick: () => {
|
|
31
|
+
setCheckGift();
|
|
32
|
+
} })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: data.qty }))),
|
|
33
|
+
React.createElement("div", { className: `col-item tl-col-3 col-item-3 nowrap` }, data.product.sale_price && !data.is_gift ? (React.createElement("div", null,
|
|
34
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 align-right cart-sale-price`, text: handlePriceCheckFunc(data.product.sale_price, currency) }),
|
|
35
|
+
React.createElement("div", { className: 'wrapper-discount' },
|
|
36
|
+
data.discount ? React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color2 discount-text` }, translate('account.order_balance.discountWithSymbol', { discount: data.discount })) : null,
|
|
37
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through value align-right cart-price1`, text: handlePriceCheckFunc(data.product.price, currency) })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 align-right cart-price2`, text: handlePriceCheckFunc(data.is_gift ? 0 : data.product.price, currency) }))),
|
|
38
|
+
React.createElement("div", { className: `col-item tl-col-4 col-item-4 nowrap` },
|
|
39
|
+
React.createElement("div", { className: `col-item-inner-wrap` },
|
|
40
|
+
React.createElement("div", { className: `flex-end-wrap` }, data.sale_total && !data.is_gift ? (React.createElement("div", null,
|
|
41
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 align-right cart-sale-total`, text: handlePriceCheckFunc(data.sale_total, currency) }),
|
|
42
|
+
React.createElement("div", { className: 'wrapper-discount' },
|
|
43
|
+
data.discount ? React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color2 discount-text` }, translate('account.order_balance.discountWithSymbol', { discount: data.discount })) : null,
|
|
44
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through value align-right cart-total1`, text: handlePriceCheckFunc(data.total, currency) })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 align-right cart-total2`, text: handlePriceCheckFunc(data.is_gift ? 0 : data.total, currency) }))),
|
|
45
|
+
React.createElement("div", { className: `favorite-and-remove-wrap` }, remove && !data.is_gift && (React.createElement("div", { className: `remove-btn-wrap` },
|
|
46
|
+
React.createElement(AccountButton, { btnType: `green-small-text`, className: 'cart-remove-btn', text: 'account.general_actions.remove', onClick: () => actions.delete({ productId: data.product.id }) }))))))),
|
|
47
|
+
isLast ? React.createElement("div", { className: 'line' }) : null));
|
|
48
|
+
});
|
|
49
|
+
export default Item;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { handlePriceCheckFunc, Image, Text, useTranslation } from '@weareconceptstudio/core';
|
|
3
|
+
import { AccountButton, AccountCounter } from '../../../../components';
|
|
4
|
+
import { useAccountContext } from '../../../../AccountProvider';
|
|
5
|
+
import { useCheckoutContext } from '../../../checkout';
|
|
6
|
+
import { defaultIconGift } from '../util';
|
|
7
|
+
const ItemMobile = memo(({ data, select }) => {
|
|
8
|
+
const { handleProductClick, currency } = useAccountContext();
|
|
9
|
+
const { translate } = useTranslation();
|
|
10
|
+
const { checkoutData, setCheckGift } = useCheckoutContext();
|
|
11
|
+
return (React.createElement(React.Fragment, null,
|
|
12
|
+
React.createElement("div", { className: `mobile-cart-item-wrap user-select-none` },
|
|
13
|
+
React.createElement("div", { className: `mobile-cart-item-inner-wrap` },
|
|
14
|
+
React.createElement("div", { className: `mobile-image-wrap` },
|
|
15
|
+
data.is_gift ? React.createElement("div", { className: 'wrapper-gift-icon' }, defaultIconGift) : null,
|
|
16
|
+
React.createElement(Image, { src: data.product.image.src, alt: data.product.image.alt })),
|
|
17
|
+
React.createElement("div", { className: `mobile-info-wrap` },
|
|
18
|
+
React.createElement(AccountButton, { text: data.product.name, btnType: `green-large-text`, className: `capitalize mobile-info-wrap-title`, onClick: () => handleProductClick(data.product) }),
|
|
19
|
+
data.color ? (React.createElement("div", { className: `mobile-info-item` },
|
|
20
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1`, text: `account.general_actions.color` }),
|
|
21
|
+
"\u00A0",
|
|
22
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 capitalize`, text: data.color }))) : data.product.short_info_1 ? (React.createElement("div", { className: 'mobile-info-item' },
|
|
23
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 mobile-short-info1`, text: data.product.short_info_1 }))) : null,
|
|
24
|
+
data.size ? (React.createElement("div", { className: `mobile-info-item` },
|
|
25
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1`, text: `account.general_actions.size` }),
|
|
26
|
+
"\u00A0",
|
|
27
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1`, text: data.size }))) : data.product.short_info_2 ? (React.createElement("div", { className: 'mobile-info-item' },
|
|
28
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 mobile-short-info2`, text: data.product.short_info_2 }))) : null,
|
|
29
|
+
React.createElement("div", { className: `mobile-total-price-wrap flex-box` },
|
|
30
|
+
data.sale_total && !data.is_gift ? (React.createElement("div", { className: 'mobile-total-price-flex-block' },
|
|
31
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-secondary-color2 mobile-total-discounted-price`, text: handlePriceCheckFunc(data.sale_total, currency) }),
|
|
32
|
+
React.createElement("div", { className: 'wrapper-discount' },
|
|
33
|
+
data.discount ? React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color2 discount-text` }, translate('account.order_balance.discountWithSymbol', { discount: data.discount })) : null,
|
|
34
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through mobile-total-price price-discount`, text: handlePriceCheckFunc(data.total, currency) })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 mobile-total-price2`, text: handlePriceCheckFunc(data.is_gift ? 0 : data.total, currency) })),
|
|
35
|
+
select ? (React.createElement("div", { className: `inner-container` }, !data.product.out_of_stock && !data.is_gift ? (React.createElement(AccountCounter, { productId: data.product.id })) : data.is_gift ? (React.createElement("div", { className: 'wrapper-gift-button' }, checkoutData.checkGift ? (React.createElement(AccountCounter, { maxQty: 1, productId: -1, isGift: data.is_gift })) : (React.createElement(AccountButton, { className: `capitalize button-gift`, text: 'account.general_actions.restore', onClick: () => {
|
|
36
|
+
setCheckGift();
|
|
37
|
+
} })))) : (React.createElement("div", { className: `in-block` },
|
|
38
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: 'account.general_actions.outOfStock' }))))) : (React.createElement("div", { className: `in-block` },
|
|
39
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 mobile-quantity-with-symbol2` },
|
|
40
|
+
translate('account.order_balance.quantity'),
|
|
41
|
+
":"),
|
|
42
|
+
"\u00A0",
|
|
43
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 mobile-quantity2`, text: data.qty }))))))),
|
|
44
|
+
React.createElement("div", { className: 'line' })));
|
|
45
|
+
});
|
|
46
|
+
export default ItemMobile;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import React, { memo,
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
2
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
3
|
//* Components
|
|
4
4
|
import Item from './Item';
|
|
5
5
|
import ItemMobile from './ItemMobile';
|
|
6
6
|
import { AccountButton } from '../../../components';
|
|
7
|
-
import { useAccountContext } from '../../../AccountProvider';
|
|
8
7
|
//* Style
|
|
9
8
|
import CartItemsStyle from './style';
|
|
10
9
|
const CartItems = memo(({ data, className, title, smallFontSize, additionalParameters, actions }) => {
|
|
11
10
|
const { winWidth } = useUi();
|
|
12
|
-
const { maxQty, currency } = useAccountContext();
|
|
13
11
|
//! Store
|
|
14
12
|
const itemsStore = useMemo(() => {
|
|
15
|
-
return winWidth >= 768 ? (React.createElement("div", { className: `
|
|
13
|
+
return winWidth >= 768 ? (React.createElement("div", { className: `cart-items-table-wrap` },
|
|
16
14
|
React.createElement("div", { className: `titles-wrap` },
|
|
17
15
|
React.createElement("div", { className: `title-wrap tl-col-1` },
|
|
18
16
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap`, text: `account.order_balance.item` })),
|
|
@@ -24,19 +22,19 @@ const CartItems = memo(({ data, className, title, smallFontSize, additionalParam
|
|
|
24
22
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap align-right`, text: `account.order_balance.total` }))),
|
|
25
23
|
React.createElement("div", { className: `items-wrap` }, data?.length > 0
|
|
26
24
|
? data.map((item, index) => {
|
|
27
|
-
return (React.createElement(Item, { key: index, data: item,
|
|
25
|
+
return (React.createElement(Item, { key: index, data: item, actions: actions, isLast: data.length - 1 == index, select: additionalParameters.select, remove: additionalParameters.remove }));
|
|
28
26
|
})
|
|
29
|
-
: null))) : (React.createElement("div", { className: `mobile-
|
|
27
|
+
: null))) : (React.createElement("div", { className: `mobile-cart-items-table-wrap` }, data?.length > 0
|
|
30
28
|
? data.map((item, index) => {
|
|
31
|
-
return (React.createElement(ItemMobile, { key: index, data: item,
|
|
29
|
+
return (React.createElement(ItemMobile, { key: index, data: item, select: additionalParameters.select }));
|
|
32
30
|
})
|
|
33
31
|
: null));
|
|
34
|
-
}, [winWidth, data, additionalParameters,
|
|
32
|
+
}, [winWidth, data, additionalParameters, actions]);
|
|
35
33
|
return (React.createElement(CartItemsStyle, { className: className || '' },
|
|
36
34
|
additionalParameters.edit.list ? (React.createElement("div", { className: `title-edit-wrapper` },
|
|
37
35
|
React.createElement(Text, { className: `account-p ${smallFontSize ? 'account-p2' : 'account-p1'} account-font-bold account-primary-color1 cart-items-title2-version`, text: title }),
|
|
38
36
|
React.createElement(AccountButton, { url: '/cart/', btnType: `green-small-text`, className: 'cart-items-edit-btn', text: `account.cart_checkout.editCart` }))) : (React.createElement(Text, { className: `account-p ${smallFontSize ? 'account-p2' : 'account-p1'} account-font-bold account-primary-color1 cart-items-title1-version`, text: title })),
|
|
39
|
-
additionalParameters.horizontalLine ? React.createElement("div", { className: `
|
|
37
|
+
additionalParameters.horizontalLine ? React.createElement("div", { className: `cart-items-line` }) : null,
|
|
40
38
|
itemsStore));
|
|
41
39
|
});
|
|
42
40
|
export default CartItems;
|