@weareconceptstudio/account 0.6.3 → 0.6.4
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/modules/cart/CartItems/Item/index.js +1 -3
- package/dist/modules/cart/CartItems/ItemMobile/index.js +1 -3
- package/dist/modules/cart/CartProvider.d.ts +1 -0
- package/dist/modules/cart/CartProvider.js +18 -2
- package/dist/modules/checkout/ThankYouTemplate/index.js +2 -2
- package/dist/modules/order/OrderedItems/ItemMobile/index.js +1 -3
- package/package.json +1 -1
|
@@ -48,9 +48,7 @@ const Item = memo(({ data, remove, select, isLast, actions, isCheckout }) => {
|
|
|
48
48
|
React.createElement("div", { className: `flex-end-wrap` }, (data.sale_total || data.product.discount) && !data.is_gift ? (React.createElement("div", null,
|
|
49
49
|
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) }),
|
|
50
50
|
React.createElement("div", { className: 'wrapper-discount' },
|
|
51
|
-
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` }, data.
|
|
52
|
-
handlePriceCheckFunc(0, currency),
|
|
53
|
-
React.createElement("span", { className: 'gift-name-text' }, data.appliedPromotion.name))) : (handlePriceCheckFunc(data.total, currency))))),
|
|
51
|
+
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` }, handlePriceCheckFunc(data.total, currency)))),
|
|
54
52
|
React.createElement("div", { className: `favorite-and-remove-wrap` }, remove && !data.is_gift && (React.createElement("div", { className: `remove-btn-wrap` },
|
|
55
53
|
React.createElement(AccountButton, { btnType: `green-small-text`, className: 'cart-remove-btn', text: 'account.general_actions.remove', onClick: () => actions.delete({ productId: data.product.id }) }))))))),
|
|
56
54
|
isLast ? React.createElement("div", { className: 'line' }) : null)) : null;
|
|
@@ -35,9 +35,7 @@ const ItemMobile = memo(({ data, select, isCheckout }) => {
|
|
|
35
35
|
data.product.discount.type === 'percentage' ? '%' : ` ${currency}`,
|
|
36
36
|
"\u00A0",
|
|
37
37
|
React.createElement("span", { className: 'lowercase' }, translate('account.order_balance.discount')))) : null,
|
|
38
|
-
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` }, data.
|
|
39
|
-
handlePriceCheckFunc(0, currency),
|
|
40
|
-
React.createElement("span", { className: 'gift-name-text' }, data.appliedPromotion.name))) : (handlePriceCheckFunc(data.total, currency)))),
|
|
38
|
+
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` }, handlePriceCheckFunc(data.total, currency))),
|
|
41
39
|
select && !data.is_gift ? (React.createElement("div", { className: `inner-container` }, !data.product.out_of_stock ? (React.createElement(AccountCounter, { productId: data.product.id })) : (React.createElement("div", { className: `in-block` },
|
|
42
40
|
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: 'account.general_actions.outOfStock' }))))) : data.is_gift && !isCheckout ? (React.createElement("div", { className: 'wrapper-gift-button' }, checkoutData.gifts.find((item) => item.promotionId == data.appliedPromotion.id && item.productId == data.product.id)?.qty !== 0 ? (React.createElement(AccountCounter, { maxQty: data?.qty, productId: data.product.id, promotionId: data.appliedPromotion.id, isGift: data.is_gift, qty: checkoutData.gifts.find((item) => item.promotionId == data.appliedPromotion.id && item.productId == data.product.id)?.qty })) : (React.createElement(AccountButton, { className: `capitalize button-gift`, text: 'account.general_actions.restore', onClick: () => setGifts({ promotionId: data.appliedPromotion.id, productId: data.product.id, qty: data?.qty }) })))) : (React.createElement("div", { className: `in-block` },
|
|
43
41
|
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 mobile-quantity-with-symbol2` },
|
|
@@ -42,6 +42,7 @@ interface CartContextType extends CartState {
|
|
|
42
42
|
productId: number;
|
|
43
43
|
}) => Promise<void>;
|
|
44
44
|
clearCart: () => Promise<void>;
|
|
45
|
+
resetCart: () => void;
|
|
45
46
|
reorder: (orderId: number) => Promise<void>;
|
|
46
47
|
mergeCart: () => Promise<void>;
|
|
47
48
|
checkoutData: CheckoutData;
|
|
@@ -120,8 +120,22 @@ export const CartProvider = ({ useUser, children }) => {
|
|
|
120
120
|
setResourceDecorator(data);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
|
|
123
|
+
// TODO: check this
|
|
124
|
+
const resetCart = async () => {
|
|
124
125
|
sessionStorage.clear();
|
|
126
|
+
removeCookie('cart');
|
|
127
|
+
setCheckoutData({
|
|
128
|
+
addressId: null,
|
|
129
|
+
useBalance: null,
|
|
130
|
+
note: '',
|
|
131
|
+
paymentType: user?.payment_method || 'cash_on_delivery',
|
|
132
|
+
gifts: [],
|
|
133
|
+
card_id: null,
|
|
134
|
+
excludedPromotions: [],
|
|
135
|
+
promotion_code: null
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const clearCart = async () => {
|
|
125
139
|
if (isLoggedIn) {
|
|
126
140
|
const { data } = await api.post('clear-cart');
|
|
127
141
|
setResourceDecorator(data);
|
|
@@ -214,7 +228,7 @@ export const CartProvider = ({ useUser, children }) => {
|
|
|
214
228
|
const handleCheckout = async () => {
|
|
215
229
|
let data = cleanObject({ ...checkoutData });
|
|
216
230
|
//! Check gift
|
|
217
|
-
if (!data.gifts
|
|
231
|
+
if (!data.gifts?.length)
|
|
218
232
|
delete data.gifts;
|
|
219
233
|
if (isNumeric(checkoutData.paymentType)) {
|
|
220
234
|
data.paymentType = 'credit_card';
|
|
@@ -224,6 +238,7 @@ export const CartProvider = ({ useUser, children }) => {
|
|
|
224
238
|
data.card_id = 0;
|
|
225
239
|
}
|
|
226
240
|
return await api.post('checkout', data).then((res) => {
|
|
241
|
+
resetCart();
|
|
227
242
|
if (res.redirect_url) {
|
|
228
243
|
window.location.href = res.redirect_url;
|
|
229
244
|
}
|
|
@@ -253,6 +268,7 @@ export const CartProvider = ({ useUser, children }) => {
|
|
|
253
268
|
clearCart,
|
|
254
269
|
reorder,
|
|
255
270
|
mergeCart,
|
|
271
|
+
resetCart,
|
|
256
272
|
setCheckoutData,
|
|
257
273
|
fillCheckoutData,
|
|
258
274
|
handleCheckout,
|
|
@@ -11,9 +11,9 @@ import { useCart } from '../../cart';
|
|
|
11
11
|
const ThankYouTemplate = ({ orderNumber, thankIcon }) => {
|
|
12
12
|
const { shopUrl } = useAccountContext();
|
|
13
13
|
const { translate } = useTranslation();
|
|
14
|
-
const {
|
|
14
|
+
const { resetCart } = useCart();
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
|
|
16
|
+
resetCart();
|
|
17
17
|
}, []);
|
|
18
18
|
return (React.createElement(Page, { className: 'thank-you-message use-account' },
|
|
19
19
|
React.createElement(ThankYouMessageStyle, null,
|
|
@@ -47,8 +47,6 @@ const ItemMobile = memo(({ data }) => {
|
|
|
47
47
|
data.sale_total && !data.is_gift ? (React.createElement(React.Fragment, null,
|
|
48
48
|
React.createElement(Text, { className: `account-p account-p3 account-font-medium account-secondary-color2 sale-total`, text: handlePriceCheckFunc(data.sale_total, currency) }),
|
|
49
49
|
React.createElement("div", { className: 'wrapper-discount' },
|
|
50
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through total1`, text: handlePriceCheckFunc(data.total, currency) })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 total2
|
|
51
|
-
handlePriceCheckFunc(0, currency),
|
|
52
|
-
React.createElement("span", { className: 'gift-name-text' }, data?.appliedPromotion?.name || 'Karlen'))) : (handlePriceCheckFunc(data.total, currency)))))))));
|
|
50
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through total1`, text: handlePriceCheckFunc(data.total, currency) })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1 total2` }, handlePriceCheckFunc(data.total, currency))))))));
|
|
53
51
|
});
|
|
54
52
|
export default ItemMobile;
|