@sonic-equipment/ui 199.0.0 → 201.0.0
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/algolia/algolia-multi-select-filter-section.js +1 -1
- package/dist/country-select/hooks/use-countries.d.ts +2 -2
- package/dist/country-select/hooks/use-countries.js +1 -1
- package/dist/exports.d.ts +8 -2
- package/dist/forms/elements/checkbox/checkbox.d.ts +1 -0
- package/dist/forms/elements/checkbox/checkbox.js +1 -1
- package/dist/forms/elements/checkbox/checkbox.module.css.js +1 -1
- package/dist/forms/partials/address-form/address-form.d.ts +11 -0
- package/dist/forms/partials/address-form/address-form.js +36 -0
- package/dist/forms/partials/address-form/address-form.module.css.js +3 -0
- package/dist/header/buttons/account/connected-account-button.js +9 -2
- package/dist/index.js +9 -3
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/pages/account/components/sign-in-form/sign-in-form.d.ts +2 -1
- package/dist/pages/account/components/sign-in-form/sign-in-form.js +8 -6
- package/dist/pages/account/sign-in-page/sign-in-page.js +2 -2
- package/dist/pages/checkout/shipping-page/components/edit-checkout-bill-to-address-form.js +2 -2
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.js +1 -1
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.d.ts +4 -0
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js +90 -0
- package/dist/pages/my-sonic/actions/create-ship-to-address/create-ship-to-address.module.css.js +3 -0
- package/dist/pages/my-sonic/actions/edit-bill-to-address/connected-edit-bill-to-address-form.d.ts +4 -0
- package/dist/pages/my-sonic/actions/edit-bill-to-address/connected-edit-bill-to-address-form.js +95 -0
- package/dist/pages/my-sonic/actions/edit-bill-to-address/edit-bill-to-address.module.css.js +3 -0
- package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.d.ts +5 -0
- package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.js +127 -0
- package/dist/pages/my-sonic/actions/edit-ship-to-address/edit-ship-to-address.module.css.js +3 -0
- package/dist/pages/my-sonic/widgets/components/address-data-card.d.ts +2 -2
- package/dist/pages/my-sonic/widgets/components/address-data-card.js +2 -6
- package/dist/pages/my-sonic/widgets/connected-bill-to-address-widget.d.ts +3 -1
- package/dist/pages/my-sonic/widgets/connected-bill-to-address-widget.js +13 -4
- package/dist/pages/my-sonic/widgets/connected-ship-to-address-widget.d.ts +4 -1
- package/dist/pages/my-sonic/widgets/connected-ship-to-address-widget.js +18 -4
- package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-address.d.ts +4 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-address.js +11 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-current-bill-to-address.d.ts +3 -1
- package/dist/shared/api/storefront/hooks/customer/use-fetch-current-bill-to-address.js +3 -7
- package/dist/shared/api/storefront/hooks/customer/use-fetch-current-ship-to-address.d.ts +3 -1
- package/dist/shared/api/storefront/hooks/customer/use-fetch-current-ship-to-address.js +6 -12
- package/dist/shared/api/storefront/hooks/customer/use-fetch-ship-to-address.d.ts +5 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-ship-to-address.js +18 -0
- package/dist/shared/api/storefront/hooks/customer/use-patch-ship-to-address.d.ts +13 -0
- package/dist/shared/api/storefront/hooks/customer/use-patch-ship-to-address.js +17 -0
- package/dist/shared/api/storefront/hooks/customer/use-post-ship-to-address.d.ts +17 -0
- package/dist/shared/api/storefront/hooks/customer/use-post-ship-to-address.js +17 -0
- package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.d.ts +1 -1
- package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.js +1 -1
- package/dist/shared/api/storefront/hooks/product/use-mark-product-as-viewed.js +3 -1
- package/dist/shared/api/storefront/hooks/wishlist/use-add-wishlist-item-to-current-wishlist.js +2 -2
- package/dist/shared/api/storefront/hooks/wishlist/use-delete-wishlist-item-from-wishlist.js +2 -2
- package/dist/shared/api/storefront/model/storefront.model.d.ts +12 -0
- package/dist/shared/api/storefront/services/account-service.js +5 -0
- package/dist/shared/api/storefront/services/customer-service.d.ts +24 -3
- package/dist/shared/api/storefront/services/customer-service.js +39 -5
- package/dist/shared/hooks/use-cookiebot.js +9 -5
- package/dist/shared/routing/types.d.ts +2 -0
- package/dist/styles.css +93 -7
- package/package.json +1 -1
- package/dist/forms/partials/edit-address-form/edit-address-form.d.ts +0 -9
- package/dist/forms/partials/edit-address-form/edit-address-form.js +0 -36
- package/dist/forms/partials/edit-address-form/edit-address-form.module.css.js +0 -3
- package/dist/pages/my-sonic/actions/edit-bill-to-address/edit-bill-to-address.d.ts +0 -1
- package/dist/pages/my-sonic/actions/edit-bill-to-address/edit-bill-to-address.js +0 -8
package/dist/pages/my-sonic/actions/edit-bill-to-address/connected-edit-bill-to-address-form.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { Button } from '../../../../buttons/button/button.js';
|
|
5
|
+
import { useCountries } from '../../../../country-select/hooks/use-countries.js';
|
|
6
|
+
import { Form } from '../../../../forms/layout/form/form.js';
|
|
7
|
+
import { AddressForm } from '../../../../forms/partials/address-form/address-form.js';
|
|
8
|
+
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
9
|
+
import { Message } from '../../../../message/message.js';
|
|
10
|
+
import { useFetchBillToAddress } from '../../../../shared/api/storefront/hooks/customer/use-fetch-bill-to-address.js';
|
|
11
|
+
import { usePatchBillToAddress } from '../../../../shared/api/storefront/hooks/customer/use-patch-bill-to-address.js';
|
|
12
|
+
import { NotFoundRequestError } from '../../../../shared/fetch/request.js';
|
|
13
|
+
import { useNavigate } from '../../../../shared/routing/use-navigate.js';
|
|
14
|
+
import { Heading } from '../../../../typography/heading/heading.js';
|
|
15
|
+
import { ErrorPage } from '../../../error-page/error-page.js';
|
|
16
|
+
import { LoadingPage } from '../../../loading-page/loading-page.js';
|
|
17
|
+
import formStyles from '../../../../forms/partials/address-form/address-form.module.css.js';
|
|
18
|
+
import styles from './edit-bill-to-address.module.css.js';
|
|
19
|
+
|
|
20
|
+
function ConnectedEditBillToAddressForm({ billToId, returnUrl, }) {
|
|
21
|
+
const { navigate } = useNavigate();
|
|
22
|
+
const { countries, currentCountry, error: errorCountries, isFetching: isLoadingCountries, } = useCountries();
|
|
23
|
+
const { data: billToAddress, error: errorBillToAddress, isLoading: isLoadingBillToAddress, } = useFetchBillToAddress({ billToId, includeValidation: true });
|
|
24
|
+
const { isLoading: isPatchingBillToAddress, isSuccess, mutate: patchBillToAddress, } = usePatchBillToAddress();
|
|
25
|
+
const isPatching = isPatchingBillToAddress;
|
|
26
|
+
const isReadonly = useMemo(() => {
|
|
27
|
+
if (billToAddress?.validation?.address1?.isDisabled)
|
|
28
|
+
return true;
|
|
29
|
+
if (billToAddress?.validation?.address2?.isDisabled)
|
|
30
|
+
return true;
|
|
31
|
+
if (billToAddress?.validation?.address3?.isDisabled)
|
|
32
|
+
return true;
|
|
33
|
+
if (billToAddress?.validation?.address4?.isDisabled)
|
|
34
|
+
return true;
|
|
35
|
+
if (billToAddress?.validation?.attention?.isDisabled)
|
|
36
|
+
return true;
|
|
37
|
+
if (billToAddress?.validation?.city?.isDisabled)
|
|
38
|
+
return true;
|
|
39
|
+
if (billToAddress?.validation?.companyName?.isDisabled)
|
|
40
|
+
return true;
|
|
41
|
+
if (billToAddress?.validation?.country?.isDisabled)
|
|
42
|
+
return true;
|
|
43
|
+
if (billToAddress?.validation?.email?.isDisabled)
|
|
44
|
+
return true;
|
|
45
|
+
if (billToAddress?.validation?.fax?.isDisabled)
|
|
46
|
+
return true;
|
|
47
|
+
if (billToAddress?.validation?.firstName?.isDisabled)
|
|
48
|
+
return true;
|
|
49
|
+
if (billToAddress?.validation?.lastName?.isDisabled)
|
|
50
|
+
return true;
|
|
51
|
+
if (billToAddress?.validation?.phone?.isDisabled)
|
|
52
|
+
return true;
|
|
53
|
+
if (billToAddress?.validation?.postalCode?.isDisabled)
|
|
54
|
+
return true;
|
|
55
|
+
if (billToAddress?.validation?.state?.isDisabled)
|
|
56
|
+
return true;
|
|
57
|
+
return false;
|
|
58
|
+
}, [billToAddress]);
|
|
59
|
+
if (isLoadingBillToAddress || isLoadingCountries)
|
|
60
|
+
return jsx(LoadingPage, {});
|
|
61
|
+
if (errorBillToAddress && errorBillToAddress instanceof NotFoundRequestError)
|
|
62
|
+
return (jsx(Heading, { size: "l", children: jsx(FormattedMessage, { id: "Address not found" }) }));
|
|
63
|
+
if (errorBillToAddress)
|
|
64
|
+
return jsx(ErrorPage, { error: errorBillToAddress });
|
|
65
|
+
if (errorCountries)
|
|
66
|
+
return jsx(ErrorPage, { error: errorCountries });
|
|
67
|
+
if (!billToAddress || !countries) {
|
|
68
|
+
return (jsx(ErrorPage, { error: new Error('No bill to address or countries data available.') }));
|
|
69
|
+
}
|
|
70
|
+
return (jsxs(Form, { className: formStyles.form, "data-test-selector": "billToAddressForm", onSubmit: ({ formData }) => {
|
|
71
|
+
const countryFormValue = formData.get('countrySelect')?.toString();
|
|
72
|
+
const country = countries.find(country => country.id === countryFormValue);
|
|
73
|
+
if (!country)
|
|
74
|
+
throw new Error(`Country not found ${formData.get('country')}`);
|
|
75
|
+
patchBillToAddress({
|
|
76
|
+
billTo: {
|
|
77
|
+
...billToAddress,
|
|
78
|
+
address1: formData.get('address1')?.toString() || '',
|
|
79
|
+
address2: formData.get('address2')?.toString() || '',
|
|
80
|
+
address3: formData.get('address3')?.toString() || '',
|
|
81
|
+
attention: formData.get('attention')?.toString() || '',
|
|
82
|
+
city: formData.get('city')?.toString() || '',
|
|
83
|
+
companyName: formData.get('companyName')?.toString() || '',
|
|
84
|
+
country,
|
|
85
|
+
email: formData.get('email')?.toString() || '',
|
|
86
|
+
firstName: formData.get('firstName')?.toString() || '',
|
|
87
|
+
lastName: formData.get('lastName')?.toString() || '',
|
|
88
|
+
phone: formData.get('phone')?.toString() || '',
|
|
89
|
+
postalCode: formData.get('postalCode')?.toString() || '',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}, children: [jsx(AddressForm, { address: billToAddress, countries: countries, currentCountry: currentCountry, isReadonly: isReadonly }), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), !isReadonly && (jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) }))] })] }));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { ConnectedEditBillToAddressForm };
|
package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { Button } from '../../../../buttons/button/button.js';
|
|
5
|
+
import { useCountries } from '../../../../country-select/hooks/use-countries.js';
|
|
6
|
+
import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
|
|
7
|
+
import { Form } from '../../../../forms/layout/form/form.js';
|
|
8
|
+
import { AddressForm } from '../../../../forms/partials/address-form/address-form.js';
|
|
9
|
+
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
10
|
+
import { Message } from '../../../../message/message.js';
|
|
11
|
+
import { usePatchCurrentAccount } from '../../../../shared/api/storefront/hooks/account/use-patch-current-account.js';
|
|
12
|
+
import { usePatchSession } from '../../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
|
|
13
|
+
import { useFetchShipToAddress } from '../../../../shared/api/storefront/hooks/customer/use-fetch-ship-to-address.js';
|
|
14
|
+
import { usePatchShipToAddress } from '../../../../shared/api/storefront/hooks/customer/use-patch-ship-to-address.js';
|
|
15
|
+
import { NotFoundRequestError } from '../../../../shared/fetch/request.js';
|
|
16
|
+
import { useNavigate } from '../../../../shared/routing/use-navigate.js';
|
|
17
|
+
import { Heading } from '../../../../typography/heading/heading.js';
|
|
18
|
+
import { ErrorPage } from '../../../error-page/error-page.js';
|
|
19
|
+
import { LoadingPage } from '../../../loading-page/loading-page.js';
|
|
20
|
+
import formStyles from '../../../../forms/partials/address-form/address-form.module.css.js';
|
|
21
|
+
import styles from './edit-ship-to-address.module.css.js';
|
|
22
|
+
|
|
23
|
+
function ConnectedEditShipToAddressForm({ billToId, returnUrl, shipToId, }) {
|
|
24
|
+
const { navigate } = useNavigate();
|
|
25
|
+
const { countries, currentCountry, error: errorCountries, isFetching: isLoadingCountries, } = useCountries();
|
|
26
|
+
const { data: shipToAddress, error: errorShipToAddress, isLoading: isLoadingShipToAddress, } = useFetchShipToAddress({ billToId, includeValidation: true, shipToId });
|
|
27
|
+
const { isLoading: isPatchingShipToAddress, isSuccess, mutate: patchShipToAddress, } = usePatchShipToAddress();
|
|
28
|
+
const { isLoading: isPatchingSession, mutate: patchSession } = usePatchSession();
|
|
29
|
+
const { isLoading: isPatchingCurrentAccount, mutate: patchCurrentAccount } = usePatchCurrentAccount();
|
|
30
|
+
const isPatching = isPatchingShipToAddress || isPatchingSession || isPatchingCurrentAccount;
|
|
31
|
+
const isReadonly = useMemo(() => {
|
|
32
|
+
if (shipToAddress?.validation?.address1?.isDisabled)
|
|
33
|
+
return true;
|
|
34
|
+
if (shipToAddress?.validation?.address2?.isDisabled)
|
|
35
|
+
return true;
|
|
36
|
+
if (shipToAddress?.validation?.address3?.isDisabled)
|
|
37
|
+
return true;
|
|
38
|
+
if (shipToAddress?.validation?.address4?.isDisabled)
|
|
39
|
+
return true;
|
|
40
|
+
if (shipToAddress?.validation?.attention?.isDisabled)
|
|
41
|
+
return true;
|
|
42
|
+
if (shipToAddress?.validation?.city?.isDisabled)
|
|
43
|
+
return true;
|
|
44
|
+
if (shipToAddress?.validation?.companyName?.isDisabled)
|
|
45
|
+
return true;
|
|
46
|
+
if (shipToAddress?.validation?.country?.isDisabled)
|
|
47
|
+
return true;
|
|
48
|
+
if (shipToAddress?.validation?.email?.isDisabled)
|
|
49
|
+
return true;
|
|
50
|
+
if (shipToAddress?.validation?.fax?.isDisabled)
|
|
51
|
+
return true;
|
|
52
|
+
if (shipToAddress?.validation?.firstName?.isDisabled)
|
|
53
|
+
return true;
|
|
54
|
+
if (shipToAddress?.validation?.lastName?.isDisabled)
|
|
55
|
+
return true;
|
|
56
|
+
if (shipToAddress?.validation?.phone?.isDisabled)
|
|
57
|
+
return true;
|
|
58
|
+
if (shipToAddress?.validation?.postalCode?.isDisabled)
|
|
59
|
+
return true;
|
|
60
|
+
if (shipToAddress?.validation?.state?.isDisabled)
|
|
61
|
+
return true;
|
|
62
|
+
return false;
|
|
63
|
+
}, [shipToAddress]);
|
|
64
|
+
if (isLoadingShipToAddress || isLoadingCountries)
|
|
65
|
+
return jsx(LoadingPage, {});
|
|
66
|
+
if (errorShipToAddress && errorShipToAddress instanceof NotFoundRequestError)
|
|
67
|
+
return (jsx(Heading, { size: "l", children: jsx(FormattedMessage, { id: "Address not found" }) }));
|
|
68
|
+
if (errorShipToAddress)
|
|
69
|
+
return jsx(ErrorPage, { error: errorShipToAddress });
|
|
70
|
+
if (errorCountries)
|
|
71
|
+
return jsx(ErrorPage, { error: errorCountries });
|
|
72
|
+
if (!shipToAddress || !countries) {
|
|
73
|
+
return (jsx(ErrorPage, { error: new Error('No ship to address or countries data available.') }));
|
|
74
|
+
}
|
|
75
|
+
return (jsxs(Form, { className: formStyles.form, "data-test-selector": "shipToAddressForm", onSubmit: async ({ formData }) => {
|
|
76
|
+
const countryFormValue = formData.get('countrySelect')?.toString();
|
|
77
|
+
const country = countries.find(country => country.id === countryFormValue);
|
|
78
|
+
if (!country)
|
|
79
|
+
throw new Error(`Country not found ${formData.get('country')}`);
|
|
80
|
+
const isDefault = formData.get('setAsDefault')?.toString() === 'TRUE' || false;
|
|
81
|
+
const patchedShipToAddress = await patchShipToAddress({
|
|
82
|
+
billToId,
|
|
83
|
+
shipTo: {
|
|
84
|
+
...shipToAddress,
|
|
85
|
+
address1: formData.get('address1')?.toString() || '',
|
|
86
|
+
address2: formData.get('address2')?.toString() || '',
|
|
87
|
+
address3: formData.get('address3')?.toString() || '',
|
|
88
|
+
attention: formData.get('attention')?.toString() || '',
|
|
89
|
+
city: formData.get('city')?.toString() || '',
|
|
90
|
+
companyName: formData.get('companyName')?.toString() || '',
|
|
91
|
+
country,
|
|
92
|
+
email: formData.get('email')?.toString() || '',
|
|
93
|
+
firstName: formData.get('firstName')?.toString() || '',
|
|
94
|
+
isDefault,
|
|
95
|
+
lastName: formData.get('lastName')?.toString() || '',
|
|
96
|
+
phone: formData.get('phone')?.toString() || '',
|
|
97
|
+
postalCode: formData.get('postalCode')?.toString() || '',
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
if (!shipToAddress.isDefault && isDefault) {
|
|
101
|
+
await patchSession({
|
|
102
|
+
session: {
|
|
103
|
+
customerWasUpdated: true,
|
|
104
|
+
shipTo: { id: patchedShipToAddress.id, isDefault: true },
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
await patchCurrentAccount({
|
|
108
|
+
account: {
|
|
109
|
+
defaultCustomerId: patchedShipToAddress.id,
|
|
110
|
+
defaultFulfillmentMethod: 'Ship',
|
|
111
|
+
setDefaultCustomer: true,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (shipToAddress.isDefault && !isDefault) {
|
|
116
|
+
await patchCurrentAccount({
|
|
117
|
+
account: {
|
|
118
|
+
defaultCustomerId: null,
|
|
119
|
+
defaultFulfillmentMethod: 'Ship',
|
|
120
|
+
setDefaultCustomer: true,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}, children: [jsx(AddressForm, { address: shipToAddress, countries: countries, currentCountry: currentCountry, isLoading: isPatching, isReadonly: isReadonly || isPatching }), shipToAddress.id !== 'current' && (jsx(Checkbox, { defaultSelected: shipToAddress.isDefault, isDisabled: isReadonly || isPatching, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), !isReadonly && (jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) }))] })] }));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { ConnectedEditShipToAddressForm };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataCardProps } from '../../../../cards/data-card/data-card';
|
|
2
2
|
export interface AddressDataCardProps {
|
|
3
|
+
actions?: DataCardProps['actions'];
|
|
3
4
|
data: {
|
|
4
5
|
address1: string | undefined;
|
|
5
6
|
address2: string | undefined;
|
|
@@ -16,8 +17,7 @@ export interface AddressDataCardProps {
|
|
|
16
17
|
};
|
|
17
18
|
'data-test-selector'?: string;
|
|
18
19
|
isLoading?: DataCardProps['isLoading'];
|
|
19
|
-
onEdit?: VoidFunction;
|
|
20
20
|
showError?: DataCardProps['showError'];
|
|
21
21
|
title?: DataCardProps['title'];
|
|
22
22
|
}
|
|
23
|
-
export declare function AddressDataCard({ data: { address1, address2, address3, address4, attention, city, country, email, firstName, lastName, phone, postalCode, }, 'data-test-selector': dataTestSelector, isLoading,
|
|
23
|
+
export declare function AddressDataCard({ actions, data: { address1, address2, address3, address4, attention, city, country, email, firstName, lastName, phone, postalCode, }, 'data-test-selector': dataTestSelector, isLoading, showError, title, }: AddressDataCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { Button } from '../../../../buttons/button/button.js';
|
|
4
3
|
import { DataCard } from '../../../../cards/data-card/data-card.js';
|
|
5
|
-
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
6
4
|
|
|
7
|
-
function AddressDataCard({ data: { address1, address2, address3, address4, attention, city, country, email, firstName, lastName, phone, postalCode, }, 'data-test-selector': dataTestSelector, isLoading = false,
|
|
5
|
+
function AddressDataCard({ actions, data: { address1, address2, address3, address4, attention, city, country, email, firstName, lastName, phone, postalCode, }, 'data-test-selector': dataTestSelector, isLoading = false, showError = false, title, }) {
|
|
8
6
|
const data = [
|
|
9
7
|
{ key: 'first-name', label: 'First name', value: firstName },
|
|
10
8
|
{ key: 'last-name', label: 'Last name', value: lastName },
|
|
@@ -39,9 +37,7 @@ function AddressDataCard({ data: { address1, address2, address3, address4, atten
|
|
|
39
37
|
{ key: 'email', label: 'Email', value: email },
|
|
40
38
|
{ key: 'phone', label: 'Phone', value: phone },
|
|
41
39
|
];
|
|
42
|
-
return (jsx(DataCard, { actions:
|
|
43
|
-
jsx(Button, { isDisabled: true, color: "secondary", onClick: onEdit, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Edit" }) }, "edit"),
|
|
44
|
-
], data: data, "data-test-selector": dataTestSelector, isLoading: isLoading, showError: showError, title: title }));
|
|
40
|
+
return (jsx(DataCard, { actions: actions, data: data, "data-test-selector": dataTestSelector, isLoading: isLoading, showError: showError, title: title }));
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
export { AddressDataCard };
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from '../../../buttons/button/button.js';
|
|
4
|
+
import { FormattedMessage } from '../../../intl/formatted-message.js';
|
|
5
|
+
import { useFetchBillToAddress } from '../../../shared/api/storefront/hooks/customer/use-fetch-bill-to-address.js';
|
|
6
|
+
import { useLocation } from '../../../shared/routing/use-location.js';
|
|
7
|
+
import { usePaths } from '../../../shared/routing/use-paths.js';
|
|
4
8
|
import { AddressDataCard } from './components/address-data-card.js';
|
|
5
9
|
|
|
6
|
-
function ConnectedBillToAddressWidget() {
|
|
7
|
-
const
|
|
8
|
-
|
|
10
|
+
function ConnectedBillToAddressWidget({ billToId = 'current', } = {}) {
|
|
11
|
+
const paths = usePaths();
|
|
12
|
+
const { href } = useLocation();
|
|
13
|
+
const editAddressUrl = `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}?returnUrl=${encodeURIComponent(href)}`;
|
|
14
|
+
const { data: billToAddress, error, isLoading, } = useFetchBillToAddress({ billToId });
|
|
15
|
+
return (jsx(AddressDataCard, { actions: [
|
|
16
|
+
jsx(Button, { color: "secondary", href: editAddressUrl, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Edit" }) }, "edit"),
|
|
17
|
+
], data: {
|
|
9
18
|
address1: billToAddress?.address1,
|
|
10
19
|
address2: billToAddress?.address2,
|
|
11
20
|
address3: billToAddress?.address3,
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from '../../../buttons/button/button.js';
|
|
4
|
+
import { FormattedMessage } from '../../../intl/formatted-message.js';
|
|
5
|
+
import { useFetchShipToAddress } from '../../../shared/api/storefront/hooks/customer/use-fetch-ship-to-address.js';
|
|
6
|
+
import { useLocation } from '../../../shared/routing/use-location.js';
|
|
7
|
+
import { usePaths } from '../../../shared/routing/use-paths.js';
|
|
4
8
|
import { AddressDataCard } from './components/address-data-card.js';
|
|
5
9
|
|
|
6
|
-
function ConnectedShipToAddressWidget() {
|
|
7
|
-
const
|
|
8
|
-
|
|
10
|
+
function ConnectedShipToAddressWidget({ billToId = 'current', shipToId = 'current', } = {}) {
|
|
11
|
+
const paths = usePaths();
|
|
12
|
+
const { href } = useLocation();
|
|
13
|
+
const editAddressUrl = `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${shipToId}?returnUrl=${encodeURIComponent(href)}`;
|
|
14
|
+
const createAddressUrl = `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/new?returnUrl=${encodeURIComponent(href)}`;
|
|
15
|
+
const { data: shipToAddress, error, isLoading, } = useFetchShipToAddress({
|
|
16
|
+
billToId,
|
|
17
|
+
shipToId,
|
|
18
|
+
});
|
|
19
|
+
return (jsx(AddressDataCard, { actions: [
|
|
20
|
+
jsx(Button, { color: "secondary", href: editAddressUrl, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Edit" }) }, "edit"),
|
|
21
|
+
jsx(Button, { color: "secondary", href: createAddressUrl, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Create" }) }, "create"),
|
|
22
|
+
], data: {
|
|
9
23
|
address1: shipToAddress?.address1,
|
|
10
24
|
address2: shipToAddress?.address2,
|
|
11
25
|
address3: shipToAddress?.address3,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { fetchBillToAddress } from '../../services/customer-service.js';
|
|
3
|
+
|
|
4
|
+
function useFetchBillToAddress({ billToId, includeValidation = false, }) {
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryFn: () => fetchBillToAddress({ billToId, includeValidation }),
|
|
7
|
+
queryKey: ['customer', 'bill-to-address', billToId, includeValidation],
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { useFetchBillToAddress };
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare function useFetchCurrentBillToAddress(
|
|
1
|
+
export declare function useFetchCurrentBillToAddress({ includeValidation, }?: {
|
|
2
|
+
includeValidation?: boolean;
|
|
3
|
+
}): import("@tanstack/react-query").UseQueryResult<import("../../model/storefront.model").BillToModel, Error>;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fetchCurrentBillToAddress } from '../../services/customer-service.js';
|
|
1
|
+
import { useFetchBillToAddress } from './use-fetch-bill-to-address.js';
|
|
3
2
|
|
|
4
|
-
function useFetchCurrentBillToAddress() {
|
|
5
|
-
return
|
|
6
|
-
queryFn: fetchCurrentBillToAddress,
|
|
7
|
-
queryKey: ['customer', 'bill-to-address', 'current'],
|
|
8
|
-
});
|
|
3
|
+
function useFetchCurrentBillToAddress({ includeValidation = false, } = {}) {
|
|
4
|
+
return useFetchBillToAddress({ billToId: 'current', includeValidation });
|
|
9
5
|
}
|
|
10
6
|
|
|
11
7
|
export { useFetchCurrentBillToAddress };
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare function useFetchCurrentShipToAddress(
|
|
1
|
+
export declare function useFetchCurrentShipToAddress({ includeValidation, }?: {
|
|
2
|
+
includeValidation?: boolean;
|
|
3
|
+
}): import("@tanstack/react-query").UseQueryResult<import("../../model/storefront.model").ShipToModel, Error>;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fetchCurrentShipToAddress } from '../../services/customer-service.js';
|
|
1
|
+
import { useFetchShipToAddress } from './use-fetch-ship-to-address.js';
|
|
3
2
|
|
|
4
|
-
function useFetchCurrentShipToAddress() {
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'bill-to-address',
|
|
10
|
-
'current',
|
|
11
|
-
'ship-to-address',
|
|
12
|
-
'current',
|
|
13
|
-
],
|
|
3
|
+
function useFetchCurrentShipToAddress({ includeValidation = false, } = {}) {
|
|
4
|
+
return useFetchShipToAddress({
|
|
5
|
+
billToId: 'current',
|
|
6
|
+
includeValidation,
|
|
7
|
+
shipToId: 'current',
|
|
14
8
|
});
|
|
15
9
|
}
|
|
16
10
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function useFetchShipToAddress({ billToId, includeValidation, shipToId, }: {
|
|
2
|
+
billToId: string;
|
|
3
|
+
includeValidation?: boolean;
|
|
4
|
+
shipToId: string;
|
|
5
|
+
}): import("@tanstack/react-query").UseQueryResult<import("../../model/storefront.model").ShipToModel, Error>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { fetchShipToAddress } from '../../services/customer-service.js';
|
|
3
|
+
|
|
4
|
+
function useFetchShipToAddress({ billToId, includeValidation = false, shipToId, }) {
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryFn: () => fetchShipToAddress({ billToId, includeValidation, shipToId }),
|
|
7
|
+
queryKey: [
|
|
8
|
+
'customer',
|
|
9
|
+
'bill-to-address',
|
|
10
|
+
billToId,
|
|
11
|
+
'ship-to-address',
|
|
12
|
+
shipToId,
|
|
13
|
+
includeValidation,
|
|
14
|
+
],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { useFetchShipToAddress };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function usePatchShipToAddress({ skipInvalidation, }?: {
|
|
2
|
+
skipInvalidation?: boolean;
|
|
3
|
+
}): {
|
|
4
|
+
error: unknown;
|
|
5
|
+
isError: boolean;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isSuccess: boolean;
|
|
8
|
+
mutate: (args_0: {
|
|
9
|
+
billToId: string;
|
|
10
|
+
shipTo: import("../../model/storefront.model").PatchShipToModel;
|
|
11
|
+
}) => Promise<import("../../model/storefront.model").ShipToModel>;
|
|
12
|
+
reset: () => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { patchShipToAddress } from '../../services/customer-service.js';
|
|
2
|
+
import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
|
|
3
|
+
|
|
4
|
+
function usePatchShipToAddress({ skipInvalidation = false, } = {}) {
|
|
5
|
+
return useAwaitableMutation({
|
|
6
|
+
mutationFn: patchShipToAddress,
|
|
7
|
+
onComplete({ queryClient }) {
|
|
8
|
+
if (skipInvalidation)
|
|
9
|
+
return;
|
|
10
|
+
queryClient.invalidateQueries({ queryKey: ['customer'] });
|
|
11
|
+
queryClient.invalidateQueries({ queryKey: ['carts'] });
|
|
12
|
+
queryClient.invalidateQueries({ queryKey: ['session'] });
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { usePatchShipToAddress };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function usePostShipToAddress({ skipInvalidation, }?: {
|
|
2
|
+
skipInvalidation?: boolean;
|
|
3
|
+
}): {
|
|
4
|
+
error: unknown;
|
|
5
|
+
isError: boolean;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isSuccess: boolean;
|
|
8
|
+
mutate: (args_0: {
|
|
9
|
+
billToId: string;
|
|
10
|
+
shipTo: Partial<Omit<import("../../model/storefront.model").ShipToModel, "country"> & {
|
|
11
|
+
country?: import("../../model/storefront.model").CountryModel | {
|
|
12
|
+
id: string;
|
|
13
|
+
} | null;
|
|
14
|
+
}>;
|
|
15
|
+
}) => Promise<import("../../model/storefront.model").ShipToModel>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { postShipToAddress } from '../../services/customer-service.js';
|
|
2
|
+
import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
|
|
3
|
+
|
|
4
|
+
function usePostShipToAddress({ skipInvalidation = false, } = {}) {
|
|
5
|
+
return useAwaitableMutation({
|
|
6
|
+
mutationFn: postShipToAddress,
|
|
7
|
+
onComplete({ queryClient }) {
|
|
8
|
+
if (skipInvalidation)
|
|
9
|
+
return;
|
|
10
|
+
queryClient.invalidateQueries({ queryKey: ['customer'] });
|
|
11
|
+
queryClient.invalidateQueries({ queryKey: ['carts'] });
|
|
12
|
+
queryClient.invalidateQueries({ queryKey: ['session'] });
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { usePostShipToAddress };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useInvalidateAdyen(): () => void
|
|
1
|
+
export declare function useInvalidateAdyen(): () => Promise<void>;
|
|
@@ -3,7 +3,7 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
3
3
|
|
|
4
4
|
function useInvalidateAdyen() {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
|
-
return useCallback(() => queryClient.
|
|
6
|
+
return useCallback(() => queryClient.invalidateQueries({ queryKey: ['adyen'] }), [queryClient]);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { useInvalidateAdyen };
|
|
@@ -8,7 +8,9 @@ function useMarkProductAsRecentlyViewed({ productId, }) {
|
|
|
8
8
|
gcTime: 0,
|
|
9
9
|
queryFn: () => {
|
|
10
10
|
markProductAsRecentlyViewed({ productId: productId });
|
|
11
|
-
queryClient.
|
|
11
|
+
queryClient.invalidateQueries({
|
|
12
|
+
queryKey: ['products', 'recently-viewed'],
|
|
13
|
+
});
|
|
12
14
|
},
|
|
13
15
|
queryKey: ['mark-product-as-recently-viewed', productId],
|
|
14
16
|
staleTime: 0,
|
package/dist/shared/api/storefront/hooks/wishlist/use-add-wishlist-item-to-current-wishlist.js
CHANGED
|
@@ -25,8 +25,8 @@ function useAddWishListItemToCurrentWishList() {
|
|
|
25
25
|
]);
|
|
26
26
|
},
|
|
27
27
|
onError() {
|
|
28
|
-
queryClient.
|
|
29
|
-
queryClient.
|
|
28
|
+
queryClient.invalidateQueries({ queryKey: ['wishlists'] });
|
|
29
|
+
queryClient.invalidateQueries({ queryKey: ['wishlistlines'] });
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -12,8 +12,8 @@ function useDeleteWishListItemFromWishList() {
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
onError() {
|
|
15
|
-
queryClient.
|
|
16
|
-
queryClient.
|
|
15
|
+
queryClient.invalidateQueries({ queryKey: ['wishlists'] });
|
|
16
|
+
queryClient.invalidateQueries({ queryKey: ['wishlistlines'] });
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -984,6 +984,18 @@ export type PatchBillToModel = Partial<Omit<BillToModel, 'country'> & {
|
|
|
984
984
|
}> & {
|
|
985
985
|
id: string;
|
|
986
986
|
};
|
|
987
|
+
export type PostShipToModel = Partial<Omit<ShipToModel, 'country'> & {
|
|
988
|
+
country?: CountryModel | {
|
|
989
|
+
id: string;
|
|
990
|
+
} | null;
|
|
991
|
+
}>;
|
|
992
|
+
export type PatchShipToModel = Partial<Omit<ShipToModel, 'country'> & {
|
|
993
|
+
country?: CountryModel | {
|
|
994
|
+
id: string;
|
|
995
|
+
} | null;
|
|
996
|
+
}> & {
|
|
997
|
+
id: string;
|
|
998
|
+
};
|
|
987
999
|
export type PatchCartModel = Partial<Omit<CartModel, 'billTo'> & {
|
|
988
1000
|
billTo?: PatchBillToModel | {
|
|
989
1001
|
id: string;
|
|
@@ -80,5 +80,10 @@ async function patchCurrentAccount({ account, }) {
|
|
|
80
80
|
throw error;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
/*
|
|
84
|
+
"setDefaultCustomer": true,
|
|
85
|
+
"defaultCustomerId": "f73fd87f-bf14-4454-afaf-b328007d3c86",
|
|
86
|
+
"defaultFulfillmentMethod": "Ship",
|
|
87
|
+
*/
|
|
83
88
|
|
|
84
89
|
export { ExistingAccountError, createAccount, createGuestAccount, fetchCurrentAccount, patchCurrentAccount };
|