@weareconceptstudio/account 0.0.6 → 0.0.8
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/AccountProvider.d.ts +4 -1
- package/dist/AccountProvider.js +9 -7
- package/dist/components/EmptyOrders/index.js +7 -6
- package/dist/components/EmptyOrders/style.js +1 -1
- package/dist/components/OrderDetails/index.js +1 -1
- package/dist/components/OrderedItems/index.d.ts +1 -1
- package/dist/components/OrderedItems/index.js +4 -37
- package/dist/components/OrdersList/OrderItem/index.js +1 -1
- package/dist/components/OrdersList/index.js +1 -1
- package/dist/components/TotalCheckout/index.js +0 -1
- package/dist/components/cart/Items/Simple/Item/index.js +6 -14
- package/dist/components/cart/Items/Simple/ItemMobile/index.js +3 -16
- package/dist/components/cart/Items/Simple/index.js +3 -3
- package/dist/components/index.d.ts +0 -6
- package/dist/components/index.js +0 -6
- package/dist/components/ui/AccountButton/style.js +3 -1
- package/dist/components/ui/WarningMessageForPopup/index.js +7 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/modules/address/AddressForm/index.js +44 -0
- package/dist/{components → modules/address}/AddressItem/index.d.ts +2 -4
- package/dist/{components → modules/address}/AddressItem/index.js +13 -13
- package/dist/modules/address/AddressProvider.d.ts +7 -0
- package/dist/modules/address/AddressProvider.js +57 -0
- package/dist/{components → modules/address}/AddressWrap/index.d.ts +3 -2
- package/dist/{components → modules/address}/AddressWrap/index.js +7 -7
- package/dist/modules/address/AddressesTemplate/index.d.ts +3 -0
- package/dist/modules/address/AddressesTemplate/index.js +11 -0
- package/dist/modules/address/SelectAddress/index.d.ts +6 -0
- package/dist/modules/address/SelectAddress/index.js +22 -0
- package/dist/modules/address/SelectAddress/style.d.ts +2 -0
- package/dist/modules/address/SelectAddress/style.js +68 -0
- package/dist/modules/address/SelectShippingBilling/index.d.ts +3 -0
- package/dist/modules/address/SelectShippingBilling/index.js +29 -0
- package/dist/modules/address/SelectShippingBillingPopup/index.d.ts +3 -0
- package/dist/modules/address/SelectShippingBillingPopup/index.js +25 -0
- package/dist/{components/SelectShippingBilling → modules/address/SelectShippingBillingPopup}/style.js +0 -43
- package/dist/modules/address/ShippingBillingForm/index.js +15 -0
- package/dist/modules/address/index.d.ts +9 -0
- package/dist/modules/address/index.js +9 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/templates/AccountSettingsTemplate/AccountInfo/index.js +1 -1
- package/dist/templates/AccountTemplate/style.js +1 -1
- package/dist/templates/CartTemplate/index.d.ts +1 -2
- package/dist/templates/CartTemplate/index.js +6 -5
- package/dist/templates/CheckoutTemplate/StepReview/index.d.ts +3 -0
- package/dist/templates/CheckoutTemplate/StepReview/index.js +8 -0
- package/dist/templates/CheckoutTemplate/StepShipping/index.d.ts +5 -0
- package/dist/templates/CheckoutTemplate/StepShipping/index.js +9 -0
- package/dist/templates/CheckoutTemplate/index.d.ts +2 -2
- package/dist/templates/CheckoutTemplate/index.js +30 -149
- package/dist/templates/CheckoutTemplate/style.js +9 -9
- package/dist/templates/ForgotPasswordTemplate/style.js +2 -2
- package/dist/templates/OrderIndividualTemplate/index.js +1 -1
- package/dist/templates/ResetPasswordTemplate/style.js +1 -1
- package/dist/templates/SignInTemplate/style.js +2 -2
- package/dist/templates/index.d.ts +0 -1
- package/dist/templates/index.js +0 -1
- package/dist/translations/en.d.ts +72 -133
- package/dist/translations/en.js +84 -133
- package/dist/translations/hy.d.ts +6 -0
- package/dist/translations/hy.js +6 -0
- package/dist/translations/index.d.ts +84 -133
- package/dist/translations/ru.d.ts +6 -0
- package/dist/translations/ru.js +6 -0
- package/dist/utils/_functions.d.ts +0 -3
- package/dist/utils/_functions.js +0 -10
- package/package.json +1 -1
- package/dist/components/AddressForm/index.js +0 -102
- package/dist/components/FavoriteButton/index.d.ts +0 -3
- package/dist/components/FavoriteButton/index.js +0 -42
- package/dist/components/OrderedItems/ReviewPopup/index.d.ts +0 -0
- package/dist/components/OrderedItems/ReviewPopup/index.js +0 -202
- package/dist/components/OrderedItems/ReviewPopup/style.d.ts +0 -2
- package/dist/components/OrderedItems/ReviewPopup/style.js +0 -329
- package/dist/components/SelectShippingBilling/index.d.ts +0 -3
- package/dist/components/SelectShippingBilling/index.js +0 -31
- package/dist/components/ShippingBillingForm/index.js +0 -96
- package/dist/templates/AddressesTemplate/index.d.ts +0 -6
- package/dist/templates/AddressesTemplate/index.js +0 -9
- /package/dist/{components → modules/address}/AddressForm/index.d.ts +0 -0
- /package/dist/{components → modules/address}/AddressForm/style.d.ts +0 -0
- /package/dist/{components → modules/address}/AddressForm/style.js +0 -0
- /package/dist/{components → modules/address}/AddressItem/style.d.ts +0 -0
- /package/dist/{components → modules/address}/AddressItem/style.js +0 -0
- /package/dist/{templates → modules/address}/AddressesTemplate/style.d.ts +0 -0
- /package/dist/{templates → modules/address}/AddressesTemplate/style.js +0 -0
- /package/dist/{components → modules/address}/EmptyAddress/index.d.ts +0 -0
- /package/dist/{components → modules/address}/EmptyAddress/index.js +0 -0
- /package/dist/{components/SelectShippingBilling → modules/address/SelectShippingBillingPopup}/style.d.ts +0 -0
- /package/dist/{components → modules/address}/ShippingBillingForm/index.d.ts +0 -0
- /package/dist/{components → modules/address}/ShippingBillingForm/style.d.ts +0 -0
- /package/dist/{components → modules/address}/ShippingBillingForm/style.js +0 -0
- /package/dist/{components → modules/address}/ShippingBillingInfo/index.d.ts +0 -0
- /package/dist/{components → modules/address}/ShippingBillingInfo/index.js +0 -0
- /package/dist/{components → modules/address}/ShippingBillingInfo/style.d.ts +0 -0
- /package/dist/{components → modules/address}/ShippingBillingInfo/style.js +0 -0
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export function useAccountContext(): any;
|
|
2
|
-
export function AccountProvider({ fontFamily, children, maxQty, currency }: {
|
|
2
|
+
export function AccountProvider({ fontFamily, shopUrl, children, maxQty, currency, addressType, addressFormFields }: {
|
|
3
3
|
fontFamily?: string;
|
|
4
|
+
shopUrl?: string;
|
|
4
5
|
children: any;
|
|
5
6
|
maxQty?: number;
|
|
6
7
|
currency: any;
|
|
8
|
+
addressType: any;
|
|
9
|
+
addressFormFields: any;
|
|
7
10
|
}): React.JSX.Element;
|
|
8
11
|
import React from 'react';
|
package/dist/AccountProvider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect } from 'react';
|
|
2
2
|
import { useTranslation } from '@weareconceptstudio/core';
|
|
3
3
|
import { ThemeProvider } from 'styled-components';
|
|
4
|
+
import { AddressProvider } from './modules/address/AddressProvider';
|
|
4
5
|
//* Translations
|
|
5
6
|
import translations from './translations';
|
|
6
7
|
//* Styles
|
|
@@ -13,15 +14,16 @@ export const useAccountContext = () => {
|
|
|
13
14
|
const context = useContext(AccountContext);
|
|
14
15
|
return context;
|
|
15
16
|
};
|
|
16
|
-
export const AccountProvider = ({ fontFamily = 'core_Font', children, maxQty = 99, currency }) => {
|
|
17
|
+
export const AccountProvider = ({ fontFamily = 'core_Font', shopUrl = '/', children, maxQty = 99, currency, addressType, addressFormFields }) => {
|
|
17
18
|
const { addTranslation } = useTranslation();
|
|
18
19
|
useEffect(() => {
|
|
19
20
|
addTranslation(translations, 'prepend');
|
|
20
21
|
}, []);
|
|
21
|
-
return (React.createElement(AccountContext.Provider, { value: { currency, maxQty } },
|
|
22
|
-
React.createElement(
|
|
23
|
-
React.createElement(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
return (React.createElement(AccountContext.Provider, { value: { currency, maxQty, shopUrl } },
|
|
23
|
+
React.createElement(AddressProvider, { addressType: addressType, addressFormFields: addressFormFields },
|
|
24
|
+
React.createElement(ThemeProvider, { theme: theme },
|
|
25
|
+
React.createElement(AccountVariables, { fontFamily: fontFamily }),
|
|
26
|
+
React.createElement(AccountHelperClass, null),
|
|
27
|
+
React.createElement(AccountTypography, null),
|
|
28
|
+
children))));
|
|
27
29
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { memo as Memo } from 'react';
|
|
2
|
+
import { useAccountContext } from '../../AccountProvider';
|
|
2
3
|
import { Text } from '@weareconceptstudio/core';
|
|
3
|
-
//* Style
|
|
4
|
-
import EmptyOrdersStyle from './style';
|
|
5
|
-
//* Components
|
|
6
4
|
import AccountButton from '../ui/AccountButton';
|
|
5
|
+
import EmptyOrdersStyle from './style';
|
|
7
6
|
const EmptyOrders = Memo(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
React.createElement(Text, { className: `account-
|
|
7
|
+
const { shopUrl } = useAccountContext();
|
|
8
|
+
return (React.createElement(EmptyOrdersStyle, { className: 'empty-orders' },
|
|
9
|
+
React.createElement(Text, { tag: `h6`, className: `account-h6 account-font-bold account-primary-color1 empty-orders-title`, text: `emptyTitle` }),
|
|
10
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 empty-orders-description`, text: `emptyDesc` }),
|
|
11
|
+
React.createElement(AccountButton, { text: `shopNow`, btnType: 'purple-text', url: shopUrl })));
|
|
11
12
|
});
|
|
12
13
|
export default EmptyOrders;
|
|
@@ -13,7 +13,7 @@ const OrderDetails = memo(({ className, status, order_date, delivery_date, order
|
|
|
13
13
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1` },
|
|
14
14
|
translate('orderStatus'),
|
|
15
15
|
":"),
|
|
16
|
-
status === 'delivered' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item value`, text: 'delivered' })) : status === 'canceled' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item value`, text: 'canceled' })) : (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item value`, text: 'inProgress' }))),
|
|
16
|
+
status === 'delivered' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item value delivered`, text: 'delivered' })) : status === 'canceled' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item value canceled`, text: 'canceled' })) : (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item value in-progress`, text: 'inProgress' }))),
|
|
17
17
|
React.createElement("div", { className: `order-detail-item-wrap` },
|
|
18
18
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1` },
|
|
19
19
|
translate('orderDate'),
|
|
@@ -1,46 +1,13 @@
|
|
|
1
|
-
import React, { useMemo
|
|
2
|
-
import { Image, Text,
|
|
3
|
-
// import SwiperCore, { Navigation } from 'swiper';
|
|
4
|
-
// import { Swiper, SwiperSlide } from 'swiper/react';
|
|
5
|
-
// SwiperCore.use([Navigation]);
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Image, Text, useUi } from '@weareconceptstudio/core';
|
|
6
3
|
//* Utils
|
|
7
4
|
import { handlePriceCheckFunc } from '../../utils/_functions';
|
|
8
5
|
//* Components
|
|
9
|
-
// import OldEditor from '../OldEditor';
|
|
10
|
-
// import ReviewPopup from './ReviewPopup';
|
|
11
|
-
// import ImagesPopup from '../ImagesPopup';
|
|
12
6
|
import AccountButton from '../ui/AccountButton';
|
|
13
7
|
//* Styles
|
|
14
|
-
// import 'swiper/swiper-bundle.css';
|
|
15
8
|
import OrderedItemsStyle from './style';
|
|
16
|
-
const OrderedItems = ({ data, status, currency }) => {
|
|
17
|
-
const {
|
|
18
|
-
const { winWidth, openPopup } = useUi();
|
|
19
|
-
const createReview = () => { };
|
|
20
|
-
const updateReview = () => { };
|
|
21
|
-
//! State
|
|
22
|
-
const [items, setItems] = useState(data);
|
|
23
|
-
//! Handle Review update
|
|
24
|
-
const addOrUpdateReview = useCallback((id, newValues) => {
|
|
25
|
-
setItems(items.map((item) => (item.id == id ? { ...item, review: newValues } : item)));
|
|
26
|
-
}, [items]);
|
|
27
|
-
//! Review popup
|
|
28
|
-
// const handleReviewPopup = useCallback(
|
|
29
|
-
// ({ orderItemId, product, review }) => {
|
|
30
|
-
// return openPopup(
|
|
31
|
-
// <ReviewPopup
|
|
32
|
-
// review={review}
|
|
33
|
-
// product={product}
|
|
34
|
-
// orderItemId={orderItemId}
|
|
35
|
-
// createReview={createReview}
|
|
36
|
-
// updateReview={updateReview}
|
|
37
|
-
// addOrUpdateReview={addOrUpdateReview}
|
|
38
|
-
// />,
|
|
39
|
-
// { className: 'is-review-popup' }
|
|
40
|
-
// );
|
|
41
|
-
// },
|
|
42
|
-
// [addOrUpdateReview]
|
|
43
|
-
// );
|
|
9
|
+
const OrderedItems = ({ data: items, status, currency }) => {
|
|
10
|
+
const { winWidth } = useUi();
|
|
44
11
|
//! Store order items
|
|
45
12
|
const storeOrderedItems = useMemo(() => {
|
|
46
13
|
return items.map((item, index) => winWidth >= 768 ? (React.createElement("div", { key: index, className: `item-wrap` },
|
|
@@ -12,7 +12,7 @@ const OrderItem = Memo(({ data }) => {
|
|
|
12
12
|
React.createElement(Text, { className: `account-p account-p4 account-font-medium account-primary-color1`, text: data.total_items })),
|
|
13
13
|
React.createElement("div", { className: `col-item od-col-3 nowrap` },
|
|
14
14
|
React.createElement(Text, { className: `account-p account-p4 account-font-medium account-primary-color1`, text: `ID ${data.order_number}` })),
|
|
15
|
-
React.createElement("div", { className: `col-item od-col-4 nowrap` }, data.status === 'delivered' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item`, text: 'delivered' })) : data.status === 'canceled' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item`, text: 'canceled' })) : (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item`, text: 'inProgress' }))),
|
|
15
|
+
React.createElement("div", { className: `col-item od-col-4 nowrap` }, data.status === 'delivered' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item delivered`, text: 'delivered' })) : data.status === 'canceled' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item canceled`, text: 'canceled' })) : (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item in-progress`, text: 'inProgress' }))),
|
|
16
16
|
React.createElement("div", { className: `col-item od-col-5 nowrap` },
|
|
17
17
|
React.createElement(Text, { className: `account-p account-p4 account-font-medium account-primary-color1`, text: handlePriceCheckFunc(data.total_price, data.currency) })),
|
|
18
18
|
React.createElement("div", { className: `col-item od-col-6 nowrap` },
|
|
@@ -45,7 +45,7 @@ const OrdersList = ({ data, total, pageSize, router, pathname, searchParams }) =
|
|
|
45
45
|
React.createElement("div", { className: `left-item-wrap last` },
|
|
46
46
|
React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1`, text: `${translate('orderNumber')}:` }),
|
|
47
47
|
React.createElement(Text, { className: `account-p account-p4 account-font-regular account-primary-color1 value`, text: `ID ${item.order_number}` }))),
|
|
48
|
-
React.createElement("div", { className: `right-wrap` }, item.status === 'delivered' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item`, text: 'delivered' })) : item.status === 'canceled' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item`, text: 'canceled' })) : (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item`, text: 'inProgress' })))),
|
|
48
|
+
React.createElement("div", { className: `right-wrap` }, item.status === 'delivered' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-primary-color1 account-primary-color5-bg status-item delivered`, text: 'delivered' })) : item.status === 'canceled' ? (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-error-color account-secondary-color7-bg status-item canceled`, text: 'canceled' })) : (React.createElement(Text, { className: `account-p account-p4 account-font-bold account-secondary-color1 account-secondary-color8-bg status-item in-progress`, text: 'inProgress' })))),
|
|
49
49
|
React.createElement("div", { className: `last-col-wrap` },
|
|
50
50
|
React.createElement("div", { className: `left-wrap` },
|
|
51
51
|
React.createElement("div", { className: `left-item-wrap` },
|
|
@@ -16,7 +16,6 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
setHeaderHeight(document.getElementsByTagName('header')[0]?.clientHeight);
|
|
18
18
|
}, [winWidth]);
|
|
19
|
-
console.log(shippingCost);
|
|
20
19
|
return (React.createElement(TotalCheckoutStyle, { "$headerHeight": headerHeight },
|
|
21
20
|
React.createElement("div", { className: `cart-main-wrap` },
|
|
22
21
|
React.createElement("div", { className: `left-panel-wrap panel` }, children),
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import React, { memo, useMemo } from 'react';
|
|
2
|
-
import { Image, Text
|
|
2
|
+
import { Image, Text } from '@weareconceptstudio/core';
|
|
3
3
|
import { Select } from '@weareconceptstudio/form';
|
|
4
4
|
import { useAccountContext } from '../../../../../AccountProvider';
|
|
5
5
|
import { handlePriceCheckFunc } from '../../../../../utils/_functions';
|
|
6
6
|
import Button from '../../../../ui/AccountButton';
|
|
7
|
-
import FavoriteButton from '../../../../FavoriteButton';
|
|
8
7
|
const pathname = '/cart/';
|
|
9
|
-
const Item = memo(({ data,
|
|
10
|
-
const { openPopup } = useUi();
|
|
8
|
+
const Item = memo(({ data, remove, select, isLast, actions }) => {
|
|
11
9
|
const { currency, maxQty } = useAccountContext();
|
|
12
10
|
const selectionList = useMemo(() => {
|
|
13
11
|
if (select) {
|
|
14
12
|
const selectList = [];
|
|
15
13
|
for (let index = 1; index <= maxQty; index++) {
|
|
16
|
-
selectList.push({
|
|
14
|
+
selectList.push({ id: index, name: index });
|
|
17
15
|
}
|
|
18
16
|
return selectList;
|
|
19
17
|
}
|
|
@@ -29,9 +27,7 @@ const Item = memo(({ data, edit, favorite, remove, select, isLast, favorites, ac
|
|
|
29
27
|
React.createElement("div", { className: `right-first-item-wrap` },
|
|
30
28
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 capitalize`, text: data.product.short_info_1 })),
|
|
31
29
|
React.createElement("div", { className: `right-second-item-wrap` },
|
|
32
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1`, text: data.product.short_info_2 })),
|
|
33
|
-
edit && !data.product?.out_of_stock ? (React.createElement("div", { className: `edit-btn-wrap empty` },
|
|
34
|
-
React.createElement(Button, { text: 'edit', btnType: `green-small-text`, onClick: () => openPopup(React.createElement("div", null, "Product Individual")) }))) : pathname === '/cart/' ? (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color3 underline opacityZero empty`, text: 'empty' })) : (''))),
|
|
30
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1`, text: data.product.short_info_2 })))),
|
|
35
31
|
React.createElement("div", { className: `col-item tl-col-2` }, select ? (React.createElement("div", { className: `select-and-out-of-stock-wrap` }, !data.product?.out_of_stock ? (React.createElement(Select, { allowSearch: false, options: selectionList, value: data.qty, onChange: (val) => actions.add({
|
|
36
32
|
productId: data.product.id,
|
|
37
33
|
qty: val,
|
|
@@ -39,17 +35,13 @@ const Item = memo(({ data, edit, favorite, remove, select, isLast, favorites, ac
|
|
|
39
35
|
React.createElement("div", { className: `col-item tl-col-3 col-item-3 nowrap` }, data?.product?.sale_price ? (React.createElement("div", null,
|
|
40
36
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 alignRight`, text: handlePriceCheckFunc(data?.product?.sale_price, currency) }),
|
|
41
37
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through value align-right`, text: handlePriceCheckFunc(data.product?.price, currency) }))) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 alignRight`, text: handlePriceCheckFunc(data.product?.price, currency) }))),
|
|
42
|
-
console.log(data.total),
|
|
43
38
|
React.createElement("div", { className: `col-item tl-col-4 col-item-4 nowrap` },
|
|
44
39
|
React.createElement("div", { className: `col-item-inner-wrap` },
|
|
45
40
|
React.createElement("div", { className: `flex-end-wrap` }, data?.product.sale_price ? (React.createElement("div", null,
|
|
46
41
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 align-right`, text: `${data.sale_total} ${currency}` }),
|
|
47
42
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color2 line-through value align-right`, text: handlePriceCheckFunc(data.product?.price * data.qty, currency) }))) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 align-right`, text: `${data.total} ${currency}` }))),
|
|
48
|
-
React.createElement("div", { className: `favorite-and-remove-wrap` },
|
|
49
|
-
|
|
50
|
-
React.createElement(FavoriteButton, { qty: data.qty, type: `withText`, favorites: favorites, productId: data.product?.id, optionId: data.selectedOption?.id, variantId: data.selectedVariant?.id }))),
|
|
51
|
-
remove && (React.createElement("div", { className: `remove-btn-wrap` },
|
|
52
|
-
React.createElement(Button, { text: 'remove', btnType: `green-small-text`, onClick: () => actions.delete({ productId: data.product?.id }) }))))))),
|
|
43
|
+
React.createElement("div", { className: `favorite-and-remove-wrap` }, remove && (React.createElement("div", { className: `remove-btn-wrap` },
|
|
44
|
+
React.createElement(Button, { text: 'remove', btnType: `green-small-text`, onClick: () => actions.delete({ productId: data.product?.id }) }))))))),
|
|
53
45
|
isLast ? React.createElement("div", { className: 'line' }) : null));
|
|
54
46
|
});
|
|
55
47
|
export default Item;
|
|
@@ -3,23 +3,20 @@ import { Image, Text, useUi } from '@weareconceptstudio/core';
|
|
|
3
3
|
import { Select } from '@weareconceptstudio/form';
|
|
4
4
|
import Button from '../../../../ui/AccountButton';
|
|
5
5
|
import { useAccountContext } from '../../../../../AccountProvider';
|
|
6
|
-
//* Utils
|
|
7
6
|
import { handlePriceCheckFunc } from '../../../../../utils/_functions';
|
|
8
|
-
//* Components
|
|
9
|
-
import FavoriteButton from '../../../../FavoriteButton';
|
|
10
7
|
// import ProductIndividual from '@/components/common/ProductIndividual';
|
|
11
8
|
//TODO: Fake
|
|
12
9
|
const pathname = '/cart/';
|
|
13
10
|
const addToCart = () => { };
|
|
14
11
|
const removeCart = () => { };
|
|
15
|
-
const ItemMobile = memo(({ data, additionalParameters, isLast
|
|
12
|
+
const ItemMobile = memo(({ data, additionalParameters, isLast }) => {
|
|
16
13
|
const { openPopup } = useUi();
|
|
17
14
|
const { currency } = useAccountContext();
|
|
18
15
|
const selectionList = useMemo(() => {
|
|
19
16
|
if (additionalParameters.select) {
|
|
20
17
|
const selectList = [];
|
|
21
18
|
for (let index = 1; index <= data.qty; index++) {
|
|
22
|
-
selectList.push({
|
|
19
|
+
selectList.push({ id: index, name: index });
|
|
23
20
|
}
|
|
24
21
|
return selectList;
|
|
25
22
|
}
|
|
@@ -39,7 +36,7 @@ const ItemMobile = memo(({ data, additionalParameters, isLast, favorites }) => {
|
|
|
39
36
|
// className={`quantity-select-mobile-wrap`}
|
|
40
37
|
// onChange={(val) => addToCart({ productId: data.product.id, variantId: data.selectedVariant.id, optionId: data.selectedOption.id, qty: val, update: true })}
|
|
41
38
|
// />
|
|
42
|
-
React.createElement(Select, { allowSearch: false, options: selectionList, value: 1, onChange: (
|
|
39
|
+
React.createElement(Select, { allowSearch: false, options: selectionList, value: 1, onChange: () => { } })) : (React.createElement("div", { className: `mobile-info-item` },
|
|
43
40
|
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1`, text: `quantityWithSymbol` }),
|
|
44
41
|
"\u00A0",
|
|
45
42
|
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1`, text: data.qty }))))) : (React.createElement("div", { className: `mobile-info-item` },
|
|
@@ -57,16 +54,6 @@ const ItemMobile = memo(({ data, additionalParameters, isLast, favorites }) => {
|
|
|
57
54
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold secondaryColor2`, text: handlePriceCheckFunc(data.product?.discountedPrice * data.qty, currency) }),
|
|
58
55
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular primaryColor2 lineThrough`, text: handlePriceCheckFunc(data.product?.price * data.qty, currency) }))) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold primaryColor1`, text: handlePriceCheckFunc(data.product?.price * data.qty || data.total, currency || currency) }))))),
|
|
59
56
|
pathname === '/cart/' && (React.createElement("div", { className: `edit-remove-favorite-mobile-wrap` },
|
|
60
|
-
additionalParameters.edit.item && !data.product?.out_of_stock ? (React.createElement(Button, { text: 'edit', btnType: `green-small-text`, onClick: () => openPopup(
|
|
61
|
-
// <ProductIndividual
|
|
62
|
-
// isPopup
|
|
63
|
-
// qty={data.qty}
|
|
64
|
-
// itemId={data.id}
|
|
65
|
-
// selectedOption={data.selectedOption}
|
|
66
|
-
// selectedVariant={data.selectedVariant}
|
|
67
|
-
// {...data.product}
|
|
68
|
-
// />
|
|
69
|
-
React.createElement("div", null, "Product Individual")) })) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold primaryColor3 underline opacityZero empty`, text: 'empty' })),
|
|
70
57
|
React.createElement("div", { className: `favorite-remove-mobile-wrap` }, additionalParameters.remove && (React.createElement(Button, { text: 'remove', btnType: `green-small-text`, onClick: () => removeCart({ productId: data.product.id, variantId: data.selectedVariant.id, optionId: data.selectedOption.id }) })))))),
|
|
71
58
|
React.createElement("div", { className: 'line' })));
|
|
72
59
|
});
|
|
@@ -5,7 +5,7 @@ import Item from './Item';
|
|
|
5
5
|
import ItemMobile from './ItemMobile';
|
|
6
6
|
//* Style
|
|
7
7
|
import CartItemsStyle from './style';
|
|
8
|
-
const CartItems = memo(({ data, className, title, smallFontSize, additionalParameters, currency, isLast,
|
|
8
|
+
const CartItems = memo(({ data, className, title, smallFontSize, additionalParameters, currency, isLast, actions }) => {
|
|
9
9
|
const { winWidth } = useUi();
|
|
10
10
|
//! Store
|
|
11
11
|
const orderStore = useMemo(() => {
|
|
@@ -20,9 +20,9 @@ const CartItems = memo(({ data, className, title, smallFontSize, additionalParam
|
|
|
20
20
|
React.createElement("div", { className: `title-wrap tl-col-4 title-item` },
|
|
21
21
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap alignRight`, text: `total` }))),
|
|
22
22
|
React.createElement("div", { className: `items-wrap` }, data?.map((item, index) => {
|
|
23
|
-
return (React.createElement(Item, { key: index, data: item, currency: currency,
|
|
23
|
+
return (React.createElement(Item, { key: index, data: item, currency: currency, isLast: data.length - 1 == index, select: additionalParameters.select, remove: additionalParameters.remove, edit: additionalParameters.edit.item, actions: actions }));
|
|
24
24
|
})))) : (React.createElement("div", { className: `mobile-order-items-table-wrap` }, data?.map((item, index) => {
|
|
25
|
-
return (React.createElement(ItemMobile, { key: index, data: item, isLast: isLast, currency: currency,
|
|
25
|
+
return (React.createElement(ItemMobile, { key: index, data: item, isLast: isLast, currency: currency, additionalParameters: additionalParameters }));
|
|
26
26
|
})));
|
|
27
27
|
}, [winWidth, data, additionalParameters, currency]);
|
|
28
28
|
return (React.createElement(CartItemsStyle, { className: className || '' },
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
export * from './ui';
|
|
2
2
|
export * from './cart';
|
|
3
3
|
export { default as FormInputCode } from './FormInputCode';
|
|
4
|
-
export { default as AddressWrap } from './AddressWrap';
|
|
5
|
-
export { default as AddressForm } from './AddressForm';
|
|
6
|
-
export { default as AddressItem } from './AddressItem';
|
|
7
4
|
export { default as TotalCheckout } from './TotalCheckout';
|
|
8
5
|
export { default as EmptyOrders } from './EmptyOrders';
|
|
9
6
|
export { default as OrderDetails } from './OrderDetails';
|
|
10
7
|
export { default as OrderedItems } from './OrderedItems';
|
|
11
8
|
export { default as OrdersList } from './OrdersList';
|
|
12
|
-
export { default as ShippingBillingInfo } from './ShippingBillingInfo';
|
|
13
|
-
export { default as ShippingBillingForm } from './ShippingBillingForm';
|
|
14
|
-
export { default as SelectShippingBilling } from './SelectShippingBilling';
|
package/dist/components/index.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
export * from './ui';
|
|
2
2
|
export * from './cart';
|
|
3
3
|
export { default as FormInputCode } from './FormInputCode';
|
|
4
|
-
export { default as AddressWrap } from './AddressWrap';
|
|
5
|
-
export { default as AddressForm } from './AddressForm';
|
|
6
|
-
export { default as AddressItem } from './AddressItem';
|
|
7
4
|
export { default as TotalCheckout } from './TotalCheckout';
|
|
8
5
|
export { default as EmptyOrders } from './EmptyOrders';
|
|
9
6
|
export { default as OrderDetails } from './OrderDetails';
|
|
10
7
|
export { default as OrderedItems } from './OrderedItems';
|
|
11
8
|
export { default as OrdersList } from './OrdersList';
|
|
12
|
-
export { default as ShippingBillingInfo } from './ShippingBillingInfo';
|
|
13
|
-
export { default as ShippingBillingForm } from './ShippingBillingForm';
|
|
14
|
-
export { default as SelectShippingBilling } from './SelectShippingBilling';
|
|
@@ -25,7 +25,9 @@ const AccountButtonStyle = styled.div `
|
|
|
25
25
|
border: 2px solid var(--account_primaryColor14);
|
|
26
26
|
color: var(--account_backgroundColor);
|
|
27
27
|
border-radius: var(--account_btnBorderRad);
|
|
28
|
-
transition:
|
|
28
|
+
transition:
|
|
29
|
+
background-color var(--account_trTime) ease-out,
|
|
30
|
+
border var(--account_trTime) ease-out;
|
|
29
31
|
display: inline-flex;
|
|
30
32
|
justify-content: center;
|
|
31
33
|
align-items: center;
|
|
@@ -9,12 +9,12 @@ import AccountButton from '../AccountButton';
|
|
|
9
9
|
const WarningMessageForPopup = React.memo(({ isDelete = false, isThankYou = false, onRemove, title, description, globalData }) => {
|
|
10
10
|
const { closePopup } = useUi();
|
|
11
11
|
const globalTheme = useTheme();
|
|
12
|
-
return (React.createElement(WarningMessageForPopupStyle, { theme: theme(globalTheme) },
|
|
13
|
-
React.createElement(Text, { tag: `h6`, className: `account-h6 account-font-bold account-primary-color1`, text: title }),
|
|
12
|
+
return (React.createElement(WarningMessageForPopupStyle, { className: 'warning-message-block', theme: theme(globalTheme) },
|
|
13
|
+
React.createElement(Text, { tag: `h6`, className: `account-h6 account-font-bold account-primary-color1 warning-message-title`, text: title }),
|
|
14
14
|
React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 confirm-delete-address-text`, text: description }),
|
|
15
|
-
React.createElement("div", { className: `cancel-remove-wrap ${!isDelete
|
|
16
|
-
React.createElement(AccountButton, { btnType: `green-large-text`,
|
|
17
|
-
React.createElement(AccountButton, { text: `remove`, btnType: `full-width`, onClick: () => {
|
|
15
|
+
React.createElement("div", { className: `cancel-remove-wrap ${!isDelete ? 'mobile-margin' : ''}` }, isDelete ? (React.createElement(React.Fragment, null,
|
|
16
|
+
React.createElement(AccountButton, { text: `cancel`, onClick: closePopup, btnType: `green-large-text`, className: 'warning-message-popup-close' }),
|
|
17
|
+
React.createElement(AccountButton, { text: `remove`, btnType: `full-width`, className: 'warning-message-popup-remove', onClick: () => {
|
|
18
18
|
onRemove();
|
|
19
19
|
closePopup();
|
|
20
20
|
} }))) : isThankYou ? (
|
|
@@ -24,8 +24,9 @@ const WarningMessageForPopup = React.memo(({ isDelete = false, isThankYou = fals
|
|
|
24
24
|
// btnType={`full-width`}
|
|
25
25
|
// text={`continueToShop`}
|
|
26
26
|
// url={globalData?.menu_bar[0]?.slug}
|
|
27
|
+
// className={'warning-message-popup-continue'}
|
|
27
28
|
// />
|
|
28
29
|
// ) : null
|
|
29
|
-
React.createElement("div", null, "Global Data")) : (React.createElement(AccountButton, { text: `done`, btnType: `full-width`,
|
|
30
|
+
React.createElement("div", null, "Global Data")) : (React.createElement(AccountButton, { text: `done`, onClick: closePopup, btnType: `full-width`, className: 'warning-message-popup-done' })))));
|
|
30
31
|
});
|
|
31
32
|
export default WarningMessageForPopup;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { memo as Memo, useState, useCallback } from 'react';
|
|
2
|
+
import { useUi, Text } from '@weareconceptstudio/core';
|
|
3
|
+
import { FormBuilder } from '@weareconceptstudio/form';
|
|
4
|
+
import AccountButton from '../../../components/ui/AccountButton';
|
|
5
|
+
import { useTheme } from 'styled-components';
|
|
6
|
+
import theme from '../../../styles/theme';
|
|
7
|
+
//* Icons
|
|
8
|
+
import { CheckboxIcon, CheckboxCheckedIcon } from '../../../utils/icons';
|
|
9
|
+
//* Style
|
|
10
|
+
import AddressFormStyle from './style';
|
|
11
|
+
const AddressForm = Memo(({ title, data, formFields, type, createAddress, updateAddress }) => {
|
|
12
|
+
const globalTheme = useTheme();
|
|
13
|
+
const { closePopup } = useUi();
|
|
14
|
+
//! States
|
|
15
|
+
const [isChecked, setIsChecked] = useState(data?.is_default || false);
|
|
16
|
+
const [isDisabled, setIsDisabled] = useState(false);
|
|
17
|
+
//! On Finish
|
|
18
|
+
const onFinish = useCallback((values) => {
|
|
19
|
+
const newData = {
|
|
20
|
+
...values,
|
|
21
|
+
is_default: isChecked,
|
|
22
|
+
type,
|
|
23
|
+
};
|
|
24
|
+
setIsDisabled(true);
|
|
25
|
+
return (!isDisabled &&
|
|
26
|
+
eval(data?.id ? `updateAddress(newData, data.id)` : `createAddress(newData)`).then(() => {
|
|
27
|
+
closePopup();
|
|
28
|
+
}));
|
|
29
|
+
}, [data, isChecked, createAddress, updateAddress, isDisabled]);
|
|
30
|
+
return (React.createElement(AddressFormStyle, { theme: theme(globalTheme), className: 'address-form-block' },
|
|
31
|
+
React.createElement(Text, { tag: `h6`, text: title, className: `account-h6 account-font-bold account-primary-color1 address-form-block-title` }),
|
|
32
|
+
React.createElement(FormBuilder, { formOptions: {
|
|
33
|
+
initialValues: data,
|
|
34
|
+
}, onSubmit: onFinish, fields: formFields, className: 'form-wrapper' },
|
|
35
|
+
React.createElement("div", { className: `default-info-wrap` }, !data?.is_default ? (React.createElement("div", { className: `banner-wrap cursor-pointer`, onClick: () => setIsChecked(!isChecked) },
|
|
36
|
+
isChecked ? (React.createElement("div", { className: 'checkbox-wrap', role: 'button' },
|
|
37
|
+
React.createElement(CheckboxCheckedIcon, null))) : (React.createElement("div", { className: 'checkbox-wrap', role: 'button' },
|
|
38
|
+
React.createElement(CheckboxIcon, null))),
|
|
39
|
+
React.createElement(Text, { className: `account-p account-p2 account-font-medium account-primary-color1 address-form-is-default-checkbox`, text: `${type === 'shipping' ? 'makeYourDefaultShippingAddress' : type == 'billing' ? 'makeYourDefaultBillingAddress' : 'makeYourDefaultAddress'}` }))) : (React.createElement(Text, { className: `account-p account-p2 account-font-medium account-primary-color1 address-form-is-default`, text: `${type === 'shipping' ? 'thisYourDefaultShippingAddress' : type == 'billing' ? 'thisYourDefaultBillingAddress' : 'thisYourDefaultAddress'}` }))),
|
|
40
|
+
React.createElement("div", { className: `cancel-and-save-wrap` },
|
|
41
|
+
React.createElement(AccountButton, { text: `cancel`, onClick: closePopup, btnType: `green-large-text`, className: `address-form-cancel-btn` }),
|
|
42
|
+
React.createElement(AccountButton, { type: 'submit', text: `saveAndApply`, btnType: `full-width`, className: `address-form-cancel-submit ${isDisabled ? 'disabled' : ''}` })))));
|
|
43
|
+
});
|
|
44
|
+
export default AddressForm;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
export default AddressItem;
|
|
2
|
-
declare function AddressItem({ title, data, checkout_review, select_address,
|
|
2
|
+
declare function AddressItem({ type, title, data, checkout_review, select_address, onClick }: {
|
|
3
|
+
type: any;
|
|
3
4
|
title: any;
|
|
4
5
|
data: any;
|
|
5
6
|
checkout_review: any;
|
|
6
7
|
select_address: any;
|
|
7
|
-
type: any;
|
|
8
8
|
onClick: any;
|
|
9
|
-
checkedId: any;
|
|
10
|
-
setCheckedId: any;
|
|
11
9
|
}): React.JSX.Element;
|
|
12
10
|
import React from 'react';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
|
+
import { useAddressContext } from '../AddressProvider';
|
|
3
4
|
//* Components
|
|
4
5
|
import AddressForm from '../AddressForm';
|
|
5
|
-
import AccountButton from '
|
|
6
|
-
import WarningMessageForPopup from '
|
|
6
|
+
import AccountButton from '../../../components/ui/AccountButton';
|
|
7
|
+
import WarningMessageForPopup from '../../../components/ui/WarningMessageForPopup';
|
|
7
8
|
//* Style
|
|
8
9
|
import AddressItemStyle from './style';
|
|
9
|
-
const AddressItem = ({ title, data, checkout_review, select_address,
|
|
10
|
+
const AddressItem = ({ type, title, data, checkout_review, select_address, onClick }) => {
|
|
10
11
|
const { openPopup } = useUi();
|
|
12
|
+
const { formFields, createAddress, updateAddress, deleteAddress, selectedAddresses, setSelectedAddresses } = useAddressContext();
|
|
11
13
|
//! Handle Popups
|
|
12
14
|
const handleDeletePopup = useCallback(() => {
|
|
13
15
|
openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteAddressMessage', description: 'confirmDeleteAddress', onRemove: () => deleteAddress(data.id, data.type) }), { className: 'messagePopup' });
|
|
14
16
|
}, [data]);
|
|
15
17
|
const handleEditAddressPopup = useCallback(() => {
|
|
16
|
-
openPopup(React.createElement(AddressForm, {
|
|
18
|
+
openPopup(React.createElement(AddressForm, { title: type === 'billing' ? `updateYourBillingAddress` : type == 'shipping' ? `updateYourShippingAddress` : 'updateYourAddress', data: data, formFields: formFields, createAddress: createAddress, updateAddress: updateAddress }));
|
|
17
19
|
}, [data]);
|
|
18
|
-
//TODO:
|
|
19
|
-
const deleteAddress = () => { };
|
|
20
20
|
return (data && (React.createElement(AddressItemStyle, { className: `item-container` },
|
|
21
21
|
checkout_review && (React.createElement("div", { className: `change-address-wrap` },
|
|
22
22
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1`, text: title }),
|
|
@@ -26,16 +26,16 @@ const AddressItem = ({ title, data, checkout_review, select_address, type, onCli
|
|
|
26
26
|
React.createElement("div", { className: `personal-data-wrap` },
|
|
27
27
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1`, text: `${data.first_name} ${data.last_name}` }),
|
|
28
28
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 col-wrap`, text: `${data.address_1}, ${data.address_2 ? data.address_2 + ',' : ''}` }),
|
|
29
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1`, text: `${data.
|
|
30
|
-
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 phone col-wrap`, text: `${data.
|
|
31
|
-
data.is_default ? (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 margin-style`, text: `${type === 'shipping' ? 'defaultShippingAddress' : 'defaultBillingAddress'}` })) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 margin-style opacity-zero`, text: `empty` })),
|
|
32
|
-
select_address && (React.createElement("div", { className: `circle-selected-wrap cursor-pointer ${
|
|
33
|
-
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${
|
|
29
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1`, text: `${data.city}` }),
|
|
30
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 phone col-wrap`, text: `${data.phone}` })),
|
|
31
|
+
data.is_default ? (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 margin-style is-default`, text: `${type === 'shipping' ? 'defaultShippingAddress' : type == 'billing' ? 'defaultBillingAddress' : 'defaultAddress'}` })) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 margin-style opacity-zero`, text: `empty` })),
|
|
32
|
+
select_address && (React.createElement("div", { className: `circle-selected-wrap cursor-pointer ${selectedAddresses?.id === data.id ? 'active' : ''}`, onClick: () => setSelectedAddresses(data) },
|
|
33
|
+
React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', className: `checkbox-icon ${selectedAddresses?.id === data.id ? 'selected' : 'note-selected'}` },
|
|
34
34
|
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' }))))),
|
|
35
35
|
!checkout_review && (React.createElement("div", { className: `edit-remove-wrapper` },
|
|
36
|
-
React.createElement(AccountButton, { text: `edit`, btnType: `green-small-text`, onClick: handleEditAddressPopup }),
|
|
36
|
+
React.createElement(AccountButton, { text: `edit`, btnType: `green-small-text`, onClick: handleEditAddressPopup, className: 'btn-one-address-version' }),
|
|
37
37
|
!select_address && !data.is_default && (React.createElement(React.Fragment, null,
|
|
38
38
|
React.createElement("div", { className: `vertical-line` }),
|
|
39
|
-
React.createElement(AccountButton, { text: `remove`, btnType: `green-small-text`,
|
|
39
|
+
React.createElement(AccountButton, { text: `remove`, onClick: handleDeletePopup, btnType: `green-small-text`, className: 'btn-more-address-version' })))))))));
|
|
40
40
|
};
|
|
41
41
|
export default AddressItem;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { api } from '@weareconceptstudio/core';
|
|
3
|
+
const AddressContext = createContext(null);
|
|
4
|
+
export const useAddressContext = () => {
|
|
5
|
+
const context = useContext(AddressContext);
|
|
6
|
+
return context;
|
|
7
|
+
};
|
|
8
|
+
export const AddressProvider = ({ addressType, addressFormFields = [], children }) => {
|
|
9
|
+
const [addresses, setAddresses] = useState(addressType ? { billing: [], shipping: [] } : []);
|
|
10
|
+
const [selectedAddresses, setSelectedAddresses] = useState(addressType ? { billing: {}, shipping: {} } : {});
|
|
11
|
+
const hasAddressType = useMemo(() => {
|
|
12
|
+
return !!addressType;
|
|
13
|
+
}, [addressType]);
|
|
14
|
+
const hasCheckoutAddress = useMemo(() => {
|
|
15
|
+
if (hasAddressType) {
|
|
16
|
+
return !(addresses.shipping.length > 0 && addresses.billing.length > 0);
|
|
17
|
+
}
|
|
18
|
+
return !(addresses.length > 0);
|
|
19
|
+
}, [hasAddressType, addresses]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
api.get({ url: 'addresses' }).then((res) => {
|
|
22
|
+
setAddresses(res.data);
|
|
23
|
+
setSelectedAddresses(addressType
|
|
24
|
+
? {
|
|
25
|
+
shipping: res.data[0],
|
|
26
|
+
billing: res.data[0],
|
|
27
|
+
}
|
|
28
|
+
: res.data[0]);
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
const createAddress = async (data) => {
|
|
32
|
+
return await api.post('addresses', data).then((res) => {
|
|
33
|
+
setAddresses(res.data);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const updateAddress = async (data, addressId) => {
|
|
37
|
+
return await api.put(`addresses/${addressId}`, data).then((res) => {
|
|
38
|
+
setAddresses(res.data);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const deleteAddress = async (addressId) => {
|
|
42
|
+
return await api.delete(`addresses/${addressId}`).then((res) => {
|
|
43
|
+
setAddresses(res.data);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return (React.createElement(AddressContext.Provider, { value: {
|
|
47
|
+
hasAddressType,
|
|
48
|
+
formFields: addressFormFields,
|
|
49
|
+
createAddress,
|
|
50
|
+
updateAddress,
|
|
51
|
+
deleteAddress,
|
|
52
|
+
addresses,
|
|
53
|
+
selectedAddresses,
|
|
54
|
+
setSelectedAddresses,
|
|
55
|
+
hasCheckoutAddress,
|
|
56
|
+
} }, children));
|
|
57
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default AddressWrap;
|
|
2
|
-
declare function AddressWrap({ title,
|
|
2
|
+
declare function AddressWrap({ title, addNewText, type, className }: {
|
|
3
3
|
title?: string;
|
|
4
|
-
|
|
4
|
+
addNewText?: string;
|
|
5
|
+
type: any;
|
|
5
6
|
className: any;
|
|
6
7
|
}): React.JSX.Element;
|
|
7
8
|
import React from 'react';
|