@weareconceptstudio/account 0.0.3 → 0.0.5
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 +8 -0
- package/dist/AccountProvider.js +27 -0
- package/dist/components/AddressForm/index.js +11 -9
- package/dist/components/AddressItem/index.d.ts +10 -1
- package/dist/components/AddressItem/index.js +7 -7
- package/dist/components/AddressWrap/index.d.ts +7 -0
- package/dist/components/AddressWrap/index.js +24 -0
- package/dist/components/EmptyAddress/index.d.ts +3 -0
- package/dist/components/EmptyAddress/index.js +6 -0
- package/dist/components/EmptyOrders/index.js +1 -1
- package/dist/components/FavoriteButton/index.d.ts +3 -0
- package/dist/components/FavoriteButton/index.js +42 -0
- package/dist/components/OrderedItems/index.js +1 -1
- package/dist/components/OrdersList/OrderItem/index.js +1 -1
- package/dist/components/OrdersList/index.js +2 -2
- package/dist/components/SelectShippingBilling/index.js +1 -1
- package/dist/components/TotalCheckout/index.js +5 -5
- package/dist/components/{EmptyCart → cart/EmptyCart}/index.js +1 -2
- package/dist/components/cart/Items/Simple/Item/index.d.ts +3 -0
- package/dist/components/cart/Items/Simple/Item/index.js +55 -0
- package/dist/components/cart/Items/Simple/ItemMobile/index.d.ts +3 -0
- package/dist/components/cart/Items/Simple/ItemMobile/index.js +73 -0
- package/dist/components/cart/Items/Simple/index.d.ts +3 -0
- package/dist/components/cart/Items/Simple/index.js +35 -0
- package/dist/components/cart/Items/Simple/style.d.ts +2 -0
- package/dist/components/cart/Items/Simple/style.js +641 -0
- package/dist/components/cart/index.d.ts +2 -0
- package/dist/components/cart/index.js +2 -0
- package/dist/components/index.d.ts +5 -9
- package/dist/components/index.js +5 -9
- package/dist/components/{AccountButton → ui/AccountButton}/index.js +1 -1
- package/dist/components/{CustomCheckbox → ui/CustomCheckbox}/index.js +1 -1
- package/dist/components/{WarningMessageForPopup → ui/WarningMessageForPopup}/index.js +1 -1
- package/dist/components/ui/index.d.ts +6 -0
- package/dist/components/ui/index.js +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/templates/AddressesTemplate/index.d.ts +4 -1
- package/dist/templates/AddressesTemplate/index.js +7 -19
- package/dist/templates/AddressesTemplate/style.js +4 -4
- package/dist/templates/CartTemplate/index.d.ts +11 -1
- package/dist/templates/CartTemplate/index.js +13 -12
- package/package.json +1 -1
- package/dist/AccountConfig.d.ts +0 -5
- package/dist/AccountConfig.js +0 -21
- /package/dist/components/{EmptyCart → cart/EmptyCart}/index.d.ts +0 -0
- /package/dist/components/{EmptyCart → cart/EmptyCart}/style.d.ts +0 -0
- /package/dist/components/{EmptyCart → cart/EmptyCart}/style.js +0 -0
- /package/dist/components/{AccountButton → ui/AccountButton}/index.d.ts +0 -0
- /package/dist/components/{AccountButton → ui/AccountButton}/style.d.ts +0 -0
- /package/dist/components/{AccountButton → ui/AccountButton}/style.js +0 -0
- /package/dist/components/{CustomCheckbox → ui/CustomCheckbox}/index.d.ts +0 -0
- /package/dist/components/{CustomCheckbox → ui/CustomCheckbox}/style.d.ts +0 -0
- /package/dist/components/{CustomCheckbox → ui/CustomCheckbox}/style.js +0 -0
- /package/dist/components/{Pagination → ui/Pagination}/index.d.ts +0 -0
- /package/dist/components/{Pagination → ui/Pagination}/index.js +0 -0
- /package/dist/components/{Pagination → ui/Pagination}/style.d.ts +0 -0
- /package/dist/components/{Pagination → ui/Pagination}/style.js +0 -0
- /package/dist/components/{Sequence → ui/Sequence}/index.d.ts +0 -0
- /package/dist/components/{Sequence → ui/Sequence}/index.js +0 -0
- /package/dist/components/{Sequence → ui/Sequence}/style.d.ts +0 -0
- /package/dist/components/{Sequence → ui/Sequence}/style.js +0 -0
- /package/dist/components/{WarningMessage → ui/WarningMessage}/index.d.ts +0 -0
- /package/dist/components/{WarningMessage → ui/WarningMessage}/index.js +0 -0
- /package/dist/components/{WarningMessage → ui/WarningMessage}/style.d.ts +0 -0
- /package/dist/components/{WarningMessage → ui/WarningMessage}/style.js +0 -0
- /package/dist/components/{WarningMessageForPopup → ui/WarningMessageForPopup}/index.d.ts +0 -0
- /package/dist/components/{WarningMessageForPopup → ui/WarningMessageForPopup}/style.d.ts +0 -0
- /package/dist/components/{WarningMessageForPopup → ui/WarningMessageForPopup}/style.js +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from '@weareconceptstudio/core';
|
|
3
|
+
import { ThemeProvider } from 'styled-components';
|
|
4
|
+
//* Translations
|
|
5
|
+
import translations from './translations';
|
|
6
|
+
//* Styles
|
|
7
|
+
import theme from './styles/theme';
|
|
8
|
+
import AccountHelperClass from './styles/helperClass';
|
|
9
|
+
import AccountVariables from './styles/variables';
|
|
10
|
+
import AccountTypography from './styles/typography';
|
|
11
|
+
const AccountContext = createContext(null);
|
|
12
|
+
export const useAccountContext = () => {
|
|
13
|
+
const context = useContext(AccountContext);
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
export const AccountProvider = ({ fontFamily = 'core_Font', children, maxQty = 99, currency }) => {
|
|
17
|
+
const { addTranslation } = useTranslation();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
addTranslation(translations, 'prepend');
|
|
20
|
+
}, []);
|
|
21
|
+
return (React.createElement(AccountContext.Provider, { value: { currency, maxQty } },
|
|
22
|
+
React.createElement(ThemeProvider, { theme: theme },
|
|
23
|
+
React.createElement(AccountVariables, { fontFamily: fontFamily }),
|
|
24
|
+
React.createElement(AccountHelperClass, null),
|
|
25
|
+
React.createElement(AccountTypography, null),
|
|
26
|
+
children)));
|
|
27
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React, { memo as Memo, useState, useCallback, useRef } from 'react';
|
|
2
2
|
import { useUi, Text } from '@weareconceptstudio/core';
|
|
3
3
|
import { Form, Input, PhoneNumber, Select } from '@weareconceptstudio/form';
|
|
4
|
+
import AccountButton from '../ui/AccountButton';
|
|
4
5
|
import { useTheme } from 'styled-components';
|
|
5
6
|
import theme from '../../styles/theme';
|
|
6
7
|
//* Icons
|
|
7
8
|
import { CheckboxIcon, CheckboxCheckedIcon } from '../../utils/icons';
|
|
8
9
|
//* Style
|
|
9
10
|
import AddressFormStyle from './style';
|
|
10
|
-
//* Components
|
|
11
|
-
import AccountButton from '../AccountButton';
|
|
12
11
|
//TODO: Form -> ref, onChange, Select, Form Item -> options,Global Data
|
|
13
12
|
const globalData = {
|
|
14
13
|
countries: [],
|
|
@@ -64,13 +63,13 @@ const AddressForm = Memo(({ title, data, selected, createAddress, updateAddress
|
|
|
64
63
|
}, []);
|
|
65
64
|
return (React.createElement(AddressFormStyle, { theme: theme(globalTheme) },
|
|
66
65
|
React.createElement(Text, { tag: `h6`, text: title, className: `account-h6 account-font-bold account-primary-color1` }),
|
|
67
|
-
React.createElement(Form, { ref: form, onSubmit: onFinish, onChange: handleFormChange, initialValues: data
|
|
66
|
+
React.createElement(Form, { ref: form, onSubmit: onFinish, onChange: handleFormChange, initialValues: data },
|
|
68
67
|
React.createElement("div", { className: `form-wrapper` },
|
|
69
68
|
React.createElement(Form.Item, { name: 'country_id', label: 'country' },
|
|
70
69
|
React.createElement(Select, { placeholder: 'Armenia',
|
|
71
70
|
// options={globalData.regions}
|
|
72
71
|
disabled: true })),
|
|
73
|
-
React.createElement(Form.Item, { name: 'type' },
|
|
72
|
+
React.createElement(Form.Item, { name: 'type', required: false },
|
|
74
73
|
React.createElement(Input, { type: 'hidden' })),
|
|
75
74
|
React.createElement(Form.Item, { name: 'first_name', label: 'firstName' },
|
|
76
75
|
React.createElement(Input, { placeholder: 'firstNamePlaceholder' })),
|
|
@@ -88,11 +87,14 @@ const AddressForm = Memo(({ title, data, selected, createAddress, updateAddress
|
|
|
88
87
|
React.createElement(Input.Number, { placeholder: 'zipCodePlaceholder' })),
|
|
89
88
|
React.createElement(Form.Item, { name: 'phone', label: 'phone' },
|
|
90
89
|
React.createElement(PhoneNumber, null))),
|
|
91
|
-
React.createElement("div", { className: `default-info-wrap` }, !data?.is_default ? (React.createElement("div", { className: `banner-wrap cursor-pointer`, onClick: () => setIsChecked(!isChecked) },
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
React.createElement("div", { className: `default-info-wrap` }, !data?.is_default ? (React.createElement("div", { className: `banner-wrap cursor-pointer`, onClick: () => setIsChecked(!isChecked) }, isChecked ? (React.createElement("div", { className: 'checkbox-wrap', role: 'button' },
|
|
91
|
+
React.createElement(CheckboxCheckedIcon, null))) : (React.createElement("div", { className: 'checkbox-wrap', role: 'button' },
|
|
92
|
+
React.createElement(CheckboxIcon, null))))) : (React.createElement("div", null, "Test")
|
|
93
|
+
// <Text
|
|
94
|
+
// className={`account-p account-p2 account-font-medium account-primary-color1`}
|
|
95
|
+
// text={`${selected.type === 'shipping' ? 'thisYourDefaultShippingAddress' : 'thisYourDefaultBillingAddress'}`}
|
|
96
|
+
// />
|
|
97
|
+
)),
|
|
96
98
|
React.createElement("div", { className: `cancel-and-save-wrap` },
|
|
97
99
|
React.createElement(AccountButton, { text: `cancel`, onClick: closePopup, btnType: `green-large-text` }),
|
|
98
100
|
React.createElement(AccountButton, { type: 'submit', text: `saveAndApply`, btnType: `full-width`, className: `${isDisabled ? 'disabled' : ''}` })))));
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export default AddressItem;
|
|
2
|
-
declare
|
|
2
|
+
declare function AddressItem({ title, data, checkout_review, select_address, type, onClick, checkedId, setCheckedId }: {
|
|
3
|
+
title: any;
|
|
4
|
+
data: any;
|
|
5
|
+
checkout_review: any;
|
|
6
|
+
select_address: any;
|
|
7
|
+
type: any;
|
|
8
|
+
onClick: any;
|
|
9
|
+
checkedId: any;
|
|
10
|
+
setCheckedId: any;
|
|
11
|
+
}): React.JSX.Element;
|
|
3
12
|
import React from 'react';
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
3
|
//* Components
|
|
4
4
|
import AddressForm from '../AddressForm';
|
|
5
|
-
import AccountButton from '../AccountButton';
|
|
6
|
-
import WarningMessageForPopup from '../WarningMessageForPopup';
|
|
5
|
+
import AccountButton from '../ui/AccountButton';
|
|
6
|
+
import WarningMessageForPopup from '../ui/WarningMessageForPopup';
|
|
7
7
|
//* Style
|
|
8
8
|
import AddressItemStyle from './style';
|
|
9
|
-
|
|
10
|
-
const deleteAddress = () => { };
|
|
11
|
-
const AddressItem = Memo(({ title, data, checkout_review, select_address, type, onClick, checkedId, setCheckedId }) => {
|
|
9
|
+
const AddressItem = ({ title, data, checkout_review, select_address, type, onClick, checkedId, setCheckedId }) => {
|
|
12
10
|
const { openPopup } = useUi();
|
|
13
11
|
//! Handle Popups
|
|
14
12
|
const handleDeletePopup = useCallback(() => {
|
|
@@ -17,6 +15,8 @@ const AddressItem = Memo(({ title, data, checkout_review, select_address, type,
|
|
|
17
15
|
const handleEditAddressPopup = useCallback(() => {
|
|
18
16
|
openPopup(React.createElement(AddressForm, { data: data, selected: { value: true, type: data.type }, title: type === 'billing' ? `updateYourBillingAddress` : `updateYourShippingAddress` }));
|
|
19
17
|
}, [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 }),
|
|
@@ -37,5 +37,5 @@ const AddressItem = Memo(({ title, data, checkout_review, select_address, type,
|
|
|
37
37
|
!select_address && !data.is_default && (React.createElement(React.Fragment, null,
|
|
38
38
|
React.createElement("div", { className: `vertical-line` }),
|
|
39
39
|
React.createElement(AccountButton, { text: `remove`, btnType: `green-small-text`, onClick: handleDeletePopup })))))))));
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
export default AddressItem;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Text, useUi } from '@weareconceptstudio/core';
|
|
4
|
+
import AccountButton from '../ui/AccountButton';
|
|
5
|
+
import EmptyAddress from '../EmptyAddress';
|
|
6
|
+
import AddressItem from '../AddressItem';
|
|
7
|
+
import AddressForm from '../AddressForm';
|
|
8
|
+
const AddressWrap = ({ title = 'addresses', addresses = [], className }) => {
|
|
9
|
+
const { openPopup } = useUi();
|
|
10
|
+
const classString = classNames('address-wrap', {
|
|
11
|
+
[className]: className,
|
|
12
|
+
});
|
|
13
|
+
const handleAddNewAddressPopup = () => {
|
|
14
|
+
openPopup(React.createElement(AddressForm, null));
|
|
15
|
+
};
|
|
16
|
+
return (React.createElement("div", { className: classString },
|
|
17
|
+
React.createElement("div", { className: `address-title-container` },
|
|
18
|
+
React.createElement(Text, { className: `account-p account-p1 account-font-bold account-primary-color1`, text: title }),
|
|
19
|
+
React.createElement(AccountButton, { text: `addNewAdd`, btnType: `purple-text`, onClick: handleAddNewAddressPopup })),
|
|
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))));
|
|
23
|
+
};
|
|
24
|
+
export default AddressWrap;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from '@weareconceptstudio/core';
|
|
3
|
+
const EmptyAddress = () => {
|
|
4
|
+
return (React.createElement(Text, { className: `account-p account-p2 account-font-regular account-primary-color1 empty-address-text`, text: `emptyAddress` }));
|
|
5
|
+
};
|
|
6
|
+
export default EmptyAddress;
|
|
@@ -3,7 +3,7 @@ import { Text } from '@weareconceptstudio/core';
|
|
|
3
3
|
//* Style
|
|
4
4
|
import EmptyOrdersStyle from './style';
|
|
5
5
|
//* Components
|
|
6
|
-
import AccountButton from '../AccountButton';
|
|
6
|
+
import AccountButton from '../ui/AccountButton';
|
|
7
7
|
const EmptyOrders = Memo(() => {
|
|
8
8
|
return (React.createElement(EmptyOrdersStyle, null,
|
|
9
9
|
React.createElement(Text, { tag: `h6`, className: `account-h6 account-font-bold account-primary-color1`, text: `emptyTitle` }),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import Button from '../ui/AccountButton';
|
|
3
|
+
const addToFavorite = () => { };
|
|
4
|
+
const removeFavorite = () => { };
|
|
5
|
+
//* Icons
|
|
6
|
+
const favoriteIcon = (React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg' },
|
|
7
|
+
React.createElement("path", { id: 'path-1', fill: '#ecefec', d: 'M14.622 0l-12.889 7.911-1.733 13.867 7.822 8.8 13.911 1.422 10.267-11.689-3.6-16.711-13.778-3.6z' }),
|
|
8
|
+
React.createElement("path", { id: 'path-2', fill: '#8c9b8b', d: 'M17.066 24.8c-0.178 0-0.267-0.044-0.356-0.178l-10.667-9.911c-0.222-0.222-0.222-0.533-0.044-0.756l4.622-5.511c0.178-0.222 0.444-0.267 0.622-0.089l5.689 3.111 3.733-4.089c0.089-0.089 0.267-0.178 0.444-0.178s0.311 0.044 0.356 0.222l4.489 5.467c0.178 0.222 0.178 0.489 0 0.622l-8.533 11.067c-0.044 0.133-0.133 0.222-0.356 0.222z' }),
|
|
9
|
+
React.createElement("path", { id: 'path-3', fill: '#b2bdb1', d: 'M17.067 24.978c-0.178 0-0.311-0.044-0.444-0.178l-10.667-9.956c-0.267-0.222-0.267-0.622-0.044-0.933l4.578-5.511c0.222-0.267 0.533-0.311 0.844-0.178l5.556 3.067 3.689-4.044c0.133-0.133 0.311-0.222 0.533-0.222 0.178 0 0.356 0.089 0.489 0.267l4.489 5.511c0.178 0.222 0.178 0.578 0 0.844l-8.533 11.067c-0.133 0.133-0.267 0.222-0.489 0.267zM7.289 14.267l9.689 9.022 7.778-10.044-3.689-4.533-3.511 3.867c-0.222 0.222-0.533 0.267-0.8 0.133l-5.6-3.067-3.867 4.622z' })));
|
|
10
|
+
const FavoriteButton = memo(({ type, favorites, productId, optionId, variantId, qty }) => {
|
|
11
|
+
//! Check Active Favorite
|
|
12
|
+
const isFavorite = useMemo(() => {
|
|
13
|
+
return favorites.some((favorite) => favorite.product.id === productId && favorite.selectedOption.id === optionId && favorite.selectedVariant.id === variantId);
|
|
14
|
+
}, [favorites, productId, variantId, optionId]);
|
|
15
|
+
//! Add to favorite
|
|
16
|
+
const addFavoriteHandleClick = useCallback(() => {
|
|
17
|
+
isFavorite
|
|
18
|
+
? removeFavorite({
|
|
19
|
+
productId,
|
|
20
|
+
variantId,
|
|
21
|
+
optionId,
|
|
22
|
+
})
|
|
23
|
+
: addToFavorite({
|
|
24
|
+
productId,
|
|
25
|
+
variantId,
|
|
26
|
+
optionId,
|
|
27
|
+
qty,
|
|
28
|
+
update: true,
|
|
29
|
+
});
|
|
30
|
+
}, [productId, variantId, optionId, qty, isFavorite]);
|
|
31
|
+
return type === 'withIcon' ? (
|
|
32
|
+
// <Icon
|
|
33
|
+
// name={`favorite`}
|
|
34
|
+
// className={`pi-favorite ${isFavorite ? 'pi-active' : ''}`}
|
|
35
|
+
// onClick={addFavoriteHandleClick}>
|
|
36
|
+
// <span className='path1' />
|
|
37
|
+
// <span className='path2' />
|
|
38
|
+
// <span className='path3' />
|
|
39
|
+
// </Icon>
|
|
40
|
+
React.createElement("div", { onClick: addFavoriteHandleClick, className: `pi-favorite ${isFavorite ? 'pi-active' : ''}` }, favoriteIcon)) : (React.createElement(Button, { text: 'addToWishlist', btnType: `green-small-text`, onClick: addFavoriteHandleClick, className: `wishlist-btn ${isFavorite ? 'active' : ''}` }));
|
|
41
|
+
});
|
|
42
|
+
export default FavoriteButton;
|
|
@@ -9,7 +9,7 @@ import { handlePriceCheckFunc } from '../../utils/_functions';
|
|
|
9
9
|
// import OldEditor from '../OldEditor';
|
|
10
10
|
// import ReviewPopup from './ReviewPopup';
|
|
11
11
|
// import ImagesPopup from '../ImagesPopup';
|
|
12
|
-
import AccountButton from '../AccountButton';
|
|
12
|
+
import AccountButton from '../ui/AccountButton';
|
|
13
13
|
//* Styles
|
|
14
14
|
// import 'swiper/swiper-bundle.css';
|
|
15
15
|
import OrderedItemsStyle from './style';
|
|
@@ -3,7 +3,7 @@ import { Text } from '@weareconceptstudio/core';
|
|
|
3
3
|
//* Utils
|
|
4
4
|
import { handlePriceCheckFunc } from '../../../utils/_functions';
|
|
5
5
|
//* Components
|
|
6
|
-
import AccountButton from '../../AccountButton';
|
|
6
|
+
import AccountButton from '../../ui/AccountButton';
|
|
7
7
|
const OrderItem = Memo(({ data }) => {
|
|
8
8
|
return (React.createElement("div", { className: `order-table-item-wrap` },
|
|
9
9
|
React.createElement("div", { className: `col-item od-col-1 nowrap` },
|
|
@@ -4,8 +4,8 @@ import { createQueryString, Text, useTranslation, useUi } from '@weareconceptstu
|
|
|
4
4
|
import { handlePriceCheckFunc } from '../../utils/_functions';
|
|
5
5
|
//* Components
|
|
6
6
|
import OrderItem from './OrderItem';
|
|
7
|
-
import Pagination from '../Pagination';
|
|
8
|
-
import AccountButton from '../AccountButton';
|
|
7
|
+
import Pagination from '../ui/Pagination';
|
|
8
|
+
import AccountButton from '../ui/AccountButton';
|
|
9
9
|
//* Style
|
|
10
10
|
import OrdersListStyle from './style';
|
|
11
11
|
const OrdersList = ({ data, total, pageSize, router, pathname, searchParams }) => {
|
|
@@ -2,7 +2,7 @@ import React, { memo as Memo, useState, useCallback } from 'react';
|
|
|
2
2
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
3
|
//* Components
|
|
4
4
|
import AddressItem from '../AddressItem';
|
|
5
|
-
import AccountButton from '../AccountButton';
|
|
5
|
+
import AccountButton from '../ui/AccountButton';
|
|
6
6
|
//* Style
|
|
7
7
|
import SelectShippingBillingStyle from './style';
|
|
8
8
|
//TODO: getCart
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React, { memo, useState, useEffect } from 'react';
|
|
2
2
|
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
|
-
import {
|
|
4
|
-
import AccountButton from '../AccountButton';
|
|
3
|
+
import { useAccountContext } from '../../AccountProvider';
|
|
4
|
+
import AccountButton from '../ui/AccountButton';
|
|
5
5
|
//* Utils
|
|
6
6
|
import { handlePriceCheckFunc, numToLocalString } from '../../utils/_functions';
|
|
7
7
|
//* Style
|
|
8
8
|
import TotalCheckoutStyle from './style';
|
|
9
|
-
|
|
10
|
-
// TODO: itemsCount, subtotal, total, loading, currency, shippingCost
|
|
11
|
-
const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, itemsCount, subtotal, total, loading, currency, shippingCost }) => {
|
|
9
|
+
const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, itemsCount, subtotal, total, loading, shippingCost }) => {
|
|
12
10
|
const { winWidth } = useUi();
|
|
11
|
+
const { currency } = useAccountContext();
|
|
13
12
|
//! States
|
|
14
13
|
const [headerHeight, setHeaderHeight] = useState();
|
|
15
14
|
const [note, setNote] = useState();
|
|
@@ -17,6 +16,7 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
17
16
|
useEffect(() => {
|
|
18
17
|
setHeaderHeight(document.getElementsByTagName('header')[0]?.clientHeight);
|
|
19
18
|
}, [winWidth]);
|
|
19
|
+
console.log(shippingCost);
|
|
20
20
|
return (React.createElement(TotalCheckoutStyle, { "$headerHeight": headerHeight },
|
|
21
21
|
React.createElement("div", { className: `cart-main-wrap` },
|
|
22
22
|
React.createElement("div", { className: `left-panel-wrap panel` }, children),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text } from '@weareconceptstudio/core';
|
|
3
|
+
import AccountButton from '../../ui/AccountButton';
|
|
3
4
|
//* Style
|
|
4
5
|
import EmptyCartStyle from './style';
|
|
5
|
-
//* Components
|
|
6
|
-
import AccountButton from '../AccountButton';
|
|
7
6
|
const EmptyCart = ({ shoppingUrl }) => {
|
|
8
7
|
return (React.createElement(EmptyCartStyle, null,
|
|
9
8
|
React.createElement("div", { className: `empty-cart-wrap` },
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { Image, Text, useUi } from '@weareconceptstudio/core';
|
|
3
|
+
import { Select } from '@weareconceptstudio/form';
|
|
4
|
+
import { useAccountContext } from '../../../../../AccountProvider';
|
|
5
|
+
import { handlePriceCheckFunc } from '../../../../../utils/_functions';
|
|
6
|
+
import Button from '../../../../ui/AccountButton';
|
|
7
|
+
import FavoriteButton from '../../../../FavoriteButton';
|
|
8
|
+
const pathname = '/cart/';
|
|
9
|
+
const Item = memo(({ data, edit, favorite, remove, select, isLast, favorites, actions }) => {
|
|
10
|
+
const { openPopup } = useUi();
|
|
11
|
+
const { currency, maxQty } = useAccountContext();
|
|
12
|
+
const selectionList = useMemo(() => {
|
|
13
|
+
if (select) {
|
|
14
|
+
const selectList = [];
|
|
15
|
+
for (let index = 1; index <= maxQty; index++) {
|
|
16
|
+
selectList.push({ value: index, label: index });
|
|
17
|
+
}
|
|
18
|
+
return selectList;
|
|
19
|
+
}
|
|
20
|
+
}, [data, select, maxQty]);
|
|
21
|
+
return (React.createElement("div", { className: `item-wrap` },
|
|
22
|
+
React.createElement("div", { className: 'line' }),
|
|
23
|
+
React.createElement("div", { className: `item-inner-wrapper` },
|
|
24
|
+
React.createElement("div", { className: `col-item tl-col-1 col-item-1` },
|
|
25
|
+
React.createElement("div", { className: `image-wrapper` },
|
|
26
|
+
React.createElement(Image, { src: data?.product?.image?.src, alt: data?.product?.image?.alt })),
|
|
27
|
+
React.createElement("div", { className: `col-1-right-wrap` },
|
|
28
|
+
React.createElement(Button, { url: data.product?.url, className: `capitalize`, text: data.product?.name, btnType: `green-large-text`, target: pathname === '/cart/' || pathname === '/checkout' ? '_blank' : '_self' }),
|
|
29
|
+
React.createElement("div", { className: `right-first-item-wrap` },
|
|
30
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 capitalize`, text: data.product.short_info_1 })),
|
|
31
|
+
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' })) : (''))),
|
|
35
|
+
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
|
+
productId: data.product.id,
|
|
37
|
+
qty: val,
|
|
38
|
+
}) })) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: data.qty })))) : (React.createElement(Text, { className: `account-p account-p3 account-font-medium account-primary-color1`, text: data.qty }))),
|
|
39
|
+
React.createElement("div", { className: `col-item tl-col-3 col-item-3 nowrap` }, data?.product?.sale_price ? (React.createElement("div", null,
|
|
40
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 alignRight`, text: handlePriceCheckFunc(data?.product?.sale_price, currency) }),
|
|
41
|
+
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
|
+
React.createElement("div", { className: `col-item tl-col-4 col-item-4 nowrap` },
|
|
44
|
+
React.createElement("div", { className: `col-item-inner-wrap` },
|
|
45
|
+
React.createElement("div", { className: `flex-end-wrap` }, data?.product.sale_price ? (React.createElement("div", null,
|
|
46
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-secondary-color2 align-right`, text: `${data.sale_total} ${currency}` }),
|
|
47
|
+
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
|
+
favorite && !data.product?.out_of_stock && (React.createElement("div", { className: `favorite-btn-wrap` },
|
|
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 }) }))))))),
|
|
53
|
+
isLast ? React.createElement("div", { className: 'line' }) : null));
|
|
54
|
+
});
|
|
55
|
+
export default Item;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { Image, Text, useUi } from '@weareconceptstudio/core';
|
|
3
|
+
import { Select } from '@weareconceptstudio/form';
|
|
4
|
+
import Button from '../../../../ui/AccountButton';
|
|
5
|
+
import { useAccountContext } from '../../../../../AccountProvider';
|
|
6
|
+
//* Utils
|
|
7
|
+
import { handlePriceCheckFunc } from '../../../../../utils/_functions';
|
|
8
|
+
//* Components
|
|
9
|
+
import FavoriteButton from '../../../../FavoriteButton';
|
|
10
|
+
// import ProductIndividual from '@/components/common/ProductIndividual';
|
|
11
|
+
//TODO: Fake
|
|
12
|
+
const pathname = '/cart/';
|
|
13
|
+
const addToCart = () => { };
|
|
14
|
+
const removeCart = () => { };
|
|
15
|
+
const ItemMobile = memo(({ data, additionalParameters, isLast, favorites }) => {
|
|
16
|
+
const { openPopup } = useUi();
|
|
17
|
+
const { currency } = useAccountContext();
|
|
18
|
+
const selectionList = useMemo(() => {
|
|
19
|
+
if (additionalParameters.select) {
|
|
20
|
+
const selectList = [];
|
|
21
|
+
for (let index = 1; index <= data.qty; index++) {
|
|
22
|
+
selectList.push({ value: index, label: index });
|
|
23
|
+
}
|
|
24
|
+
return selectList;
|
|
25
|
+
}
|
|
26
|
+
}, [data]);
|
|
27
|
+
return (React.createElement(React.Fragment, null,
|
|
28
|
+
isLast ? React.createElement("div", { className: 'line' }) : null,
|
|
29
|
+
React.createElement("div", { className: `mobile-order-item-wrap` },
|
|
30
|
+
React.createElement("div", { className: `mobile-order-item-inner-wrap` },
|
|
31
|
+
React.createElement("div", { className: `mobile-image-wrap` },
|
|
32
|
+
React.createElement(Image, { src: data?.images?.[0].src, alt: data?.images?.[0].alt })),
|
|
33
|
+
React.createElement("div", { className: `mobile-info-wrap` },
|
|
34
|
+
React.createElement(Button, { className: `capitalize`, url: data.product?.url, btnType: `green-large-text`, text: data.product?.name || data.name, target: pathname === '/cart/' || pathname === '/checkout/' ? '_blank' : '_self' }),
|
|
35
|
+
additionalParameters.select ? (React.createElement("div", { className: `select-and-out-of-stock-mobile-wrap` }, !data.product?.out_of_stock ? (
|
|
36
|
+
// <FormSelect
|
|
37
|
+
// list={selectionList}
|
|
38
|
+
// selectedValue={data.qty}
|
|
39
|
+
// className={`quantity-select-mobile-wrap`}
|
|
40
|
+
// onChange={(val) => addToCart({ productId: data.product.id, variantId: data.selectedVariant.id, optionId: data.selectedOption.id, qty: val, update: true })}
|
|
41
|
+
// />
|
|
42
|
+
React.createElement(Select, { allowSearch: false, options: selectionList, value: 1, onChange: (val) => console.log(val) })) : (React.createElement("div", { className: `mobile-info-item` },
|
|
43
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1`, text: `quantityWithSymbol` }),
|
|
44
|
+
"\u00A0",
|
|
45
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1`, text: data.qty }))))) : (React.createElement("div", { className: `mobile-info-item` },
|
|
46
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1`, text: `quantityWithSymbol` }),
|
|
47
|
+
"\u00A0",
|
|
48
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1`, text: data.qty || data.quantity }))),
|
|
49
|
+
React.createElement("div", { className: `mobile-price-wrap nowrap` },
|
|
50
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1 mb-mt`, text: `price` }),
|
|
51
|
+
data?.discountedPrice ? (React.createElement("div", null,
|
|
52
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold secondaryColor2`, text: handlePriceCheckFunc(data?.product.discountedPrice, currency) }),
|
|
53
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-regular primaryColor2 lineThrough value`, text: handlePriceCheckFunc(data.product?.price, currency) }))) : (React.createElement(Text, { className: `account-p account-p3 account-font-bold primaryColor1`, text: handlePriceCheckFunc(data.product?.price, currency) }))),
|
|
54
|
+
React.createElement("div", { className: `mobile-total-price-wrap nowrap` },
|
|
55
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-medium primaryColor1 mb-mt`, text: `total` }),
|
|
56
|
+
data.selectedOption?.discountedPrice ? (React.createElement("div", null,
|
|
57
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold secondaryColor2`, text: handlePriceCheckFunc(data.product?.discountedPrice * data.qty, currency) }),
|
|
58
|
+
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
|
+
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
|
+
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
|
+
React.createElement("div", { className: 'line' })));
|
|
72
|
+
});
|
|
73
|
+
export default ItemMobile;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { Text, useUi } from '@weareconceptstudio/core';
|
|
3
|
+
//* Components
|
|
4
|
+
import Item from './Item';
|
|
5
|
+
import ItemMobile from './ItemMobile';
|
|
6
|
+
//* Style
|
|
7
|
+
import CartItemsStyle from './style';
|
|
8
|
+
const CartItems = memo(({ data, className, title, smallFontSize, additionalParameters, currency, isLast, favorites, actions }) => {
|
|
9
|
+
const { winWidth } = useUi();
|
|
10
|
+
//! Store
|
|
11
|
+
const orderStore = useMemo(() => {
|
|
12
|
+
return winWidth >= 768 ? (React.createElement("div", { className: `order-items-table-wrap` },
|
|
13
|
+
React.createElement("div", { className: `titles-wrap` },
|
|
14
|
+
React.createElement("div", { className: `title-wrap tl-col-1` },
|
|
15
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap`, text: `item` })),
|
|
16
|
+
React.createElement("div", { className: `title-wrap tl-col-2` },
|
|
17
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap`, text: `quantity` })),
|
|
18
|
+
React.createElement("div", { className: `title-wrap tl-col-3 title-item` },
|
|
19
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap alignRight`, text: `price` })),
|
|
20
|
+
React.createElement("div", { className: `title-wrap tl-col-4 title-item` },
|
|
21
|
+
React.createElement(Text, { className: `account-p account-p3 account-font-bold account-primary-color1 nowrap alignRight`, text: `total` }))),
|
|
22
|
+
React.createElement("div", { className: `items-wrap` }, data?.map((item, index) => {
|
|
23
|
+
return (React.createElement(Item, { key: index, data: item, currency: currency, favorites: favorites, isLast: data.length - 1 == index, select: additionalParameters.select, remove: additionalParameters.remove, edit: additionalParameters.edit.item, favorite: additionalParameters.favorite, actions: actions }));
|
|
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, favorites: favorites, additionalParameters: additionalParameters }));
|
|
26
|
+
})));
|
|
27
|
+
}, [winWidth, data, additionalParameters, currency]);
|
|
28
|
+
return (React.createElement(CartItemsStyle, { className: className || '' },
|
|
29
|
+
additionalParameters.edit.list ? (React.createElement("div", { className: `title-edit-wrapper` },
|
|
30
|
+
React.createElement(Text, { className: `p ${smallFontSize ? 'p2' : 'p1'} account-font-bold account-primary-color1`, text: title }),
|
|
31
|
+
React.createElement(Button, { url: '/cart/', text: `editCart`, btnType: `green-small-text` }))) : (React.createElement(Text, { className: `p ${smallFontSize ? 'p2' : 'p1'} account-font-bold account-primary-color1`, text: title })),
|
|
32
|
+
additionalParameters.horizontalLine && React.createElement("div", { className: `order-items-line` }),
|
|
33
|
+
orderStore));
|
|
34
|
+
});
|
|
35
|
+
export default CartItems;
|