@weareconceptstudio/account 0.0.7 → 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 +5 -4
- package/dist/components/OrderedItems/index.d.ts +1 -1
- package/dist/components/OrderedItems/index.js +4 -37
- package/dist/components/cart/Items/Simple/Item/index.js +6 -13
- package/dist/components/cart/Items/Simple/ItemMobile/index.js +2 -15
- 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/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 +11 -11
- 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/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/OrderIndividualTemplate/index.js +1 -1
- 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 -99
- 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(() => {
|
|
7
|
+
const { shopUrl } = useAccountContext();
|
|
8
8
|
return (React.createElement(EmptyOrdersStyle, { className: 'empty-orders' },
|
|
9
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` })
|
|
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;
|
|
@@ -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` },
|
|
@@ -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,
|
|
@@ -44,11 +40,8 @@ const Item = memo(({ data, edit, favorite, remove, select, isLast, favorites, ac
|
|
|
44
40
|
React.createElement("div", { className: `flex-end-wrap` }, data?.product.sale_price ? (React.createElement("div", null,
|
|
45
41
|
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 align-right`, text: `${data.sale_total} ${currency}` }),
|
|
46
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}` }))),
|
|
47
|
-
React.createElement("div", { className: `favorite-and-remove-wrap` },
|
|
48
|
-
|
|
49
|
-
React.createElement(FavoriteButton, { qty: data.qty, type: `withText`, favorites: favorites, productId: data.product?.id, optionId: data.selectedOption?.id, variantId: data.selectedVariant?.id }))),
|
|
50
|
-
remove && (React.createElement("div", { className: `remove-btn-wrap` },
|
|
51
|
-
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 }) }))))))),
|
|
52
45
|
isLast ? React.createElement("div", { className: 'line' }) : null));
|
|
53
46
|
});
|
|
54
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
|
}
|
|
@@ -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';
|
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,11 +26,11 @@ 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 is-default`, 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
36
|
React.createElement(AccountButton, { text: `edit`, btnType: `green-small-text`, onClick: handleEditAddressPopup, className: 'btn-one-address-version' }),
|
|
@@ -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';
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
+
import { useAddressContext } from '../AddressProvider';
|
|
3
4
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
4
|
-
import AccountButton from '
|
|
5
|
+
import AccountButton from '../../../components/ui/AccountButton';
|
|
5
6
|
import EmptyAddress from '../EmptyAddress';
|
|
6
7
|
import AddressItem from '../AddressItem';
|
|
7
8
|
import AddressForm from '../AddressForm';
|
|
8
|
-
const AddressWrap = ({ title = 'addresses',
|
|
9
|
+
const AddressWrap = ({ title = 'addresses', addNewText = 'addNewAdd', type, className }) => {
|
|
9
10
|
const { openPopup } = useUi();
|
|
11
|
+
const { formFields, createAddress, updateAddress, addresses } = useAddressContext();
|
|
10
12
|
const classString = classNames('address-wrap', {
|
|
11
13
|
[className]: className,
|
|
12
14
|
});
|
|
13
15
|
const handleAddNewAddressPopup = () => {
|
|
14
|
-
openPopup(React.createElement(AddressForm,
|
|
16
|
+
openPopup(React.createElement(AddressForm, { type: type, title: 'addNewAddress', formFields: formFields, createAddress: createAddress, updateAddress: updateAddress }));
|
|
15
17
|
};
|
|
16
18
|
return (React.createElement("div", { className: classString },
|
|
17
19
|
React.createElement("div", { className: `address-title-container` },
|
|
18
20
|
React.createElement(Text, { className: `account-p account-p1 account-font-bold account-primary-color1`, text: title }),
|
|
19
|
-
React.createElement(AccountButton, { text:
|
|
20
|
-
addresses.length > 0 ? (React.createElement("div", { className: `flex-wrapper` }, addresses.map((item, index) => {
|
|
21
|
-
return (React.createElement(AddressItem, { key: index, data: item }));
|
|
22
|
-
}))) : (React.createElement(EmptyAddress, null))));
|
|
21
|
+
React.createElement(AccountButton, { text: addNewText, btnType: `purple-text`, onClick: handleAddNewAddressPopup })),
|
|
22
|
+
addresses.length > 0 ? (React.createElement("div", { className: `flex-wrapper` }, addresses.map((item, index) => (React.createElement(AddressItem, { key: index, type: type, data: item }))))) : (React.createElement(EmptyAddress, null))));
|
|
23
23
|
};
|
|
24
24
|
export default AddressWrap;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useAddressContext } from '../AddressProvider';
|
|
3
|
+
import AddressWrap from '../AddressWrap';
|
|
4
|
+
import AddressesTemplateStyle from './style';
|
|
5
|
+
const AddressesTemplate = () => {
|
|
6
|
+
const { hasAddressType } = useAddressContext();
|
|
7
|
+
return (React.createElement(AddressesTemplateStyle, null, hasAddressType ? (React.createElement(React.Fragment, null,
|
|
8
|
+
React.createElement(AddressWrap, { type: 'shipping', title: 'shippingAddress', addNewText: 'addNewShippingAddress' }),
|
|
9
|
+
React.createElement(AddressWrap, { type: 'billing', title: 'billingAddress', addNewText: 'addNewBillingAddress' }))) : (React.createElement(AddressWrap, null))));
|
|
10
|
+
};
|
|
11
|
+
export default AddressesTemplate;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useAddressContext } from '../AddressProvider';
|
|
3
|
+
import { Text, useUi } from '@weareconceptstudio/core';
|
|
4
|
+
import AddressForm from '../AddressForm';
|
|
5
|
+
import AddressItem from '../AddressItem';
|
|
6
|
+
import AccountButton from '../../../components/ui/AccountButton';
|
|
7
|
+
import SelectAddressStyle from './style';
|
|
8
|
+
const SelectAddress = ({ type, title }) => {
|
|
9
|
+
const { openPopup } = useUi();
|
|
10
|
+
const { addresses, formFields, hasAddressType, createAddress } = useAddressContext();
|
|
11
|
+
const handleNewAddressPopup = () => {
|
|
12
|
+
openPopup(React.createElement(AddressForm, { title: `addNewShippingAddress`, formFields: formFields, createAddress: createAddress, selected: { value: false, type: 'shipping' } }));
|
|
13
|
+
};
|
|
14
|
+
return (React.createElement(SelectAddressStyle, null,
|
|
15
|
+
React.createElement("div", { className: `select-address-wrap` },
|
|
16
|
+
React.createElement(Text, { tag: `h6`, className: hasAddressType ? `account-h6 account-font-bold account-primary-color1` : 'account-p account-p2 account-font-bold account-primary-color1', text: title }),
|
|
17
|
+
React.createElement(AccountButton, { onClick: handleNewAddressPopup, text: `addNewAdd`, btnType: hasAddressType ? `purple-text` : 'green-small-text' })),
|
|
18
|
+
addresses?.length > 0 ? (React.createElement("div", { className: `flex-wrapper` }, addresses.map((item, index) => {
|
|
19
|
+
return (React.createElement(AddressItem, { id: item.id, type: type, data: item, key: index, select_address: true, checkout_review: false }));
|
|
20
|
+
}))) : null));
|
|
21
|
+
};
|
|
22
|
+
export default SelectAddress;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default SelectAddressStyle;
|
|
2
|
+
declare const SelectAddressStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|