@vtex/faststore-plugin-buyer-portal 2.0.13 → 2.0.14
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 +18 -1
- package/cms/b2b/components/.gitkeep +0 -0
- package/cms/b2b/pages/cms_content_type__i18n.jsonc +36 -0
- package/cypress/integration/localization.test.ts +482 -0
- package/cypress/support/commands.ts +8 -0
- package/docs/i18n/i18n-messages-format.md +391 -0
- package/docs/i18n/locales.json +701 -0
- package/docs/i18n/migration-inventory.md +959 -0
- package/package.json +3 -3
- package/specs/custom-localization-system.md +711 -0
- package/specs/multi-locale-e2e-validation.md +277 -0
- package/src/__mocks__/discovery.config.ts +12 -0
- package/src/features/accounting-fields/components/AccountingConfirmDelete/AccountingConfirmDelete.tsx +14 -4
- package/src/features/accounting-fields/components/AccountingFieldConfirmEdit/AccountingFieldConfirmEdit.tsx +11 -6
- package/src/features/accounting-fields/components/AccountingFieldDropdown/AccountingFieldDropdown.tsx +5 -3
- package/src/features/accounting-fields/components/AccountingFieldForm/AccountingFieldForm.tsx +33 -23
- package/src/features/accounting-fields/components/AccountingValueConfirmEdit/AccountingValueConfirmEdit.tsx +10 -6
- package/src/features/accounting-fields/components/AccountingValueDropdown/AccountingValueDropdown.tsx +19 -9
- package/src/features/accounting-fields/components/AccountingValueForm/AccountingValueForm.tsx +21 -10
- package/src/features/accounting-fields/components/CreateAccountingFieldDrawer/CreateAccountingFieldDrawer.tsx +11 -8
- package/src/features/accounting-fields/components/CreateAccountingValueDrawer/CreateAccountingValueDrawer.tsx +18 -7
- package/src/features/accounting-fields/components/DeleteAccountingFieldDrawer/DeleteAccountingFieldDrawer.tsx +14 -12
- package/src/features/accounting-fields/components/DeleteAccountingValueDrawer/DeleteAccountingValueDrawer.tsx +20 -10
- package/src/features/accounting-fields/components/EditAccountingFieldDrawer/EditAccountingFieldDrawer.tsx +5 -3
- package/src/features/accounting-fields/components/EditAccountingValueDrawer/EditAccountingValueDrawer.tsx +13 -6
- package/src/features/accounting-fields/components/RemoveValueFromUnitDrawer/RemoveValueFromUnitDrawer.tsx +19 -8
- package/src/features/accounting-fields/layouts/AccountingFieldLayout/AccountingFieldLayout.tsx +11 -9
- package/src/features/addresses/components/AddRecipientsDrawer/AddRecipientsDrawer.tsx +13 -7
- package/src/features/addresses/components/AddressDropdownMenu/AddressDropdownMenu.tsx +22 -20
- package/src/features/addresses/components/AddressForm/AddressForm.tsx +33 -22
- package/src/features/addresses/components/AddressLine/AddressLine.tsx +29 -25
- package/src/features/addresses/components/AddressLocationsList/AddressLocationsList.tsx +15 -6
- package/src/features/addresses/components/AddressRecipientsList/AddressRecipientsList.tsx +9 -4
- package/src/features/addresses/components/AddressesCard/AddressesCard.tsx +8 -5
- package/src/features/addresses/components/CreateAddressDrawer/CreateAddressDrawer.tsx +27 -14
- package/src/features/addresses/components/CreateAddressSettingsDrawer/CreateAddressSettingsDrawer.tsx +26 -21
- package/src/features/addresses/components/DeleteAddressDrawer/DeleteAddressDrawer.tsx +20 -16
- package/src/features/addresses/components/DeleteAddressLocationDrawer/DeleteAddressLocationDrawer.tsx +26 -14
- package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +20 -17
- package/src/features/addresses/components/EditAddressDrawer/EditAddressDrawer.tsx +12 -6
- package/src/features/addresses/components/EditAddressLocationDrawer/EditAddressLocationDrawer.tsx +24 -17
- package/src/features/addresses/components/EditRecipientAddressDrawer/EditRecipientAddressDrawer.tsx +17 -15
- package/src/features/addresses/components/LocationForm/LocationField/LocationField.tsx +8 -5
- package/src/features/addresses/components/LocationForm/LocationForm.tsx +9 -3
- package/src/features/addresses/components/LocationsDrawer/LocationsDrawer.tsx +15 -9
- package/src/features/addresses/components/RecipientsForm/RecipientItem/RecipientItem.tsx +55 -46
- package/src/features/addresses/components/RecipientsForm/RecipientsForm.tsx +4 -1
- package/src/features/addresses/components/RemoveAddressDrawer/RemoveAddressDrawer.tsx +21 -14
- package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +16 -9
- package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +11 -8
- package/src/features/b2b-agent/layouts/B2BAgentLayout/B2BAgentLayout.tsx +3 -1
- package/src/features/budgets/components/BudgetAddForm/BudgetAddForm.tsx +14 -12
- package/src/features/budgets/components/BudgetAddSuccess/BudgetAddSuccess.tsx +16 -14
- package/src/features/budgets/components/BudgetAllocationsSelection/BudgetAllocationsSelection.tsx +8 -5
- package/src/features/budgets/components/BudgetAllocationsTable/BudgetAllocationsTable.tsx +9 -6
- package/src/features/budgets/components/BudgetDeleteDrawer/BudgetDeleteDrawer.tsx +23 -17
- package/src/features/budgets/components/BudgetEditNotificationDrawer/BudgetEditNotificationDrawer.tsx +13 -6
- package/src/features/budgets/components/BudgetNotificationForm/BudgetNotificationForm.tsx +31 -24
- package/src/features/budgets/components/BudgetNotificationsInfo/BudgetNotificationsInfo.tsx +15 -9
- package/src/features/budgets/components/BudgetRemainingBalance/BudgetRemainingBalance.tsx +6 -2
- package/src/features/budgets/components/BudgetSettingsInfo/BudgetSettingsInfo.tsx +27 -10
- package/src/features/budgets/components/BudgetUsersTable/BudgetUsersTable.tsx +14 -7
- package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +11 -8
- package/src/features/budgets/components/CreateBudgetAllocationDrawer/CreateBudgetAllocationDrawer.tsx +8 -5
- package/src/features/budgets/components/CreateBudgetDrawer/CreateBudgetDrawer.tsx +31 -18
- package/src/features/budgets/components/DeleteBudgetAllocationDrawer/DeleteBudgetAllocationDrawer.tsx +17 -12
- package/src/features/budgets/components/EditBudgetDrawer/EditBudgetDrawer.tsx +14 -8
- package/src/features/budgets/components/EmptyState.tsx/EmptyState.tsx +4 -1
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +7 -5
- package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +5 -3
- package/src/features/budgets/messages/budgetNotifications.ts +5 -5
- package/src/features/budgets/utils/handleBudgetError.tsx +5 -8
- package/src/features/budgets/utils/handleBudgetError.types.ts +3 -0
- package/src/features/buying-policies/components/AccountingFieldCriteriaSelector/AccountingFieldCriteriaSelector.tsx +5 -3
- package/src/features/buying-policies/components/AccountingFieldCriteriaSelector/AccountingValueCriteriaSelector.tsx +20 -9
- package/src/features/buying-policies/components/AddBuyingPolicyDrawer/AddBuyingPolicyDrawer.tsx +8 -5
- package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/BasicBuyingPolicyDrawer.tsx +49 -33
- package/src/features/buying-policies/components/BudgetCriteriaSelector/BudgetCriteriaSelector.tsx +8 -2
- package/src/features/buying-policies/components/BuyingPolicyDropdownMenu/BuyingPolicyDropdownMenu.tsx +5 -3
- package/src/features/buying-policies/components/DeleteBuyingPolicyDrawer/DeleteBuyingPolicyDrawer.tsx +28 -24
- package/src/features/buying-policies/components/UpdateBuyingPolicyDrawer/UpdateBuyingPolicyDrawer.tsx +10 -7
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +11 -4
- package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/BuyingPolicyDetailsLayout.tsx +26 -9
- package/src/features/buying-policies/utils/accountingFieldCriteriaHelpers.ts +2 -2
- package/src/features/buying-policies/utils/buyingPoliciesWorkflowTypes.ts +3 -3
- package/src/features/buying-policies/utils/orderFieldsCriteriaOptions.ts +8 -8
- package/src/features/buying-policies/utils/spendingLimitsCriteriaOptions.ts +6 -6
- package/src/features/contracts/components/ContractsCard/ContractsCard.tsx +7 -5
- package/src/features/contracts/layouts/ContractsLayout/ContractsLayout.tsx +9 -4
- package/src/features/credit-cards/components/CreateCreditCardDrawer/CreateCreditCardDrawer.tsx +17 -11
- package/src/features/credit-cards/components/CreditCardDropdownMenu/CreditCardDropdownMenu.tsx +17 -11
- package/src/features/credit-cards/components/CreditCardForm/CreditCardForm.tsx +8 -5
- package/src/features/credit-cards/components/CreditCardSettingsDrawer/CreditCardSettingsDrawer.tsx +10 -8
- package/src/features/credit-cards/components/DeleteCreditCardDrawer/DeleteCreditCardDrawer.tsx +19 -14
- package/src/features/credit-cards/components/EditCreditCardDrawer/EditCreditCardDrawer.tsx +14 -13
- package/src/features/credit-cards/components/RemoveCreditCardDrawer/RemoveCreditCardDrawer.tsx +18 -15
- package/src/features/credit-cards/layouts/CreditCardsLayout/CreditCardLayout.tsx +10 -4
- package/src/features/order-entry/layouts/OrderEntryLayout.tsx +3 -1
- package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +11 -9
- package/src/features/org-units/components/AuthSetupDrawer/AuthSetupDrawer.tsx +28 -16
- package/src/features/org-units/components/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +18 -12
- package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +28 -29
- package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbLink.tsx +4 -4
- package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/OrgUnitDetailsDropdownMenu.tsx +4 -2
- package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +23 -5
- package/src/features/org-units/components/OrgUnitDetailsNavbar/org-unit-details-navbar.scss +18 -2
- package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +6 -4
- package/src/features/org-units/components/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +9 -6
- package/src/features/org-units/components/OrganizationalUnitsCard/OrganizationalUnitsCard.tsx +15 -7
- package/src/features/org-units/components/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +15 -9
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +27 -26
- package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +8 -3
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +29 -18
- package/src/features/payment-methods/components/PaymentMethodSettingsDrawer/PaymentMethodSettingsDrawer.tsx +13 -9
- package/src/features/payment-methods/components/RemoveMethodButton/RemoveMethodButton.tsx +5 -2
- package/src/features/payment-methods/components/RemovePaymentMethodsDrawer/RemovePaymentMethodsDrawer.tsx +10 -7
- package/src/features/payment-methods/hooks/useRemovePaymentMethodSubmit.ts +6 -4
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +21 -15
- package/src/features/product-assortment/components/ProductAssortmentTable/ProductAssortmentTable.tsx +11 -7
- package/src/features/product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx +9 -6
- package/src/features/profile/components/ProfileCard/ProfileCard.tsx +8 -5
- package/src/features/profile/components/ProfileSummary/ProfileSummary.tsx +13 -6
- package/src/features/profile/layouts/ProfileLayout/ProfileLayout.tsx +16 -6
- package/src/features/roles/layout/RoleDetailsLayout/RoleDetailsLayout.tsx +4 -2
- package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +5 -3
- package/src/features/shared/components/BasicCard/BasicCard.tsx +6 -4
- package/src/features/shared/components/BasicCard/BasicCardLine.tsx +5 -4
- package/src/features/shared/components/CustomerSwitch/CustomerSwitchDrawer.tsx +10 -2
- package/src/features/shared/components/CustomerSwitch/CustomerSwitchSearch.tsx +4 -1
- package/src/features/shared/components/DropdownFilter/DropdownFilter.tsx +11 -7
- package/src/features/shared/components/Error/Error.tsx +13 -6
- package/src/features/shared/components/HeaderInside/HeaderInside.tsx +5 -2
- package/src/features/shared/components/InternalSearch/InternalSearch.tsx +4 -1
- package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +7 -5
- package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +23 -8
- package/src/features/shared/components/OrgUnitInputSearch/OrgUnitInputSearch.tsx +7 -2
- package/src/features/shared/components/Pagination/Pagination.tsx +6 -2
- package/src/features/shared/components/Paginator/Counter.tsx +11 -5
- package/src/features/shared/components/Paginator/Interval.tsx +4 -3
- package/src/features/shared/components/Paginator/NextPageButton.tsx +6 -2
- package/src/features/shared/components/SettingsDrawer/SettingsDrawer.tsx +6 -4
- package/src/features/shared/components/SettingsDrawer/SettingsDrawerListType.tsx +11 -10
- package/src/features/shared/components/SettingsDrawer/listTypeOptions.ts +10 -7
- package/src/features/shared/components/SortFilter/SortFilter.tsx +15 -8
- package/src/features/shared/components/Table/TableRow/TableRow.tsx +5 -1
- package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +7 -3
- package/src/features/shared/layouts/BaseTabsLayout/Navbar.tsx +28 -4
- package/src/features/shared/layouts/BaseTabsLayout/about-drawer/AboutDrawer.tsx +15 -5
- package/src/features/shared/layouts/BaseTabsLayout/base-tabs-layout.scss +24 -9
- package/src/features/shared/layouts/BaseTabsLayout/sidebar-drawer/SidebarDrawer.tsx +5 -2
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +10 -5
- package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +7 -4
- package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +9 -4
- package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +7 -4
- package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +3 -0
- package/src/features/shared/layouts/SumaPageLayout/FullSidebarNav.tsx +13 -7
- package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +9 -5
- package/src/features/shared/localization/LocalizationContext.tsx +35 -0
- package/src/features/shared/localization/__tests__/createLocalize.test.ts +166 -0
- package/src/features/shared/localization/__tests__/get-localization-labels.service.test.ts +202 -0
- package/src/features/shared/localization/clients/LocalizationClient.ts +19 -0
- package/src/features/shared/localization/constants.ts +31 -0
- package/src/features/shared/localization/createLocalize.ts +78 -0
- package/src/features/shared/localization/services/get-localization-labels.service.ts +76 -0
- package/src/features/shared/localization/types.ts +66 -0
- package/src/features/shared/localization/withLocalization.tsx +22 -0
- package/src/features/shared/types/AuthRouteProps.ts +5 -0
- package/src/features/shared/types/LoaderData.ts +1 -0
- package/src/features/shared/utils/addresLabelToPropMapping.ts +10 -10
- package/src/features/shared/utils/constants.ts +1 -4
- package/src/features/shared/utils/getContractSettingsLinks.ts +17 -12
- package/src/features/shared/utils/getFinanceSettingsLinks.ts +14 -9
- package/src/features/shared/utils/getKeyByValue.ts +2 -2
- package/src/features/shared/utils/getOrganizationSettingsLinks.ts +13 -3
- package/src/features/shared/utils/getSumaListingSidebarLinks.ts +15 -10
- package/src/features/shared/utils/index.ts +2 -0
- package/src/features/shared/utils/routeLayoutMapping.ts +30 -30
- package/src/features/shared/utils/search.tsx +10 -0
- package/src/features/shared/utils/withAuth.tsx +6 -0
- package/src/features/shared/utils/withAuthLoader.ts +11 -0
- package/src/features/shared/utils/withLoaderErrorBoundary.ts +9 -0
- package/src/features/shared/utils/withProviders.tsx +13 -2
- package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +39 -27
- package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +41 -39
- package/src/features/users/components/DeleteUserDrawer/DeleteUserDrawer.tsx +27 -23
- package/src/features/users/components/EmailTransactionalSection/EmailTransactionalSection.tsx +6 -8
- package/src/features/users/components/LoginField/LoginField.tsx +4 -4
- package/src/features/users/components/ReassignOrgUnitDrawer/ReassignOrgUnitDrawer.tsx +22 -19
- package/src/features/users/components/ResetPasswordDrawer/ResetPasswordDrawer.tsx +16 -21
- package/src/features/users/components/UpdateUserDrawer/UpdateUserDrawer.tsx +26 -15
- package/src/features/users/components/UpdateUserDrawerWithUsername/UpdateUserDrawerWithUsername.tsx +22 -8
- package/src/features/users/components/UserDropdownMenu/UserDropdownMenu.tsx +7 -5
- package/src/features/users/components/UserFormFields/UserFormFields.tsx +9 -8
- package/src/features/users/components/UsersCard/UsersCard.tsx +4 -2
- package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +26 -10
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +12 -8
- package/src/pages/accounting-field.tsx +28 -15
- package/src/pages/address-details.tsx +37 -26
- package/src/pages/addresses.tsx +27 -12
- package/src/pages/budgets-details.tsx +25 -15
- package/src/pages/budgets.tsx +31 -17
- package/src/pages/buyer-organization-manager.tsx +23 -12
- package/src/pages/buying-policies.tsx +38 -20
- package/src/pages/buying-policy-details.tsx +20 -19
- package/src/pages/contracts.tsx +15 -1
- package/src/pages/credit-cards.tsx +30 -17
- package/src/pages/order-entry.tsx +26 -15
- package/src/pages/org-unit-details.tsx +20 -6
- package/src/pages/org-units.tsx +20 -6
- package/src/pages/payment-groups.tsx +15 -12
- package/src/pages/productAssortment.tsx +10 -1
- package/src/pages/profile.tsx +14 -1
- package/src/pages/role-details.tsx +19 -6
- package/src/pages/roles.tsx +27 -14
- package/src/pages/user-details.tsx +29 -17
- package/src/pages/users.tsx +11 -0
- package/vitest.config.ts +13 -0
- package/src/features/addresses/constants/messages.ts +0 -8
- package/src/features/credit-cards/constants/messages.ts +0 -6
|
@@ -2,11 +2,15 @@ import storeConfig from "discovery.config";
|
|
|
2
2
|
|
|
3
3
|
import { B2BAgentLayout } from "../features/b2b-agent/layouts";
|
|
4
4
|
import { withErrorBoundary } from "../features/shared/components";
|
|
5
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
6
|
+
import { LocalizationProvider } from "../features/shared/localization/LocalizationContext";
|
|
7
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
5
8
|
import {
|
|
6
9
|
withAuthLoader,
|
|
7
10
|
withLoaderErrorBoundary,
|
|
8
11
|
} from "../features/shared/utils";
|
|
9
12
|
|
|
13
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
10
14
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -31,13 +35,18 @@ const getAuthCookieInfo = (
|
|
|
31
35
|
|
|
32
36
|
type B2BAgentPageQuery = Record<string, never>;
|
|
33
37
|
|
|
38
|
+
type B2BAgentPageData = { localizationLabels: LabelMap };
|
|
39
|
+
|
|
34
40
|
const loaderFunction = async (
|
|
35
41
|
data: LoaderData<B2BAgentPageQuery>
|
|
36
|
-
): Promise<AuthRouteProps<
|
|
42
|
+
): Promise<AuthRouteProps<B2BAgentPageData>> => {
|
|
37
43
|
return withAuthLoader(data, async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
const localizationLabels = await getLocalizationLabelsService({
|
|
45
|
+
entryIds: LOCALIZATION_ENTRY_IDS.b2bAgent,
|
|
46
|
+
locale: data.locale,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return { localizationLabels };
|
|
41
50
|
});
|
|
42
51
|
};
|
|
43
52
|
|
|
@@ -46,7 +55,7 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
|
46
55
|
redirectToError: true,
|
|
47
56
|
});
|
|
48
57
|
|
|
49
|
-
const B2BAgentPage = (props: AuthRouteProps<
|
|
58
|
+
const B2BAgentPage = (props: AuthRouteProps<B2BAgentPageData>) => {
|
|
50
59
|
if (!props.authorized) return null;
|
|
51
60
|
|
|
52
61
|
const cookieHeader = props.clientContext?.cookie ?? "";
|
|
@@ -73,13 +82,15 @@ const B2BAgentPage = (props: AuthRouteProps<undefined>) => {
|
|
|
73
82
|
const userId = props.clientContext?.userId;
|
|
74
83
|
|
|
75
84
|
return (
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
<LocalizationProvider labels={props.data?.localizationLabels ?? {}}>
|
|
86
|
+
<B2BAgentLayout
|
|
87
|
+
vtexIdclientAutCookie={vtexIdclientAutCookie}
|
|
88
|
+
account={account}
|
|
89
|
+
locale={locale}
|
|
90
|
+
customerId={customerId}
|
|
91
|
+
userId={userId}
|
|
92
|
+
/>
|
|
93
|
+
</LocalizationProvider>
|
|
83
94
|
);
|
|
84
95
|
};
|
|
85
96
|
|
|
@@ -5,6 +5,8 @@ import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
|
5
5
|
import { withErrorBoundary } from "../features/shared/components";
|
|
6
6
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
7
7
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
8
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
9
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
8
10
|
import {
|
|
9
11
|
type ClientContext,
|
|
10
12
|
getValidPage,
|
|
@@ -31,6 +33,7 @@ export type BuyingPoliciesPageData = {
|
|
|
31
33
|
clientContext: ClientContext;
|
|
32
34
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
33
35
|
currentUser: UserData | null;
|
|
36
|
+
localization: { labels: Record<string, string> };
|
|
34
37
|
};
|
|
35
38
|
hasError?: boolean;
|
|
36
39
|
error?: ErrorBoundaryProps;
|
|
@@ -53,7 +56,14 @@ const loaderFunction = async (
|
|
|
53
56
|
return withAuthLoader(
|
|
54
57
|
data,
|
|
55
58
|
async ({ cookie, userId, customerId, ...clientContext }) => {
|
|
59
|
+
const labelsPromise = getLocalizationLabelsService({
|
|
60
|
+
entryIds: LOCALIZATION_ENTRY_IDS.buyingPolicies,
|
|
61
|
+
locale: data.locale,
|
|
62
|
+
});
|
|
63
|
+
|
|
56
64
|
if (!contractId || !orgUnitId) {
|
|
65
|
+
const localizationLabels = await labelsPromise;
|
|
66
|
+
|
|
57
67
|
return {
|
|
58
68
|
buyingPolicies: [],
|
|
59
69
|
total: 0,
|
|
@@ -64,30 +74,37 @@ const loaderFunction = async (
|
|
|
64
74
|
currentOrgUnit: null,
|
|
65
75
|
currentContract: null,
|
|
66
76
|
currentUser: null,
|
|
77
|
+
localization: { labels: localizationLabels },
|
|
67
78
|
},
|
|
68
79
|
};
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
const [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
const [
|
|
83
|
+
currentOrgUnit,
|
|
84
|
+
user,
|
|
85
|
+
contract,
|
|
86
|
+
buyingPoliciesResponse,
|
|
87
|
+
localizationLabels,
|
|
88
|
+
] = await Promise.all([
|
|
89
|
+
getOrgUnitBasicDataService({
|
|
90
|
+
id: orgUnitId,
|
|
91
|
+
cookie,
|
|
92
|
+
}),
|
|
93
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
94
|
+
getContractDetailsService({
|
|
95
|
+
contractId,
|
|
96
|
+
cookie,
|
|
97
|
+
unitId: orgUnitId,
|
|
98
|
+
}),
|
|
99
|
+
getBuyingPoliciesService({
|
|
100
|
+
orgUnitId,
|
|
101
|
+
contractId,
|
|
102
|
+
cookie,
|
|
103
|
+
page,
|
|
104
|
+
search,
|
|
105
|
+
}),
|
|
106
|
+
labelsPromise,
|
|
107
|
+
]);
|
|
91
108
|
|
|
92
109
|
const { data: buyingPolicies = [], total = 0 } = buyingPoliciesResponse;
|
|
93
110
|
|
|
@@ -107,6 +124,7 @@ const loaderFunction = async (
|
|
|
107
124
|
currentOrgUnit,
|
|
108
125
|
currentUser: user,
|
|
109
126
|
currentContract: contract,
|
|
127
|
+
localization: { labels: localizationLabels },
|
|
110
128
|
},
|
|
111
129
|
};
|
|
112
130
|
}
|
|
@@ -5,6 +5,8 @@ import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
|
5
5
|
import { withErrorBoundary } from "../features/shared/components";
|
|
6
6
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
7
7
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
8
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
9
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
8
10
|
import {
|
|
9
11
|
type ClientContext,
|
|
10
12
|
withLoaderErrorBoundary,
|
|
@@ -27,6 +29,7 @@ export type BuyingPolicyDetailsPageData = {
|
|
|
27
29
|
clientContext: ClientContext;
|
|
28
30
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
29
31
|
currentUser: UserData | null;
|
|
32
|
+
localization: { labels: Record<string, string> };
|
|
30
33
|
};
|
|
31
34
|
hasError?: boolean;
|
|
32
35
|
error?: ErrorBoundaryProps;
|
|
@@ -44,25 +47,22 @@ const loaderFunction = async (
|
|
|
44
47
|
const { contractId, orgUnitId, buyingPolicyId } = data.query;
|
|
45
48
|
|
|
46
49
|
return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
|
|
47
|
-
const currentOrgUnit
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
buyingPolicyId,
|
|
64
|
-
cookie,
|
|
65
|
-
});
|
|
50
|
+
const [currentOrgUnit, user, contract, buyingPolicy, localizationLabels] =
|
|
51
|
+
await Promise.all([
|
|
52
|
+
getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
|
|
53
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
54
|
+
getContractDetailsService({ contractId, cookie, unitId: orgUnitId }),
|
|
55
|
+
getBuyingPolicyService({
|
|
56
|
+
orgUnitId,
|
|
57
|
+
contractId,
|
|
58
|
+
buyingPolicyId,
|
|
59
|
+
cookie,
|
|
60
|
+
}),
|
|
61
|
+
getLocalizationLabelsService({
|
|
62
|
+
entryIds: LOCALIZATION_ENTRY_IDS.buyingPolicies,
|
|
63
|
+
locale: data.locale,
|
|
64
|
+
}),
|
|
65
|
+
]);
|
|
66
66
|
|
|
67
67
|
return {
|
|
68
68
|
data: {
|
|
@@ -73,6 +73,7 @@ const loaderFunction = async (
|
|
|
73
73
|
currentOrgUnit,
|
|
74
74
|
currentUser: user,
|
|
75
75
|
currentContract: contract,
|
|
76
|
+
localization: { labels: localizationLabels },
|
|
76
77
|
},
|
|
77
78
|
};
|
|
78
79
|
});
|
package/src/pages/contracts.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import { listAttachedContractsService } from "../features/contracts/services";
|
|
|
3
3
|
import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
4
4
|
import { withErrorBoundary } from "../features/shared/components";
|
|
5
5
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
6
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
7
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
6
8
|
import {
|
|
7
9
|
type ClientContext,
|
|
8
10
|
withLoaderErrorBoundary,
|
|
@@ -15,6 +17,7 @@ import { getUserByIdService } from "../features/users/services";
|
|
|
15
17
|
import type { ContractData } from "../features/contracts/types";
|
|
16
18
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
17
19
|
import type { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
20
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
18
21
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
19
22
|
import type { UserData } from "../features/users/types";
|
|
20
23
|
|
|
@@ -27,6 +30,7 @@ export type ContractsPageData = {
|
|
|
27
30
|
};
|
|
28
31
|
context: {
|
|
29
32
|
clientContext: ClientContext;
|
|
33
|
+
localization?: { labels: LabelMap };
|
|
30
34
|
};
|
|
31
35
|
hasError?: boolean;
|
|
32
36
|
error?: ErrorBoundaryProps;
|
|
@@ -59,10 +63,19 @@ const loaderFunction = async (
|
|
|
59
63
|
return { redirected: true } as unknown as ContractsPageData;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
const [orgUnit, contracts, user] = await Promise.all([
|
|
66
|
+
const [orgUnit, contracts, user, localizationLabels] = await Promise.all([
|
|
63
67
|
getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
|
|
64
68
|
listAttachedContractsService({ orgUnitId, cookie }),
|
|
65
69
|
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
70
|
+
getLocalizationLabelsService({
|
|
71
|
+
entryIds: [
|
|
72
|
+
LOCALIZATION_ENTRY_IDS.contracts,
|
|
73
|
+
LOCALIZATION_ENTRY_IDS.orgUnits,
|
|
74
|
+
LOCALIZATION_ENTRY_IDS.addresses,
|
|
75
|
+
LOCALIZATION_ENTRY_IDS.accountingFields,
|
|
76
|
+
],
|
|
77
|
+
locale: data.locale,
|
|
78
|
+
}),
|
|
66
79
|
]);
|
|
67
80
|
|
|
68
81
|
return {
|
|
@@ -73,6 +86,7 @@ const loaderFunction = async (
|
|
|
73
86
|
},
|
|
74
87
|
context: {
|
|
75
88
|
clientContext: { cookie, userId, ...clientContext },
|
|
89
|
+
localization: { labels: localizationLabels },
|
|
76
90
|
},
|
|
77
91
|
};
|
|
78
92
|
}
|
|
@@ -6,6 +6,8 @@ import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
|
6
6
|
import { withErrorBoundary } from "../features/shared/components";
|
|
7
7
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
8
8
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
9
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
10
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
9
11
|
import {
|
|
10
12
|
type ClientContext,
|
|
11
13
|
withLoaderErrorBoundary,
|
|
@@ -16,6 +18,7 @@ import { getUserByIdService } from "../features/users/services";
|
|
|
16
18
|
|
|
17
19
|
import type { ContractData } from "../features/contracts/types";
|
|
18
20
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
21
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
19
22
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
20
23
|
import type { UserData } from "../features/users/types";
|
|
21
24
|
|
|
@@ -26,6 +29,7 @@ export type CreditCardPageData = {
|
|
|
26
29
|
clientContext: ClientContext;
|
|
27
30
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
28
31
|
currentUser: UserData | null;
|
|
32
|
+
localization?: { labels: LabelMap };
|
|
29
33
|
};
|
|
30
34
|
hasError?: boolean;
|
|
31
35
|
error?: ErrorBoundaryProps;
|
|
@@ -42,23 +46,31 @@ const loaderFunction = async (
|
|
|
42
46
|
const { contractId, orgUnitId } = data.query;
|
|
43
47
|
|
|
44
48
|
return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
|
|
45
|
-
const [currentOrgUnit, user, contract, creditCards] =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
const [currentOrgUnit, user, contract, creditCards, localizationLabels] =
|
|
50
|
+
await Promise.all([
|
|
51
|
+
getOrgUnitBasicDataService({
|
|
52
|
+
id: orgUnitId,
|
|
53
|
+
cookie,
|
|
54
|
+
}),
|
|
55
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
56
|
+
getContractDetailsService({
|
|
57
|
+
contractId,
|
|
58
|
+
cookie,
|
|
59
|
+
unitId: orgUnitId,
|
|
60
|
+
}),
|
|
61
|
+
getCreditCardsListService({
|
|
62
|
+
cookie,
|
|
63
|
+
unitId: orgUnitId,
|
|
64
|
+
customerId: contractId,
|
|
65
|
+
}),
|
|
66
|
+
getLocalizationLabelsService({
|
|
67
|
+
entryIds: [
|
|
68
|
+
LOCALIZATION_ENTRY_IDS.creditCards,
|
|
69
|
+
LOCALIZATION_ENTRY_IDS.addresses,
|
|
70
|
+
],
|
|
71
|
+
locale: data.locale,
|
|
72
|
+
}),
|
|
73
|
+
]);
|
|
62
74
|
|
|
63
75
|
return {
|
|
64
76
|
data: creditCards,
|
|
@@ -67,6 +79,7 @@ const loaderFunction = async (
|
|
|
67
79
|
currentOrgUnit,
|
|
68
80
|
currentUser: user,
|
|
69
81
|
currentContract: contract,
|
|
82
|
+
localization: { labels: localizationLabels },
|
|
70
83
|
},
|
|
71
84
|
};
|
|
72
85
|
});
|
|
@@ -2,12 +2,16 @@ import storeConfig from "discovery.config";
|
|
|
2
2
|
|
|
3
3
|
import { OrderEntryLayout } from "../features/order-entry/layouts/OrderEntryLayout";
|
|
4
4
|
import { withErrorBoundary } from "../features/shared/components";
|
|
5
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
6
|
+
import { LocalizationProvider } from "../features/shared/localization/LocalizationContext";
|
|
7
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
5
8
|
import { validateOrderEntryAccessService } from "../features/shared/services";
|
|
6
9
|
import {
|
|
7
10
|
withAuthLoader,
|
|
8
11
|
withLoaderErrorBoundary,
|
|
9
12
|
} from "../features/shared/utils";
|
|
10
13
|
|
|
14
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
11
15
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -56,15 +60,20 @@ const getAuthCookieInfo = (
|
|
|
56
60
|
|
|
57
61
|
type OrderEntryPageQuery = Record<string, never>;
|
|
58
62
|
|
|
63
|
+
type OrderEntryPageData = { localizationLabels: LabelMap };
|
|
64
|
+
|
|
59
65
|
const loaderFunction = async (
|
|
60
66
|
data: LoaderData<OrderEntryPageQuery>
|
|
61
|
-
): Promise<AuthRouteProps<
|
|
67
|
+
): Promise<AuthRouteProps<OrderEntryPageData>> => {
|
|
62
68
|
return withAuthLoader(
|
|
63
69
|
data,
|
|
64
70
|
async () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
const localizationLabels = await getLocalizationLabelsService({
|
|
72
|
+
entryIds: LOCALIZATION_ENTRY_IDS.orderEntry,
|
|
73
|
+
locale: data.locale,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return { localizationLabels };
|
|
68
77
|
},
|
|
69
78
|
{ validateAccess: validateOrderEntryAccessService }
|
|
70
79
|
);
|
|
@@ -75,7 +84,7 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
|
75
84
|
redirectToError: true,
|
|
76
85
|
});
|
|
77
86
|
|
|
78
|
-
const OrderEntryPage = (props: AuthRouteProps<
|
|
87
|
+
const OrderEntryPage = (props: AuthRouteProps<OrderEntryPageData>) => {
|
|
79
88
|
if (!props.authorized) return null;
|
|
80
89
|
|
|
81
90
|
const cookieHeader = props.clientContext?.cookie ?? "";
|
|
@@ -106,16 +115,18 @@ const OrderEntryPage = (props: AuthRouteProps<undefined>) => {
|
|
|
106
115
|
const userId = props.clientContext?.userId;
|
|
107
116
|
|
|
108
117
|
return (
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
<LocalizationProvider labels={props.data?.localizationLabels ?? {}}>
|
|
119
|
+
<OrderEntryLayout
|
|
120
|
+
vtexIdclientAutCookie={vtexIdclientAutCookie}
|
|
121
|
+
vtexIdclientAutCookie_client={vtexIdclientAutCookie}
|
|
122
|
+
segment={segment}
|
|
123
|
+
session={session}
|
|
124
|
+
account={account}
|
|
125
|
+
locale={locale}
|
|
126
|
+
customerId={customerId}
|
|
127
|
+
userId={userId}
|
|
128
|
+
/>
|
|
129
|
+
</LocalizationProvider>
|
|
119
130
|
);
|
|
120
131
|
};
|
|
121
132
|
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
} from "../features/org-units/services";
|
|
7
7
|
import { withErrorBoundary } from "../features/shared/components";
|
|
8
8
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
9
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
10
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
9
11
|
import { getBuyerPortalFeatureFlags } from "../features/shared/services/feature-flags/get-feature-flags.service";
|
|
10
12
|
import {
|
|
11
13
|
type ClientContext,
|
|
@@ -21,6 +23,7 @@ import type {
|
|
|
21
23
|
OrgUnitBasicData,
|
|
22
24
|
OrgUnitSettings,
|
|
23
25
|
} from "../features/org-units/types";
|
|
26
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
24
27
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
25
28
|
import type { UserData } from "../features/users/types";
|
|
26
29
|
|
|
@@ -34,6 +37,7 @@ export type OrgUnitDetailsPageData = {
|
|
|
34
37
|
};
|
|
35
38
|
context: {
|
|
36
39
|
clientContext: ClientContext;
|
|
40
|
+
localization?: { labels: LabelMap };
|
|
37
41
|
};
|
|
38
42
|
hasError?: boolean;
|
|
39
43
|
error?: {
|
|
@@ -75,12 +79,21 @@ const loaderFunction = async (
|
|
|
75
79
|
return { redirected: true } as unknown as OrgUnitDetailsPageData;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
const [orgUnit, user, contracts, settings] =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const [orgUnit, user, contracts, settings, localizationLabels] =
|
|
83
|
+
await Promise.all([
|
|
84
|
+
getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
|
|
85
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
86
|
+
getContractsByOrgUnitIdService({ orgUnitId, cookie }),
|
|
87
|
+
getOrgUnitSettingsService({ unitId: orgUnitId, cookie }),
|
|
88
|
+
getLocalizationLabelsService({
|
|
89
|
+
entryIds: [
|
|
90
|
+
LOCALIZATION_ENTRY_IDS.orgUnits,
|
|
91
|
+
LOCALIZATION_ENTRY_IDS.addresses,
|
|
92
|
+
LOCALIZATION_ENTRY_IDS.accountingFields,
|
|
93
|
+
],
|
|
94
|
+
locale: data.locale,
|
|
95
|
+
}),
|
|
96
|
+
]);
|
|
84
97
|
|
|
85
98
|
return {
|
|
86
99
|
data: {
|
|
@@ -91,6 +104,7 @@ const loaderFunction = async (
|
|
|
91
104
|
},
|
|
92
105
|
context: {
|
|
93
106
|
clientContext: { cookie, userId, ...clientContext },
|
|
107
|
+
localization: { labels: localizationLabels },
|
|
94
108
|
},
|
|
95
109
|
};
|
|
96
110
|
});
|
package/src/pages/org-units.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
import { withErrorBoundary } from "../features/shared/components";
|
|
10
10
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
11
11
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
12
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
13
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
12
14
|
import {
|
|
13
15
|
type ClientContext,
|
|
14
16
|
withLoaderErrorBoundary,
|
|
@@ -22,6 +24,7 @@ import type {
|
|
|
22
24
|
OrgUnitBasicData,
|
|
23
25
|
OrgUnitSearchResponse,
|
|
24
26
|
} from "../features/org-units/types";
|
|
27
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
25
28
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
26
29
|
import type { UserData } from "../features/users/types";
|
|
27
30
|
|
|
@@ -33,6 +36,7 @@ export type OrgUnitsPageData = {
|
|
|
33
36
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
34
37
|
currentContract: ContractData | null;
|
|
35
38
|
currentUser: UserData | null;
|
|
39
|
+
localization?: { labels: LabelMap };
|
|
36
40
|
};
|
|
37
41
|
hasError?: boolean;
|
|
38
42
|
error?: ErrorBoundaryProps;
|
|
@@ -52,12 +56,17 @@ const loaderFunction = async (
|
|
|
52
56
|
return withAuthLoader(
|
|
53
57
|
data,
|
|
54
58
|
async ({ cookie, customerId, userId, ...restClientContext }) => {
|
|
55
|
-
const currentOrgUnit = await
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const [currentOrgUnit, user, localizationLabels] = await Promise.all([
|
|
60
|
+
getOrgUnitBasicDataService({
|
|
61
|
+
id: data.query.orgUnitId,
|
|
62
|
+
cookie,
|
|
63
|
+
}),
|
|
64
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
65
|
+
getLocalizationLabelsService({
|
|
66
|
+
entryIds: LOCALIZATION_ENTRY_IDS.orgUnits,
|
|
67
|
+
locale: data.locale,
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
61
70
|
|
|
62
71
|
// Organizational Units don't need contract data, but the sidebar
|
|
63
72
|
// (rendered by shared layouts) uses `currentContract` for its identity
|
|
@@ -78,6 +87,8 @@ const loaderFunction = async (
|
|
|
78
87
|
...restClientContext,
|
|
79
88
|
};
|
|
80
89
|
|
|
90
|
+
const localization = { labels: localizationLabels };
|
|
91
|
+
|
|
81
92
|
if (search) {
|
|
82
93
|
return {
|
|
83
94
|
data: await searchOrgUnitsByNameService({
|
|
@@ -91,6 +102,7 @@ const loaderFunction = async (
|
|
|
91
102
|
currentOrgUnit,
|
|
92
103
|
currentContract,
|
|
93
104
|
currentUser: user,
|
|
105
|
+
localization,
|
|
94
106
|
},
|
|
95
107
|
};
|
|
96
108
|
}
|
|
@@ -118,6 +130,7 @@ const loaderFunction = async (
|
|
|
118
130
|
currentOrgUnit,
|
|
119
131
|
currentContract,
|
|
120
132
|
currentUser: user,
|
|
133
|
+
localization,
|
|
121
134
|
},
|
|
122
135
|
};
|
|
123
136
|
}
|
|
@@ -133,6 +146,7 @@ const loaderFunction = async (
|
|
|
133
146
|
currentOrgUnit,
|
|
134
147
|
currentContract,
|
|
135
148
|
currentUser: user,
|
|
149
|
+
localization,
|
|
136
150
|
},
|
|
137
151
|
};
|
|
138
152
|
}
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
import { withErrorBoundary } from "../features/shared/components";
|
|
9
9
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
10
10
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
11
|
+
import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
|
|
12
|
+
import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
|
|
11
13
|
import {
|
|
12
14
|
type ClientContext,
|
|
13
15
|
withLoaderErrorBoundary,
|
|
@@ -20,6 +22,7 @@ import { getUserByIdService } from "../features/users/services";
|
|
|
20
22
|
import type { ContractData } from "../features/contracts/types";
|
|
21
23
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
22
24
|
import type { PaginatedPaymentMethod } from "../features/payment-methods/types";
|
|
25
|
+
import type { LabelMap } from "../features/shared/localization/types";
|
|
23
26
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
24
27
|
import type { UserData } from "../features/users/types";
|
|
25
28
|
|
|
@@ -32,6 +35,7 @@ export type PaymentMethodsPageData = {
|
|
|
32
35
|
clientContext: ClientContext;
|
|
33
36
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
34
37
|
currentUser: UserData | null;
|
|
38
|
+
localization?: { labels: LabelMap };
|
|
35
39
|
};
|
|
36
40
|
hasError?: boolean;
|
|
37
41
|
error?: ErrorBoundaryProps;
|
|
@@ -51,18 +55,16 @@ const loaderFunction = async (
|
|
|
51
55
|
const page = getValidPage(pageString);
|
|
52
56
|
|
|
53
57
|
return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
|
|
54
|
-
const currentOrgUnit
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
unitId: orgUnitId,
|
|
65
|
-
});
|
|
58
|
+
const [currentOrgUnit, user, contract, localizationLabels] =
|
|
59
|
+
await Promise.all([
|
|
60
|
+
getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
|
|
61
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
62
|
+
getContractDetailsService({ contractId, cookie, unitId: orgUnitId }),
|
|
63
|
+
getLocalizationLabelsService({
|
|
64
|
+
entryIds: LOCALIZATION_ENTRY_IDS.paymentMethods,
|
|
65
|
+
locale: data.locale,
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
66
68
|
|
|
67
69
|
const paymentMethods = await getPaymentMethodsByUnitIdService({
|
|
68
70
|
customerId: contractId,
|
|
@@ -88,6 +90,7 @@ const loaderFunction = async (
|
|
|
88
90
|
currentOrgUnit,
|
|
89
91
|
currentUser: user,
|
|
90
92
|
currentContract: contract,
|
|
93
|
+
localization: { labels: localizationLabels },
|
|
91
94
|
},
|
|
92
95
|
};
|
|
93
96
|
});
|