@weareconceptstudio/account 0.4.8 → 0.4.9
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/AppliedPromotion/index.d.ts +5 -0
- package/dist/components/TotalCheckout/PromoCodeComp/AppliedPromotion/index.js +11 -0
- package/dist/components/TotalCheckout/PromoCodeComp/index.d.ts +2 -1
- package/dist/components/TotalCheckout/PromoCodeComp/index.js +14 -11
- package/dist/components/TotalCheckout/index.js +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from '@weareconceptstudio/core';
|
|
3
|
+
const AppliedPromotion = ({ name }) => {
|
|
4
|
+
return (React.createElement("div", { className: `promo-code-success-block` },
|
|
5
|
+
React.createElement(Text, { className: 'account-p account-p4 account-primary-color2 account-font-medium promo-code-success-text' }, name),
|
|
6
|
+
React.createElement(Text, { text: 'account.general_actions.remove', className: 'account-p account-p4 account-primary-color2 account-font-medium promo-code-remove-text', onClick: () => {
|
|
7
|
+
// promotionHandler(null);
|
|
8
|
+
// setDisable(false);
|
|
9
|
+
} })));
|
|
10
|
+
};
|
|
11
|
+
export default AppliedPromotion;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export default PromoCodeComp;
|
|
2
|
-
declare function PromoCodeComp({ isPromoCode, promotionHandler, usePromotion, getItemCount }: {
|
|
2
|
+
declare function PromoCodeComp({ isPromoCode, promotionHandler, usePromotion, getItemCount, appliedPromotions }: {
|
|
3
3
|
isPromoCode?: boolean;
|
|
4
4
|
promotionHandler: any;
|
|
5
5
|
usePromotion: any;
|
|
6
6
|
getItemCount: any;
|
|
7
|
+
appliedPromotions: any;
|
|
7
8
|
}): React.JSX.Element;
|
|
8
9
|
import React from 'react';
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Text, CollapseItem } from '@weareconceptstudio/core';
|
|
3
3
|
import { FormBuilder } from '@weareconceptstudio/form';
|
|
4
4
|
import AccountButton from '../../AccountButton';
|
|
5
|
+
import AppliedPromotion from './AppliedPromotion';
|
|
5
6
|
import { promoCodeFields } from './utils';
|
|
6
7
|
//* Style
|
|
7
8
|
import PromoCodeCompStyle from './style';
|
|
8
|
-
const PromoCodeComp = ({ isPromoCode = true, promotionHandler, usePromotion, getItemCount }) => {
|
|
9
|
+
const PromoCodeComp = ({ isPromoCode = true, promotionHandler, usePromotion, getItemCount, appliedPromotions }) => {
|
|
9
10
|
//! States
|
|
10
|
-
const [couponCode, setCouponCode] = useState(false);
|
|
11
11
|
const [disable, setDisable] = useState(false);
|
|
12
12
|
//! On Finish
|
|
13
13
|
const onFinish = (values) => {
|
|
14
14
|
setDisable(true);
|
|
15
15
|
promotionHandler(values.promo_code);
|
|
16
16
|
};
|
|
17
|
+
const promotions = useMemo(() => {
|
|
18
|
+
return appliedPromotions.map((promotion) => React.createElement(AppliedPromotion, { ...promotion }));
|
|
19
|
+
}, [appliedPromotions]);
|
|
17
20
|
return isPromoCode ? (React.createElement(PromoCodeCompStyle, { className: `collapse-distance ${getItemCount ? '' : 'disable'}` },
|
|
18
|
-
React.createElement(CollapseItem, { disable: disable, title: React.createElement(React.Fragment, null,
|
|
21
|
+
React.createElement(CollapseItem, { status: appliedPromotions.length ? 'open' : 'closed', disable: disable, title: React.createElement(React.Fragment, null,
|
|
19
22
|
React.createElement("div", { className: 'inner-wrapper-icon' },
|
|
20
23
|
React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '12', height: '12', viewBox: '0 0 12 12', fill: 'none' },
|
|
21
24
|
React.createElement("path", { d: 'M0 6H12', stroke: 'black', strokeWidth: '2' }),
|
|
22
25
|
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: 'account.balance_promotions.gotPromotionCode' })), description: React.createElement(React.Fragment, null,
|
|
24
|
-
|
|
25
|
-
React.createElement(
|
|
26
|
+
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,
|
|
27
|
+
promotions,
|
|
28
|
+
usePromotion ? (React.createElement(AppliedPromotion, { name: usePromotion, onClick: () => {
|
|
26
29
|
promotionHandler(null);
|
|
27
30
|
setDisable(false);
|
|
28
|
-
} }))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
} })) : (React.createElement(FormBuilder, { onSubmit: onFinish, fields: promoCodeFields, className: `promo-code-block`, formOptions: {
|
|
32
|
+
className: 'promo-code-container',
|
|
33
|
+
} },
|
|
34
|
+
React.createElement(AccountButton, { text: `account.general_actions.add`, type: 'submit', btnType: `promo-code-version` })))) }))) : null;
|
|
32
35
|
};
|
|
33
36
|
export default PromoCodeComp;
|
|
@@ -16,7 +16,7 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
16
16
|
const { fillCheckoutData, fillCart, checkoutBtnDisabled, isCheckoutPage } = useCheckoutContext();
|
|
17
17
|
const { addressLoading } = useAddressContext();
|
|
18
18
|
const { user } = useUser();
|
|
19
|
-
const { itemsCount, shippingCost, freeShippingRange, shippingCostValue, total, subtotal, useBalance, loading, usePromotion, discount } = useCart();
|
|
19
|
+
const { itemsCount, shippingCost, freeShippingRange, shippingCostValue, total, subtotal, useBalance, loading, usePromotion, discount, appliedPromotions } = useCart();
|
|
20
20
|
const handleBalance = (amount) => {
|
|
21
21
|
fillCart('useBalance', amount);
|
|
22
22
|
};
|
|
@@ -62,15 +62,15 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
62
62
|
React.createElement("div", { className: `od-item-wrap` },
|
|
63
63
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-subtotal`, text: `account.cart_checkout.subtotal` }),
|
|
64
64
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-currency`, text: itemsCount ? handlePriceCheckFunc(subtotal, currency) : `0 ${currency}` })),
|
|
65
|
-
React.createElement("div", { className: `od-item-wrap` },
|
|
66
|
-
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-shipping`, text: `account.address_management.shipping` }),
|
|
67
|
-
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-shipping-cost`, text: `${String(shippingCost).toLowerCase() === 'free' || shippingCost === '-' ? shippingCost : `${numToLocalString(shippingCost)} ${currency}`}` })),
|
|
68
65
|
user && useBalance ? (React.createElement("div", { className: `od-item-wrap` },
|
|
69
66
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `account.balance_promotions.muramoney` }),
|
|
70
67
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(useBalance, currency)}` }))) : null,
|
|
71
68
|
user && discount ? (React.createElement("div", { className: `od-item-wrap` },
|
|
72
69
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1`, text: `account.order_balance.discount` }),
|
|
73
70
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 balance-text-block`, text: `-${handlePriceCheckFunc(discount, currency)}` }))) : null,
|
|
71
|
+
React.createElement("div", { className: `od-item-wrap` },
|
|
72
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-shipping`, text: `account.address_management.shipping` }),
|
|
73
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 sticky-wrap-shipping-cost`, text: `${String(shippingCost).toLowerCase() === 'free' || shippingCost === '-' ? shippingCost : `${numToLocalString(shippingCost)} ${currency}`}` })),
|
|
74
74
|
React.createElement("div", { className: `od-item-wrap` },
|
|
75
75
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-total`, text: `account.order_balance.total` }),
|
|
76
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}` })),
|
|
@@ -78,7 +78,7 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps })
|
|
|
78
78
|
React.createElement(CollapseContainer, { className: 'collapse-container-wrapper' },
|
|
79
79
|
React.createElement("div", { ref: innerCollapseRef },
|
|
80
80
|
React.createElement(BalanceComp, { getItemCount: itemsCount, balance: user?.balance || 0, currency: currency, balanceHandler: handleBalance, useBalance: useBalance }),
|
|
81
|
-
React.createElement(PromoCodeComp, { getItemCount: itemsCount, promotionHandler: handlePromotion, usePromotion: usePromotion }))),
|
|
81
|
+
React.createElement(PromoCodeComp, { getItemCount: itemsCount, promotionHandler: handlePromotion, usePromotion: usePromotion, appliedPromotions: appliedPromotions }))),
|
|
82
82
|
isCheckoutPage && typeof isShipping === 'boolean' && !isShipping ? React.createElement(CommentComp, { fillCheckoutData: fillCheckoutData }) : null,
|
|
83
83
|
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))))));
|
|
84
84
|
});
|