@weareconceptstudio/account 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AccountButton/index.d.ts +1 -1
- package/dist/components/AccountButton/index.js +4 -2
- package/dist/components/AccountContainer/index.js +1 -1
- package/dist/components/TotalCheckout/Skeleton/icons.d.ts +2 -0
- package/dist/components/TotalCheckout/Skeleton/icons.js +11 -0
- package/dist/components/TotalCheckout/Skeleton/index.d.ts +3 -0
- package/dist/components/TotalCheckout/Skeleton/index.js +10 -0
- package/dist/components/TotalCheckout/Skeleton/style.d.ts +2 -0
- package/dist/components/TotalCheckout/Skeleton/style.js +10 -0
- package/dist/components/TotalCheckout/index.js +7 -5
- package/dist/components/WarningMessage/index.d.ts +6 -1
- package/dist/components/WarningMessage/index.js +3 -3
- package/dist/modules/account/AccountSettingsTemplate/index.d.ts +1 -1
- package/dist/modules/account/AccountSettingsTemplate/index.js +6 -3
- package/dist/modules/account/AccountTemplate/index.d.ts +1 -2
- package/dist/modules/account/AccountTemplate/index.js +7 -4
- package/dist/modules/address/AddressForm/index.js +1 -1
- package/dist/modules/address/AddressItem/index.d.ts +4 -1
- package/dist/modules/address/AddressItem/index.js +4 -4
- package/dist/modules/address/AddressItem/style.js +4 -0
- package/dist/modules/address/AddressProvider.js +10 -9
- package/dist/modules/address/SelectAddress/index.d.ts +1 -4
- package/dist/modules/address/SelectAddress/index.js +21 -19
- package/dist/modules/address/SelectAddressPopup/index.d.ts +3 -0
- package/dist/modules/address/SelectAddressPopup/index.js +34 -0
- package/dist/modules/address/SelectAddressPopup/style.d.ts +2 -0
- package/dist/modules/address/{SelectShippingBillingPopup → SelectAddressPopup}/style.js +39 -2
- package/dist/modules/address/index.d.ts +1 -2
- package/dist/modules/address/index.js +1 -1
- package/dist/modules/auth/ForgotPasswordTemplate/index.d.ts +2 -2
- package/dist/modules/auth/ForgotPasswordTemplate/index.js +12 -13
- package/dist/modules/auth/ResetPasswordTemplate/index.d.ts +3 -3
- package/dist/modules/auth/ResetPasswordTemplate/index.js +13 -15
- package/dist/modules/auth/SignInTemplate/index.d.ts +3 -3
- package/dist/modules/auth/SignInTemplate/index.js +14 -7
- package/dist/modules/auth/SignUpTemplate/index.d.ts +3 -3
- package/dist/modules/auth/SignUpTemplate/index.js +15 -6
- package/dist/modules/auth/VerifyEmailAddressTemplate/index.js +4 -4
- package/dist/modules/cart/CartTemplate/Skeleton/SkeletonItem/index.d.ts +3 -0
- package/dist/modules/cart/CartTemplate/Skeleton/SkeletonItem/index.js +23 -0
- package/dist/modules/cart/CartTemplate/Skeleton/SkeletonItem/style.d.ts +2 -0
- package/dist/modules/cart/CartTemplate/Skeleton/SkeletonItem/style.js +110 -0
- package/dist/modules/cart/CartTemplate/Skeleton/icons.d.ts +13 -0
- package/dist/modules/cart/CartTemplate/Skeleton/icons.js +57 -0
- package/dist/modules/cart/CartTemplate/Skeleton/index.d.ts +5 -0
- package/dist/modules/cart/CartTemplate/Skeleton/index.js +24 -0
- package/dist/modules/cart/CartTemplate/Skeleton/style.d.ts +2 -0
- package/dist/modules/cart/CartTemplate/Skeleton/style.js +165 -0
- package/dist/modules/cart/CartTemplate/index.js +4 -2
- package/dist/modules/cart/CartTemplate/style.js +14 -6
- package/dist/modules/cart/SimpleItems/style.js +267 -265
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +2 -3
- package/dist/modules/checkout/CheckoutTemplate/index.js +1 -1
- package/dist/modules/order/OrderedItems/index.js +1 -1
- package/package.json +1 -1
- package/dist/modules/address/SelectAddress/style.d.ts +0 -2
- package/dist/modules/address/SelectAddress/style.js +0 -62
- package/dist/modules/address/SelectShippingBilling/index.d.ts +0 -3
- package/dist/modules/address/SelectShippingBilling/index.js +0 -37
- package/dist/modules/address/SelectShippingBillingPopup/index.d.ts +0 -3
- package/dist/modules/address/SelectShippingBillingPopup/index.js +0 -22
- package/dist/modules/address/SelectShippingBillingPopup/style.d.ts +0 -2
|
@@ -2,13 +2,15 @@ import React, { memo, useCallback, useMemo } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Link, useTranslation } from '@weareconceptstudio/core';
|
|
4
4
|
import AccountButtonStyle from './style';
|
|
5
|
-
const AccountButton =
|
|
5
|
+
const AccountButton = (props) => {
|
|
6
|
+
const { btnType, text, className, onClick, children, url, customLinkProps, target, type = 'button', disabled = false, svg_icon } = props;
|
|
6
7
|
const { translate } = useTranslation();
|
|
7
8
|
const Component = useMemo(() => (url ? Link : 'button'), [url]);
|
|
8
9
|
const customProps = useMemo(() => (url ? { ...customLinkProps, url, target } : { type, disabled }), [url, type, disabled]);
|
|
9
10
|
const classString = classNames('btn-wrap', {
|
|
10
11
|
[btnType]: btnType,
|
|
11
12
|
[className]: className,
|
|
13
|
+
'disabled': disabled,
|
|
12
14
|
});
|
|
13
15
|
const handleClick = useCallback(() => {
|
|
14
16
|
return !disabled && onClick?.();
|
|
@@ -17,5 +19,5 @@ const AccountButton = memo(({ btnType, text, className, onClick, children, url,
|
|
|
17
19
|
React.createElement(Component, { ...customProps },
|
|
18
20
|
svg_icon || children || translate(text),
|
|
19
21
|
" ")));
|
|
20
|
-
}
|
|
22
|
+
};
|
|
21
23
|
export default AccountButton;
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
import AccountContainerStyle from './style';
|
|
6
6
|
const AccountContainer = forwardRef(({ row, isSection, full, className, children }, ref) => {
|
|
7
7
|
//! Ref
|
|
8
|
-
const contRef = useRef();
|
|
8
|
+
const contRef = useRef(null);
|
|
9
9
|
//! Imperative Handle
|
|
10
10
|
useImperativeHandle(ref, () => contRef.current, []);
|
|
11
11
|
//! ClassName
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const skeletonTotal = (React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '528', height: '290', viewBox: '0 0 528 290', fill: 'none' },
|
|
3
|
+
React.createElement("line", { y1: '45', x2: '528', y2: '45', stroke: '#EFF1F2', "stroke-width": '2' }),
|
|
4
|
+
React.createElement("rect", { width: '160', height: '30', rx: '12', fill: '#EFF1F2' }),
|
|
5
|
+
React.createElement("rect", { y: '82', width: '90', height: '21', rx: '10.5', fill: '#EFF1F2' }),
|
|
6
|
+
React.createElement("rect", { x: '391', y: '82', width: '137', height: '21', rx: '10.5', fill: '#EFF1F2' }),
|
|
7
|
+
React.createElement("rect", { x: '391', y: '174', width: '137', height: '21', rx: '10.5', fill: '#EFF1F2' }),
|
|
8
|
+
React.createElement("rect", { x: '436', y: '128', width: '91', height: '21', rx: '10.5', fill: '#EFF1F2' }),
|
|
9
|
+
React.createElement("rect", { y: '128', width: '90', height: '21', rx: '10.5', fill: '#EFF1F2' }),
|
|
10
|
+
React.createElement("rect", { y: '174', width: '90', height: '21', rx: '10.5', fill: '#EFF1F2' }),
|
|
11
|
+
React.createElement("rect", { x: '1', y: '227', width: '527', height: '63', rx: '31.5', fill: '#EFF1F2' })));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
//* Styles
|
|
3
|
+
import { skeletonTotal } from './icons';
|
|
4
|
+
import SkeletonTotalCheckoutStyle from './style';
|
|
5
|
+
//* Component
|
|
6
|
+
const SkeletonTotalCheckout = () => {
|
|
7
|
+
return (React.createElement(SkeletonTotalCheckoutStyle, null,
|
|
8
|
+
React.createElement("div", { className: 'wrapper-skeleton' }, skeletonTotal)));
|
|
9
|
+
};
|
|
10
|
+
export default SkeletonTotalCheckout;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default SkeletonTotalCheckoutStyle;
|
|
2
|
+
declare const SkeletonTotalCheckoutStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -7,7 +7,9 @@ import { Input, Radio } from '@weareconceptstudio/form';
|
|
|
7
7
|
import { handlePriceCheckFunc, numToLocalString } from '../../utils/_functions';
|
|
8
8
|
//* Style
|
|
9
9
|
import TotalCheckoutStyle from './style';
|
|
10
|
-
|
|
10
|
+
//* Skeleton
|
|
11
|
+
import SkeletonTotalCheckout from './Skeleton';
|
|
12
|
+
const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, itemsCount, subtotal, total, shippingCost, fillCheckoutData, checkoutData, isCheckout = false, loading }) => {
|
|
11
13
|
const { currency, useUser } = useAccountContext();
|
|
12
14
|
const { user } = useUser();
|
|
13
15
|
const savedCards = useMemo(() => {
|
|
@@ -36,7 +38,7 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
36
38
|
return (React.createElement(TotalCheckoutStyle, null,
|
|
37
39
|
React.createElement("div", { className: `cart-main-wrap` },
|
|
38
40
|
React.createElement("div", { className: `left-panel-wrap panel` }, children),
|
|
39
|
-
React.createElement("div", { className: `right-panel-wrap panel ${confirmation ? 'display-none-wrap' : ''}` }, !confirmation && (React.createElement("div", { className: `max-width-wrapper sticky-wrap` },
|
|
41
|
+
React.createElement("div", { className: `right-panel-wrap panel ${confirmation ? 'display-none-wrap' : ''}` }, !confirmation && !loading ? (React.createElement("div", { className: `max-width-wrapper sticky-wrap` },
|
|
40
42
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-title`, text: `orderSummary` }),
|
|
41
43
|
React.createElement("div", { className: `od-line` }),
|
|
42
44
|
React.createElement("div", { className: `od-item-wrap` },
|
|
@@ -48,8 +50,8 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
48
50
|
React.createElement("div", { className: `od-item-wrap` },
|
|
49
51
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-total`, text: `total` }),
|
|
50
52
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1 sticky-wrap-currnecy2`, text: itemsCount ? handlePriceCheckFunc(total, currency) : `0 ${currency}` })),
|
|
51
|
-
isCheckout ? (React.createElement(React.Fragment, null,
|
|
52
|
-
|
|
53
|
+
isCheckout && typeof isShipping === 'boolean' && !isShipping ? (React.createElement(React.Fragment, null,
|
|
54
|
+
React.createElement(Input.TextArea, { onChange: (e) => fillCheckoutData('note', e.target.value), placeholder: 'checkoutCommentPlaceholder', containerClassName: `comment-field`, className: `account-p account-p3 account-font-regular account-primary-color1` }),
|
|
53
55
|
React.createElement(Radio.Group, { value: checkoutData.paymentType, onChange: (val) => fillCheckoutData('paymentType', val), options: [
|
|
54
56
|
{ label: 'Visa Arca', value: 'credit_card' },
|
|
55
57
|
{ label: 'Idram', value: 'idram' },
|
|
@@ -59,6 +61,6 @@ const TotalCheckout = memo(({ isShipping, children, confirmation, buttonProps, i
|
|
|
59
61
|
{ label: 'Cash', value: 'cash_on_delivery' },
|
|
60
62
|
] }),
|
|
61
63
|
React.createElement("div", { style: { marginTop: 20 } }, savedCards))) : null,
|
|
62
|
-
React.createElement(AccountButton, { url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, disabled: buttonProps.disabled, onClick: () => buttonProps.handleClick && buttonProps.handleClick(), className: `sticky-wrap-btn
|
|
64
|
+
React.createElement(AccountButton, { url: buttonProps.url, btnType: `full-width`, text: buttonProps.text, type: buttonProps.type, disabled: buttonProps.disabled, onClick: () => buttonProps.handleClick && buttonProps.handleClick(), className: `sticky-wrap-btn` }))) : (React.createElement(SkeletonTotalCheckout, null))))));
|
|
63
65
|
});
|
|
64
66
|
export default TotalCheckout;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export default WarningMessage;
|
|
2
|
-
declare
|
|
2
|
+
declare function WarningMessage({ error, isSent, successTitle, successSubtitle }: {
|
|
3
|
+
error: any;
|
|
4
|
+
isSent: any;
|
|
5
|
+
successTitle: any;
|
|
6
|
+
successSubtitle: any;
|
|
7
|
+
}): React.JSX.Element;
|
|
3
8
|
import React from 'react';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Text } from '@weareconceptstudio/core';
|
|
3
3
|
//* Style
|
|
4
4
|
import WarningMessageStyle from './style';
|
|
5
|
-
const WarningMessage =
|
|
5
|
+
const WarningMessage = ({ error, isSent, successTitle, successSubtitle }) => {
|
|
6
6
|
return ((isSent || error) && (React.createElement(WarningMessageStyle, { className: `message-container account-${error ? 'error' : 'success'}-color-bg` },
|
|
7
7
|
React.createElement(Text, { className: `account-p account-p4 message-title account-font-bold account-${error ? 'error' : 'success'}-color`, text: error || successTitle }),
|
|
8
8
|
!error && (React.createElement(Text, { className: `account-p account-p4 message-subtitle account-font-regular account-${error ? 'error' : 'success'}-color`, text: successSubtitle })))));
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
export default WarningMessage;
|
|
@@ -7,5 +7,5 @@ interface AccountSettingsProps {
|
|
|
7
7
|
onAccountUpdate: () => Promise<any>;
|
|
8
8
|
onPasswordUpdate: () => Promise<any>;
|
|
9
9
|
}
|
|
10
|
-
declare const AccountSettingsTemplate: ({
|
|
10
|
+
declare const AccountSettingsTemplate: ({ displayFields, accountFormFields, passwordFormFields }: AccountSettingsProps) => React.JSX.Element;
|
|
11
11
|
export default AccountSettingsTemplate;
|
|
@@ -2,9 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import AccountInfo from './AccountInfo';
|
|
3
3
|
import AccountPassword from './AccountPassword';
|
|
4
4
|
import AccountSettingsTemplateStyle from './style';
|
|
5
|
-
|
|
5
|
+
import { useAccountContext } from '../../../AccountProvider';
|
|
6
|
+
const AccountSettingsTemplate = ({ displayFields, accountFormFields, passwordFormFields }) => {
|
|
7
|
+
const { useUser } = useAccountContext();
|
|
8
|
+
const { user, updateAccount, updatePassword } = useUser();
|
|
6
9
|
return (React.createElement(AccountSettingsTemplateStyle, null,
|
|
7
|
-
React.createElement(AccountInfo, { user: user, onAccountUpdate:
|
|
8
|
-
React.createElement(AccountPassword, { onPasswordUpdate:
|
|
10
|
+
React.createElement(AccountInfo, { user: user, onAccountUpdate: updateAccount, displayFields: displayFields, formFields: accountFormFields }),
|
|
11
|
+
React.createElement(AccountPassword, { onPasswordUpdate: updatePassword, formFields: passwordFormFields })));
|
|
9
12
|
};
|
|
10
13
|
export default AccountSettingsTemplate;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export default AccountTemplate;
|
|
2
|
-
declare function AccountTemplate({ isFullWidth, menuOptions, children
|
|
2
|
+
declare function AccountTemplate({ isFullWidth, menuOptions, children }: {
|
|
3
3
|
isFullWidth?: boolean;
|
|
4
4
|
menuOptions?: any[];
|
|
5
5
|
children: any;
|
|
6
|
-
onSignOut: any;
|
|
7
6
|
}): React.JSX.Element;
|
|
8
7
|
import React from 'react';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { Text, Link, useUi, Page } from '@weareconceptstudio/core';
|
|
3
3
|
import AccountStyle from './style';
|
|
4
|
-
|
|
4
|
+
import { useAccountContext } from '../../../AccountProvider';
|
|
5
|
+
const AccountTemplate = ({ isFullWidth = false, menuOptions = [], children }) => {
|
|
5
6
|
const { winWidth } = useUi();
|
|
7
|
+
const { useUser } = useAccountContext();
|
|
8
|
+
const { user, isLoggedIn, signOut } = useUser();
|
|
6
9
|
//! Line Store
|
|
7
10
|
const lineStore = useMemo(() => {
|
|
8
11
|
if (winWidth < 1024) {
|
|
@@ -14,7 +17,7 @@ const AccountTemplate = ({ isFullWidth = false, menuOptions = [], children, onSi
|
|
|
14
17
|
return menuOptions.map((menuItem, index) => (React.createElement(Link, { key: index, href: menuItem.url, className: `menu-item ${menuItem.className ? menuItem.className : ''}`, ...menuItem.options },
|
|
15
18
|
React.createElement(Text, { tag: `span`, className: `account-p account-p1 account-font-bold sidebar-item`, text: menuItem.name }))));
|
|
16
19
|
}, [menuOptions]);
|
|
17
|
-
return (React.createElement(Page, { className: 'account use-account' },
|
|
20
|
+
return user && isLoggedIn ? (React.createElement(Page, { className: 'account use-account' },
|
|
18
21
|
React.createElement(AccountStyle, { className: 'account-container' },
|
|
19
22
|
React.createElement("div", { className: 'account-wrap' },
|
|
20
23
|
React.createElement("aside", { className: 'sidebar' },
|
|
@@ -23,9 +26,9 @@ const AccountTemplate = ({ isFullWidth = false, menuOptions = [], children, onSi
|
|
|
23
26
|
React.createElement(Text, { className: 'account-p account-p1 account-font-bold account-primary-color1', text: 'myAccount' }),
|
|
24
27
|
React.createElement("div", { className: `account-line` })),
|
|
25
28
|
React.createElement("div", { className: 'tabs-wrap' }, menu),
|
|
26
|
-
React.createElement(Text, { text: 'signOut', onClick:
|
|
29
|
+
React.createElement(Text, { text: 'signOut', onClick: signOut, className: 'account-p account-p1 account-error-color account-font-bold sign-out' }))),
|
|
27
30
|
lineStore,
|
|
28
31
|
React.createElement("div", { className: `right-bar` },
|
|
29
|
-
React.createElement("div", { className: `max-width-wrap ${isFullWidth ? 'full-max-width' : ''}` }, children))))));
|
|
32
|
+
React.createElement("div", { className: `max-width-wrap ${isFullWidth ? 'full-max-width' : ''}` }, children)))))) : null;
|
|
30
33
|
};
|
|
31
34
|
export default AccountTemplate;
|
|
@@ -38,6 +38,6 @@ const AddressForm = Memo(({ title, data, type }) => {
|
|
|
38
38
|
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'}` }))),
|
|
39
39
|
React.createElement("div", { className: `cancel-and-save-wrap` },
|
|
40
40
|
React.createElement(AccountButton, { text: `cancel`, onClick: closePopup, btnType: `green-large-text`, className: `address-form-cancel-btn` }),
|
|
41
|
-
React.createElement(AccountButton, { type: 'submit', text: `saveAndApply`, btnType: `full-width`, className: `address-form-cancel-submit
|
|
41
|
+
React.createElement(AccountButton, { type: 'submit', text: `saveAndApply`, btnType: `full-width`, className: `address-form-cancel-submit`, disabled: isDisabled })))));
|
|
42
42
|
});
|
|
43
43
|
export default AddressForm;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export default AddressItem;
|
|
2
|
-
declare function AddressItem({ type, title, data, checkout_review, select_address, onClick }: {
|
|
2
|
+
declare function AddressItem({ type, title, data, checkout_review, select_address, onClick, checkedId, setCheckedId, className }: {
|
|
3
3
|
type: any;
|
|
4
4
|
title: any;
|
|
5
5
|
data: any;
|
|
6
6
|
checkout_review: any;
|
|
7
7
|
select_address: any;
|
|
8
8
|
onClick: any;
|
|
9
|
+
checkedId: any;
|
|
10
|
+
setCheckedId: any;
|
|
11
|
+
className: any;
|
|
9
12
|
}): React.JSX.Element;
|
|
10
13
|
import React from 'react';
|
|
@@ -7,9 +7,9 @@ import AccountButton from '../../../components/AccountButton';
|
|
|
7
7
|
import WarningMessageForPopup from '../../../components/WarningMessageForPopup';
|
|
8
8
|
//* Style
|
|
9
9
|
import AddressItemStyle from './style';
|
|
10
|
-
const AddressItem = ({ type, title, data, checkout_review, select_address, onClick }) => {
|
|
10
|
+
const AddressItem = ({ type, title, data, checkout_review, select_address, onClick, checkedId, setCheckedId, className }) => {
|
|
11
11
|
const { openPopup } = useUi();
|
|
12
|
-
const { deleteAddress, selectedAddresses
|
|
12
|
+
const { deleteAddress, selectedAddresses } = useAddressContext();
|
|
13
13
|
//! Handle Popups
|
|
14
14
|
const handleDeletePopup = useCallback(() => {
|
|
15
15
|
openPopup(React.createElement(WarningMessageForPopup, { isDelete: true, title: 'deleteAddressMessage', description: 'confirmDeleteAddress', onRemove: () => deleteAddress(data.id, data.type) }), {
|
|
@@ -22,7 +22,7 @@ const AddressItem = ({ type, title, data, checkout_review, select_address, onCli
|
|
|
22
22
|
accountIcon: true,
|
|
23
23
|
});
|
|
24
24
|
}, [data]);
|
|
25
|
-
return (data && (React.createElement(AddressItemStyle, { className: `item-container` },
|
|
25
|
+
return (data && (React.createElement(AddressItemStyle, { className: `item-container ${className || ''}` },
|
|
26
26
|
checkout_review && (React.createElement("div", { className: `change-address-wrap` },
|
|
27
27
|
React.createElement(Text, { className: `account-p account-p2 account-font-bold account-primary-color1`, text: title }),
|
|
28
28
|
React.createElement(AccountButton, { text: `change`, btnType: `green-small-text`, onClick: onClick }))),
|
|
@@ -34,7 +34,7 @@ const AddressItem = ({ type, title, data, checkout_review, select_address, onCli
|
|
|
34
34
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1`, text: `${data.city}` }),
|
|
35
35
|
React.createElement(Text, { className: `account-p account-p3 account-font-regular account-primary-color1 phone col-wrap`, text: `${data.phone}` })),
|
|
36
36
|
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` })),
|
|
37
|
-
select_address && (React.createElement("div", { className: `circle-selected-wrap cursor-pointer ${
|
|
37
|
+
select_address && (React.createElement("div", { className: `circle-selected-wrap cursor-pointer ${checkedId == data.id ? 'active' : ''}`, onClick: () => setCheckedId(data.id) },
|
|
38
38
|
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'}` },
|
|
39
39
|
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' }))))),
|
|
40
40
|
!checkout_review && (React.createElement("div", { className: `edit-remove-wrapper` },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { api } from '@weareconceptstudio/core';
|
|
3
3
|
const AddressContext = createContext(null);
|
|
4
4
|
export const useAddressContext = () => {
|
|
@@ -6,8 +6,8 @@ export const useAddressContext = () => {
|
|
|
6
6
|
return context;
|
|
7
7
|
};
|
|
8
8
|
export const AddressProvider = ({ addressType, addressFormFields = [], useUser, useCart, children }) => {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const { isLoggedIn } = useUser();
|
|
10
|
+
const { getCart } = useCart();
|
|
11
11
|
const [addressLoading, setAddressLoading] = useState(true);
|
|
12
12
|
const [addresses, setAddresses] = useState(addressType ? { billing: [], shipping: [] } : []);
|
|
13
13
|
const [selectedAddresses, setSelectedAddresses] = useState(addressType ? { billing: {}, shipping: {} } : {});
|
|
@@ -22,7 +22,7 @@ export const AddressProvider = ({ addressType, addressFormFields = [], useUser,
|
|
|
22
22
|
return addresses.length > 0;
|
|
23
23
|
}, [hasAddressType, addresses]);
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
if (
|
|
25
|
+
if (isLoggedIn) {
|
|
26
26
|
api.get({ url: 'addresses' }).then((res) => {
|
|
27
27
|
setAddresses(res.data);
|
|
28
28
|
setSelectedAddresses(addressType
|
|
@@ -34,7 +34,7 @@ export const AddressProvider = ({ addressType, addressFormFields = [], useUser,
|
|
|
34
34
|
setAddressLoading(false);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
}, [
|
|
37
|
+
}, [isLoggedIn]);
|
|
38
38
|
const createAddress = async (data) => {
|
|
39
39
|
return await api.post('addresses', data).then((res) => {
|
|
40
40
|
setAddresses(res.data);
|
|
@@ -56,10 +56,11 @@ export const AddressProvider = ({ addressType, addressFormFields = [], useUser,
|
|
|
56
56
|
setAddresses(res.data);
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
|
-
const selectAddress = (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const selectAddress = ({ checkedId, type }) => {
|
|
60
|
+
const checkedAddress = (type ? addresses[type] : addresses).find((item) => item.id === checkedId);
|
|
61
|
+
setSelectedAddresses(checkedAddress);
|
|
62
|
+
setCheckoutAddressId(checkedId);
|
|
63
|
+
getCart({ addressId: checkedId });
|
|
63
64
|
};
|
|
64
65
|
return (React.createElement(AddressContext.Provider, { value: {
|
|
65
66
|
addressLoading,
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useUi } from '@weareconceptstudio/core';
|
|
2
3
|
import { useAddressContext } from '../AddressProvider';
|
|
3
|
-
import
|
|
4
|
-
import AddressForm from '../AddressForm';
|
|
4
|
+
import SelectAddressPopup from '../SelectAddressPopup';
|
|
5
5
|
import AddressItem from '../AddressItem';
|
|
6
|
-
|
|
7
|
-
import SelectAddressStyle from './style';
|
|
8
|
-
const SelectAddress = ({ type, title }) => {
|
|
6
|
+
const SelectAddress = () => {
|
|
9
7
|
const { openPopup } = useUi();
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
const addressContext = useAddressContext();
|
|
9
|
+
const { selectedAddresses, setSelectedAddresses, hasAddressType } = addressContext;
|
|
10
|
+
const handleSelectPopup = useCallback(({ title, type }) => {
|
|
11
|
+
openPopup(React.createElement(SelectAddressPopup, { title: title, type: type }), { accountIcon: true });
|
|
12
|
+
}, []);
|
|
13
|
+
return (React.createElement("div", { className: `shipping-billing-change-wrapper` }, hasAddressType ? (React.createElement(React.Fragment, null,
|
|
14
|
+
React.createElement(AddressItem, { checkout_review: true, type: 'shipping', select_address: false, title: 'shippingAddress', data: selectedAddresses.shipping, onClick: () => handleSelectPopup({
|
|
15
|
+
title: 'selectShippingAddress',
|
|
16
|
+
type: 'shipping',
|
|
17
|
+
}), setSelectedAddresses: setSelectedAddresses }),
|
|
18
|
+
React.createElement(AddressItem, { checkout_review: true, type: 'billing', select_address: false, title: 'billingAddress', data: selectedAddresses.billing, onClick: () => handleSelectPopup({
|
|
19
|
+
title: 'selectBillingAddress',
|
|
20
|
+
type: 'billing',
|
|
21
|
+
}) }))) : (React.createElement(AddressItem, { checkout_review: true, type: 'shipping', title: 'address', className: 'full', select_address: false, data: selectedAddresses, onClick: () => handleSelectPopup({
|
|
22
|
+
title: 'address',
|
|
23
|
+
type: null,
|
|
24
|
+
}) }))));
|
|
23
25
|
};
|
|
24
26
|
export default SelectAddress;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { memo as Memo, useCallback, useState } from 'react';
|
|
2
|
+
import { useUi, Text } from '@weareconceptstudio/core';
|
|
3
|
+
//* Components
|
|
4
|
+
import AddressForm from '../AddressForm';
|
|
5
|
+
import AddressItem from '../AddressItem';
|
|
6
|
+
import AccountButton from '../../../components/AccountButton';
|
|
7
|
+
//* Style
|
|
8
|
+
import SelectAddressPopupStyle from './style';
|
|
9
|
+
import { useAddressContext } from '../AddressProvider';
|
|
10
|
+
const SelectAddressPopup = Memo(({ title, type }) => {
|
|
11
|
+
const { openPopup, closePopup } = useUi();
|
|
12
|
+
const { selectAddress, addresses, hasAddressType, selectedAddresses } = useAddressContext();
|
|
13
|
+
const [checkedId, setCheckedId] = useState(() => selectedAddresses.id, [selectedAddresses]);
|
|
14
|
+
const handleNewAddressPopup = () => {
|
|
15
|
+
openPopup(React.createElement(AddressForm, { title: type == 'shipping' ? `addNewShippingAddress` : type == 'billing' ? 'addNewBillingAddress' : 'addNewAddress', selected: { value: false, type: type } }), {
|
|
16
|
+
accountIcon: true,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const handleAddressChangeSubmit = useCallback(() => {
|
|
20
|
+
selectAddress({ checkedId, type });
|
|
21
|
+
closePopup();
|
|
22
|
+
}, [checkedId]);
|
|
23
|
+
return (React.createElement(SelectAddressPopupStyle, null,
|
|
24
|
+
React.createElement("div", { className: `select-address-wrap` },
|
|
25
|
+
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 }),
|
|
26
|
+
React.createElement(AccountButton, { onClick: handleNewAddressPopup, text: `addNewAdd`, btnType: hasAddressType ? `purple-text` : 'green-small-text' })),
|
|
27
|
+
addresses?.length > 0 ? (React.createElement("div", { className: `flex-wrapper` }, addresses.map((item, index) => {
|
|
28
|
+
return (React.createElement(AddressItem, { id: item.id, type: type, data: item, key: index, select_address: true, checkout_review: false, checkedId: checkedId, setCheckedId: setCheckedId }));
|
|
29
|
+
}))) : null,
|
|
30
|
+
React.createElement("div", { className: `cancel-and-save-wrap` },
|
|
31
|
+
React.createElement(AccountButton, { btnType: `green-large-text`, text: `cancel`, onClick: closePopup }),
|
|
32
|
+
React.createElement(AccountButton, { btnType: `full-width`, text: `saveAndApply`, onClick: handleAddressChangeSubmit }))));
|
|
33
|
+
});
|
|
34
|
+
export default SelectAddressPopup;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default SelectAddressPopupStyle;
|
|
2
|
+
declare const SelectAddressPopupStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
const
|
|
2
|
+
const SelectAddressPopupStyle = styled.section `
|
|
3
3
|
--account_cancelAndSaveWrapMTop: var(--sp5x);
|
|
4
4
|
--account_cancelDistance: var(--sp5x);
|
|
5
|
+
--account_selectAddressWrapMBot: var(--sp5x);
|
|
6
|
+
--account_itemDistance: var(--sp3x);
|
|
7
|
+
|
|
8
|
+
.select-address-wrap {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
align-items: center;
|
|
13
|
+
margin-bottom: var(--account_selectAddressWrapMBot);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.flex-wrapper {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-wrap: wrap;
|
|
19
|
+
margin-left: calc(-1 * calc(var(--account_itemDistance) / 2));
|
|
20
|
+
margin-right: calc(-1 * calc(var(--account_itemDistance) / 2));
|
|
21
|
+
|
|
22
|
+
.item-container {
|
|
23
|
+
&:not(:nth-child(1), :nth-child(2)) {
|
|
24
|
+
margin-top: var(--account_itemDistance) !important;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
5
28
|
|
|
6
29
|
.cancel-and-save-wrap {
|
|
7
30
|
display: flex;
|
|
@@ -19,36 +42,50 @@ const SelectShippingBillingAddressStyle = styled.section `
|
|
|
19
42
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeL}) {
|
|
20
43
|
--account_cancelAndSaveWrapMTop: var(--sp4x);
|
|
21
44
|
--account_cancelDistance: var(--sp3x);
|
|
45
|
+
--account_selectAddressWrapMBot: var(--sp4x);
|
|
46
|
+
--account_itemDistance: var(--sp3x);
|
|
22
47
|
}
|
|
23
48
|
|
|
24
49
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeLMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeM}) {
|
|
25
50
|
--account_cancelAndSaveWrapMTop: var(--sp3x);
|
|
26
51
|
--account_cancelDistance: var(--sp3x);
|
|
52
|
+
--account_selectAddressWrapMBot: var(--sp3x);
|
|
53
|
+
--account_itemDistance: var(--sp2x);
|
|
27
54
|
}
|
|
28
55
|
|
|
29
56
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeMMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeS}) {
|
|
30
57
|
--account_cancelAndSaveWrapMTop: var(--sp3x);
|
|
31
58
|
--account_cancelDistance: var(--sp3x);
|
|
59
|
+
--account_selectAddressWrapMBot: var(--sp3x);
|
|
60
|
+
--account_itemDistance: var(--sp2x);
|
|
32
61
|
}
|
|
33
62
|
|
|
34
63
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXS}) {
|
|
35
64
|
--account_cancelAndSaveWrapMTop: var(--sp3x);
|
|
36
65
|
--account_cancelDistance: var(--sp2-5x);
|
|
66
|
+
--account_selectAddressWrapMBot: var(--sp3x);
|
|
67
|
+
--account_itemDistance: var(--sp2x);
|
|
37
68
|
}
|
|
38
69
|
|
|
39
70
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_DesktopSizeXSMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSize}) {
|
|
40
71
|
--account_cancelAndSaveWrapMTop: var(--sp3x);
|
|
41
72
|
--account_cancelDistance: var(--sp2-5x);
|
|
73
|
+
--account_selectAddressWrapMBot: var(--sp3x);
|
|
74
|
+
--account_itemDistance: var(--sp2x);
|
|
42
75
|
}
|
|
43
76
|
|
|
44
77
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeMin}) and (min-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeS}) {
|
|
45
78
|
--account_cancelAndSaveWrapMTop: var(--sp3x);
|
|
46
79
|
--account_cancelDistance: var(--sp2-5x);
|
|
80
|
+
--account_selectAddressWrapMBot: var(--sp3x);
|
|
81
|
+
--account_itemDistance: var(--sp2x);
|
|
47
82
|
}
|
|
48
83
|
|
|
49
84
|
@media only screen and (max-width: ${(props) => props.theme.account.mediaQuery.account_TabletSizeSMin}) {
|
|
50
85
|
--account_cancelAndSaveWrapMTop: var(--sp3x);
|
|
51
86
|
--account_cancelDistance: var(--sp2x);
|
|
87
|
+
--account_selectAddressWrapMBot: var(--sp3x);
|
|
88
|
+
--account_itemDistance: var(--sp2x);
|
|
52
89
|
|
|
53
90
|
.cancel-and-save-wrap {
|
|
54
91
|
flex-direction: column-reverse;
|
|
@@ -66,4 +103,4 @@ const SelectShippingBillingAddressStyle = styled.section `
|
|
|
66
103
|
}
|
|
67
104
|
}
|
|
68
105
|
`;
|
|
69
|
-
export default
|
|
106
|
+
export default SelectAddressPopupStyle;
|
|
@@ -6,5 +6,4 @@ export { default as AddressItem } from "./AddressItem";
|
|
|
6
6
|
export { default as SelectAddress } from "./SelectAddress";
|
|
7
7
|
export { default as ShippingBillingInfo } from "./ShippingBillingInfo";
|
|
8
8
|
export { default as ShippingBillingForm } from "./ShippingBillingForm";
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as SelectShippingBillingPopup } from "./SelectShippingBillingPopup";
|
|
9
|
+
export { default as SelectShippingBillingPopup } from "./SelectAddressPopup";
|
|
@@ -7,4 +7,4 @@ export { default as SelectAddress } from './SelectAddress';
|
|
|
7
7
|
export { default as ShippingBillingInfo } from './ShippingBillingInfo';
|
|
8
8
|
export { default as ShippingBillingForm } from './ShippingBillingForm';
|
|
9
9
|
export { default as SelectShippingBilling } from './SelectShippingBilling';
|
|
10
|
-
export { default as SelectShippingBillingPopup } from './
|
|
10
|
+
export { default as SelectShippingBillingPopup } from './SelectAddressPopup';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface ForgotPasswordProps {
|
|
3
|
-
|
|
3
|
+
signInUrl?: string;
|
|
4
4
|
}
|
|
5
|
-
declare const ForgotPasswordTemplate: ({
|
|
5
|
+
declare const ForgotPasswordTemplate: ({ signInUrl }: ForgotPasswordProps) => React.JSX.Element;
|
|
6
6
|
export default ForgotPasswordTemplate;
|