@vtex/faststore-plugin-buyer-portal 1.3.40 → 1.3.42
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/CHANGELOG.md +25 -1
- package/package.json +1 -1
- package/src/features/addresses/components/AddressForm/AddressForm.tsx +254 -220
- package/src/features/addresses/components/CreateAddressSettingsDrawer/CreateAddressSettingsDrawer.tsx +64 -25
- package/src/features/addresses/components/CreateAddressSettingsDrawer/create-address-settings-drawer.scss +22 -22
- package/src/features/addresses/services/default-values/get-default-address.service.ts +1 -1
- package/src/features/addresses/types/AddressData.ts +1 -0
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +8 -6
- package/src/features/shared/clients/ScopeClient.ts +38 -2
- package/src/features/shared/components/Error/Error.tsx +15 -13
- package/src/features/shared/components/SettingsDrawer/SettingsDrawer.tsx +106 -0
- package/src/features/shared/components/SettingsDrawer/SettingsDrawerContext.tsx +17 -0
- package/src/features/shared/components/SettingsDrawer/SettingsDrawerListType.tsx +100 -0
- package/src/features/shared/components/SettingsDrawer/settings-drawer.scss +61 -0
- package/src/features/shared/components/index.ts +7 -0
- package/src/features/shared/hooks/index.ts +2 -0
- package/src/features/shared/hooks/useGetScopeConfig.ts +35 -0
- package/src/features/shared/hooks/useSetScopeConfig.ts +30 -0
- package/src/features/shared/services/get-scope-config.service.ts +19 -0
- package/src/features/shared/services/index.ts +9 -0
- package/src/features/shared/services/set-scope-config.service.ts +27 -0
- package/src/features/shared/types/index.ts +1 -0
- package/src/features/shared/utils/constants.ts +10 -1
- package/src/features/shared/utils/index.ts +6 -1
- package/src/pages/payment-methods.tsx +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getScopeConfigService,
|
|
3
|
+
type GetScopeConfigServiceProps,
|
|
4
|
+
SCOPE_KEYS,
|
|
5
|
+
} from "../services";
|
|
6
|
+
|
|
7
|
+
import { useQuery, type QueryOptions } from "./useQuery";
|
|
8
|
+
|
|
9
|
+
import type { AwaitedType } from "../types";
|
|
10
|
+
|
|
11
|
+
export const useGetScopeConfig = (
|
|
12
|
+
props: Omit<GetScopeConfigServiceProps, "cookie">,
|
|
13
|
+
options?: QueryOptions<AwaitedType<typeof getScopeConfigService>>
|
|
14
|
+
) => {
|
|
15
|
+
const { data, error, isLoading, refetch } = useQuery<
|
|
16
|
+
AwaitedType<typeof getScopeConfigService>
|
|
17
|
+
>(
|
|
18
|
+
`scope-config-${props.customerId}-${props.unitId}-${props.scopeName}`,
|
|
19
|
+
(clientContext) =>
|
|
20
|
+
getScopeConfigService({
|
|
21
|
+
...props,
|
|
22
|
+
cookie: clientContext.cookie,
|
|
23
|
+
}),
|
|
24
|
+
options
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
scopeConfig: data,
|
|
29
|
+
isScopeConfigLoading: isLoading,
|
|
30
|
+
hasScopeConfigError: error,
|
|
31
|
+
refetchScopeConfig: refetch,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { SCOPE_KEYS };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setScopeConfigService,
|
|
3
|
+
type SetScopeConfigServiceProps,
|
|
4
|
+
SCOPE_KEYS,
|
|
5
|
+
} from "../services";
|
|
6
|
+
|
|
7
|
+
import { type MutationOptions, useMutation } from "./useMutation";
|
|
8
|
+
|
|
9
|
+
import type { AwaitedType } from "../types";
|
|
10
|
+
|
|
11
|
+
export const useSetScopeConfig = (
|
|
12
|
+
options?: MutationOptions<AwaitedType<typeof setScopeConfigService>>
|
|
13
|
+
) => {
|
|
14
|
+
const { mutate, isLoading, error } = useMutation<
|
|
15
|
+
AwaitedType<typeof setScopeConfigService>,
|
|
16
|
+
Omit<SetScopeConfigServiceProps, "cookie">
|
|
17
|
+
>(
|
|
18
|
+
(variables, clientContext) =>
|
|
19
|
+
setScopeConfigService({ ...variables, cookie: clientContext.cookie }),
|
|
20
|
+
options
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
setScopeConfig: mutate,
|
|
25
|
+
isSetScopeConfigLoading: isLoading,
|
|
26
|
+
hasSetScopeConfigError: error,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { SCOPE_KEYS };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { scopesClient, SCOPE_KEYS } from "../clients/ScopeClient";
|
|
2
|
+
|
|
3
|
+
export type GetScopeConfigServiceProps = {
|
|
4
|
+
customerId: string;
|
|
5
|
+
unitId: string;
|
|
6
|
+
scopeName: string;
|
|
7
|
+
cookie: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getScopeConfigService = async ({
|
|
11
|
+
customerId,
|
|
12
|
+
unitId,
|
|
13
|
+
scopeName,
|
|
14
|
+
cookie,
|
|
15
|
+
}: GetScopeConfigServiceProps) => {
|
|
16
|
+
return scopesClient.getScopeConfig(customerId, unitId, scopeName, cookie);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { SCOPE_KEYS };
|
|
@@ -15,3 +15,12 @@ export {
|
|
|
15
15
|
getDependenciesVersionService,
|
|
16
16
|
type GetDependenciesVersionProps,
|
|
17
17
|
} from "./get-dependencies-version.service";
|
|
18
|
+
export {
|
|
19
|
+
getScopeConfigService,
|
|
20
|
+
type GetScopeConfigServiceProps,
|
|
21
|
+
SCOPE_KEYS,
|
|
22
|
+
} from "./get-scope-config.service";
|
|
23
|
+
export {
|
|
24
|
+
setScopeConfigService,
|
|
25
|
+
type SetScopeConfigServiceProps,
|
|
26
|
+
} from "./set-scope-config.service";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { scopesClient, SCOPE_KEYS } from "../clients/ScopeClient";
|
|
2
|
+
|
|
3
|
+
export type SetScopeConfigServiceProps = {
|
|
4
|
+
customerId: string;
|
|
5
|
+
unitId: string;
|
|
6
|
+
scopeName: string;
|
|
7
|
+
type: "sync" | "custom";
|
|
8
|
+
cookie: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const setScopeConfigService = async ({
|
|
12
|
+
customerId,
|
|
13
|
+
unitId,
|
|
14
|
+
scopeName,
|
|
15
|
+
type,
|
|
16
|
+
cookie,
|
|
17
|
+
}: SetScopeConfigServiceProps) => {
|
|
18
|
+
return scopesClient.setScopeConfig(
|
|
19
|
+
customerId,
|
|
20
|
+
unitId,
|
|
21
|
+
scopeName,
|
|
22
|
+
type,
|
|
23
|
+
cookie
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { SCOPE_KEYS };
|
|
@@ -13,4 +13,13 @@ export const LOCAL_STORAGE_LOCATION_EDIT_KEY = "bp_hide_edit_location_confirm";
|
|
|
13
13
|
export const LOCAL_STORAGE_RECIPIENT_EDIT_KEY =
|
|
14
14
|
"bp_hide_edit_recipient_confirm";
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const SCOPE_KEYS = {
|
|
17
|
+
CONTRACTS: "contractIds",
|
|
18
|
+
ADDRESSES: "addresses",
|
|
19
|
+
CUSTOM_FIELDS: "customFields",
|
|
20
|
+
COLLECTIONS: "collectionIds",
|
|
21
|
+
PAYMENT_SYSTEMS: "paymentSystemIds",
|
|
22
|
+
CREDIT_CARDS: "creditCards",
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
export const CURRENT_VERSION = "1.3.42";
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export { addressLabelToPropMapping } from "./addresLabelToPropMapping";
|
|
2
2
|
export { getApiUrl, getPostalCodeApiUrl, getTokenizationUrl } from "./api";
|
|
3
3
|
export { compareItems } from "./compareItems";
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
API_URL,
|
|
6
|
+
AUT_COOKIE_KEY,
|
|
7
|
+
DEBOUNCE_TIMEOUT,
|
|
8
|
+
SCOPE_KEYS,
|
|
9
|
+
} from "./constants";
|
|
5
10
|
export {
|
|
6
11
|
getAuthCookie,
|
|
7
12
|
getCookieAsString,
|
|
@@ -82,7 +82,7 @@ const loaderFunction = async (
|
|
|
82
82
|
return {
|
|
83
83
|
data: paymentMethods,
|
|
84
84
|
search: search ?? "",
|
|
85
|
-
totalPaymentMethods: contractPaymentMethods
|
|
85
|
+
totalPaymentMethods: contractPaymentMethods?.paging?.total ?? 0,
|
|
86
86
|
context: {
|
|
87
87
|
clientContext: { cookie, userId, ...clientContext },
|
|
88
88
|
currentOrgUnit,
|