@weareconceptstudio/account 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TotalCheckout/PromoCodeComp/index.d.ts +3 -2
- package/dist/components/TotalCheckout/PromoCodeComp/index.js +6 -6
- package/dist/components/TotalCheckout/index.js +8 -4
- package/dist/modules/cart/EmptyCart/index.js +1 -2
- package/dist/styles/typography.js +6 -0
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default PromoCodeComp;
|
|
2
|
-
declare function PromoCodeComp({ isPromoCode,
|
|
2
|
+
declare function PromoCodeComp({ isPromoCode, promoCodeHandler, usePromoCode, getItemCount }: {
|
|
3
3
|
isPromoCode?: boolean;
|
|
4
|
-
|
|
4
|
+
promoCodeHandler: any;
|
|
5
|
+
usePromoCode: any;
|
|
5
6
|
getItemCount: any;
|
|
6
7
|
}): React.JSX.Element;
|
|
7
8
|
import React from 'react';
|
|
@@ -5,14 +5,14 @@ import AccountButton from '../../AccountButton';
|
|
|
5
5
|
import { promoCodeFields } from './utils';
|
|
6
6
|
//* Style
|
|
7
7
|
import PromoCodeCompStyle from './style';
|
|
8
|
-
const PromoCodeComp = ({ isPromoCode = true,
|
|
8
|
+
const PromoCodeComp = ({ isPromoCode = true, promoCodeHandler, usePromoCode, getItemCount }) => {
|
|
9
9
|
//! States
|
|
10
10
|
const [couponCode, setCouponCode] = useState(false);
|
|
11
11
|
const [disable, setDisable] = useState(false);
|
|
12
12
|
//! On Finish
|
|
13
|
-
const onFinish = () => {
|
|
14
|
-
setCouponCode(true);
|
|
13
|
+
const onFinish = (values) => {
|
|
15
14
|
setDisable(true);
|
|
15
|
+
promoCodeHandler(values.promo_code);
|
|
16
16
|
};
|
|
17
17
|
return isPromoCode ? (React.createElement(PromoCodeCompStyle, { className: `collapse-distance ${getItemCount ? '' : 'disable'}` },
|
|
18
18
|
React.createElement(CollapseItem, { disable: disable, title: React.createElement(React.Fragment, null,
|
|
@@ -20,10 +20,10 @@ const PromoCodeComp = ({ isPromoCode = true, promo_code, getItemCount }) => {
|
|
|
20
20
|
React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '12', height: '12', viewBox: '0 0 12 12', fill: 'none' },
|
|
21
21
|
React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
|
|
22
22
|
React.createElement("path", { d: 'M6 12L6 0', stroke: 'black', strokeWidth: '2' }))),
|
|
23
|
-
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium promo-code-text', text: 'gotPromotionCode' })), description: React.createElement(React.Fragment, null,
|
|
24
|
-
React.createElement(Text, { className: 'account-p account-p4 account-primary-color2 account-font-medium promo-code-success-text' },
|
|
23
|
+
React.createElement(Text, { className: 'account-p account-p4 account-primary-color1 account-font-medium promo-code-text', text: 'gotPromotionCode' })), description: React.createElement(React.Fragment, null, usePromoCode ? (React.createElement("div", { className: `promo-code-success-block` },
|
|
24
|
+
React.createElement(Text, { className: 'account-p account-p4 account-primary-color2 account-font-medium promo-code-success-text' }, usePromoCode),
|
|
25
25
|
React.createElement(Text, { text: 'remove', className: 'account-p account-p4 account-primary-color2 account-font-medium promo-code-remove-text', onClick: () => {
|
|
26
|
-
|
|
26
|
+
promoCodeHandler(null);
|
|
27
27
|
setDisable(false);
|
|
28
28
|
} }))) : (React.createElement(FormBuilder, { onSubmit: onFinish, fields: promoCodeFields, className: `promo-code-block`, formOptions: {
|
|
29
29
|
className: 'promo-code-container',
|
|
@@ -11,17 +11,18 @@ import CommentComp from './CommentComp';
|
|
|
11
11
|
import TotalCheckoutStyle from './style';
|
|
12
12
|
//* Skeleton
|
|
13
13
|
import SkeletonTotalCheckout from './Skeleton';
|
|
14
|
-
// TODO: Promo code
|
|
15
|
-
const promo_code = '10% of first order';
|
|
16
14
|
const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps }) => {
|
|
17
15
|
const { currency, useCart, useUser } = useAccountContext();
|
|
18
16
|
const { fillCheckoutData, fillCart, checkoutBtnDisabled, isCheckoutPage } = useCheckoutContext();
|
|
19
17
|
const { addressLoading } = useAddressContext();
|
|
20
18
|
const { user } = useUser();
|
|
21
|
-
const { itemsCount, shippingCost, freeShippingRange, shippingCostValue, total, subtotal, useBalance, loading } = useCart();
|
|
19
|
+
const { itemsCount, shippingCost, freeShippingRange, shippingCostValue, total, subtotal, useBalance, loading, usePromoCode, discountTotal } = useCart();
|
|
22
20
|
const handleBalance = (amount) => {
|
|
23
21
|
fillCart('useBalance', amount);
|
|
24
22
|
};
|
|
23
|
+
const handlePromoCode = (code) => {
|
|
24
|
+
fillCart('promoCode', code);
|
|
25
|
+
};
|
|
25
26
|
const innerCollapseRef = useRef(null);
|
|
26
27
|
//! disable keypress on input
|
|
27
28
|
useEffect(() => {
|
|
@@ -67,6 +68,9 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
67
68
|
user && useBalance ? (React.createElement("div", { className: `od-item-wrap` },
|
|
68
69
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `muramoney` }),
|
|
69
70
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(useBalance, currency)}` }))) : null,
|
|
71
|
+
user && discountTotal ? (React.createElement("div", { className: `od-item-wrap` },
|
|
72
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `discount` }),
|
|
73
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(discountTotal, currency)}` }))) : null,
|
|
70
74
|
React.createElement("div", { className: `od-item-wrap` },
|
|
71
75
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-total`, text: `total` }),
|
|
72
76
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-currency2`, text: itemsCount ? handlePriceCheckFunc(total, currency) : `0 ${currency}` })),
|
|
@@ -74,7 +78,7 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
74
78
|
React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
|
|
75
79
|
React.createElement("div", { ref: innerCollapseRef },
|
|
76
80
|
React.createElement(BalanceComp, { getItemCount: itemsCount, balance: user?.balance || 0, currency: currency, balanceHandler: handleBalance, useBalance: useBalance }),
|
|
77
|
-
React.createElement(PromoCodeComp, { getItemCount: itemsCount,
|
|
81
|
+
React.createElement(PromoCodeComp, { getItemCount: itemsCount, promoCodeHandler: handlePromoCode, usePromoCode: usePromoCode }))),
|
|
78
82
|
isCheckoutPage && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, { fillCheckoutData: fillCheckoutData }) : null,
|
|
79
83
|
React.createElement(AccountButton, { loading: buttonProps.loadingButton, url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, className: `sticky-wrap-btn`, disabled: checkoutBtnDisabled, onClick: () => buttonProps.handleClick && buttonProps.handleClick() }))) : (React.createElement(SkeletonTotalCheckout, null))))));
|
|
80
84
|
});
|
|
@@ -5,10 +5,9 @@ import { AccountButton } from '../../../components';
|
|
|
5
5
|
import EmptyCartStyle from './style';
|
|
6
6
|
import { emptyCartIconDefault } from './icons';
|
|
7
7
|
const EmptyCart = ({ shoppingUrl, emptyCartIcon }) => {
|
|
8
|
-
console.log(emptyCartIcon);
|
|
9
8
|
return (React.createElement(EmptyCartStyle, null,
|
|
10
9
|
React.createElement("div", { className: `empty-cart-wrap` },
|
|
11
|
-
emptyCartIcon
|
|
10
|
+
emptyCartIcon || React.createElement("div", { className: 'wrapper-icon' }, emptyCartIconDefault),
|
|
12
11
|
React.createElement(Text, { tag: `h4`, className: `account-h6 account-font-bold account-primary-color1 empty-cart-title`, text: `cartEmpty` }),
|
|
13
12
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 empty-cart-description`, text: `cartEmptyDesc` }),
|
|
14
13
|
shoppingUrl ? (React.createElement(AccountButton, { text: `shopNow`, url: shoppingUrl, btnType: 'purple-text', className: 'empty-cart-btn' })) : null)));
|