@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.
Files changed (219) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/cms/b2b/components/.gitkeep +0 -0
  3. package/cms/b2b/pages/cms_content_type__i18n.jsonc +36 -0
  4. package/cypress/integration/localization.test.ts +482 -0
  5. package/cypress/support/commands.ts +8 -0
  6. package/docs/i18n/i18n-messages-format.md +391 -0
  7. package/docs/i18n/locales.json +701 -0
  8. package/docs/i18n/migration-inventory.md +959 -0
  9. package/package.json +3 -3
  10. package/specs/custom-localization-system.md +711 -0
  11. package/specs/multi-locale-e2e-validation.md +277 -0
  12. package/src/__mocks__/discovery.config.ts +12 -0
  13. package/src/features/accounting-fields/components/AccountingConfirmDelete/AccountingConfirmDelete.tsx +14 -4
  14. package/src/features/accounting-fields/components/AccountingFieldConfirmEdit/AccountingFieldConfirmEdit.tsx +11 -6
  15. package/src/features/accounting-fields/components/AccountingFieldDropdown/AccountingFieldDropdown.tsx +5 -3
  16. package/src/features/accounting-fields/components/AccountingFieldForm/AccountingFieldForm.tsx +33 -23
  17. package/src/features/accounting-fields/components/AccountingValueConfirmEdit/AccountingValueConfirmEdit.tsx +10 -6
  18. package/src/features/accounting-fields/components/AccountingValueDropdown/AccountingValueDropdown.tsx +19 -9
  19. package/src/features/accounting-fields/components/AccountingValueForm/AccountingValueForm.tsx +21 -10
  20. package/src/features/accounting-fields/components/CreateAccountingFieldDrawer/CreateAccountingFieldDrawer.tsx +11 -8
  21. package/src/features/accounting-fields/components/CreateAccountingValueDrawer/CreateAccountingValueDrawer.tsx +18 -7
  22. package/src/features/accounting-fields/components/DeleteAccountingFieldDrawer/DeleteAccountingFieldDrawer.tsx +14 -12
  23. package/src/features/accounting-fields/components/DeleteAccountingValueDrawer/DeleteAccountingValueDrawer.tsx +20 -10
  24. package/src/features/accounting-fields/components/EditAccountingFieldDrawer/EditAccountingFieldDrawer.tsx +5 -3
  25. package/src/features/accounting-fields/components/EditAccountingValueDrawer/EditAccountingValueDrawer.tsx +13 -6
  26. package/src/features/accounting-fields/components/RemoveValueFromUnitDrawer/RemoveValueFromUnitDrawer.tsx +19 -8
  27. package/src/features/accounting-fields/layouts/AccountingFieldLayout/AccountingFieldLayout.tsx +11 -9
  28. package/src/features/addresses/components/AddRecipientsDrawer/AddRecipientsDrawer.tsx +13 -7
  29. package/src/features/addresses/components/AddressDropdownMenu/AddressDropdownMenu.tsx +22 -20
  30. package/src/features/addresses/components/AddressForm/AddressForm.tsx +33 -22
  31. package/src/features/addresses/components/AddressLine/AddressLine.tsx +29 -25
  32. package/src/features/addresses/components/AddressLocationsList/AddressLocationsList.tsx +15 -6
  33. package/src/features/addresses/components/AddressRecipientsList/AddressRecipientsList.tsx +9 -4
  34. package/src/features/addresses/components/AddressesCard/AddressesCard.tsx +8 -5
  35. package/src/features/addresses/components/CreateAddressDrawer/CreateAddressDrawer.tsx +27 -14
  36. package/src/features/addresses/components/CreateAddressSettingsDrawer/CreateAddressSettingsDrawer.tsx +26 -21
  37. package/src/features/addresses/components/DeleteAddressDrawer/DeleteAddressDrawer.tsx +20 -16
  38. package/src/features/addresses/components/DeleteAddressLocationDrawer/DeleteAddressLocationDrawer.tsx +26 -14
  39. package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +20 -17
  40. package/src/features/addresses/components/EditAddressDrawer/EditAddressDrawer.tsx +12 -6
  41. package/src/features/addresses/components/EditAddressLocationDrawer/EditAddressLocationDrawer.tsx +24 -17
  42. package/src/features/addresses/components/EditRecipientAddressDrawer/EditRecipientAddressDrawer.tsx +17 -15
  43. package/src/features/addresses/components/LocationForm/LocationField/LocationField.tsx +8 -5
  44. package/src/features/addresses/components/LocationForm/LocationForm.tsx +9 -3
  45. package/src/features/addresses/components/LocationsDrawer/LocationsDrawer.tsx +15 -9
  46. package/src/features/addresses/components/RecipientsForm/RecipientItem/RecipientItem.tsx +55 -46
  47. package/src/features/addresses/components/RecipientsForm/RecipientsForm.tsx +4 -1
  48. package/src/features/addresses/components/RemoveAddressDrawer/RemoveAddressDrawer.tsx +21 -14
  49. package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +16 -9
  50. package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +11 -8
  51. package/src/features/b2b-agent/layouts/B2BAgentLayout/B2BAgentLayout.tsx +3 -1
  52. package/src/features/budgets/components/BudgetAddForm/BudgetAddForm.tsx +14 -12
  53. package/src/features/budgets/components/BudgetAddSuccess/BudgetAddSuccess.tsx +16 -14
  54. package/src/features/budgets/components/BudgetAllocationsSelection/BudgetAllocationsSelection.tsx +8 -5
  55. package/src/features/budgets/components/BudgetAllocationsTable/BudgetAllocationsTable.tsx +9 -6
  56. package/src/features/budgets/components/BudgetDeleteDrawer/BudgetDeleteDrawer.tsx +23 -17
  57. package/src/features/budgets/components/BudgetEditNotificationDrawer/BudgetEditNotificationDrawer.tsx +13 -6
  58. package/src/features/budgets/components/BudgetNotificationForm/BudgetNotificationForm.tsx +31 -24
  59. package/src/features/budgets/components/BudgetNotificationsInfo/BudgetNotificationsInfo.tsx +15 -9
  60. package/src/features/budgets/components/BudgetRemainingBalance/BudgetRemainingBalance.tsx +6 -2
  61. package/src/features/budgets/components/BudgetSettingsInfo/BudgetSettingsInfo.tsx +27 -10
  62. package/src/features/budgets/components/BudgetUsersTable/BudgetUsersTable.tsx +14 -7
  63. package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +11 -8
  64. package/src/features/budgets/components/CreateBudgetAllocationDrawer/CreateBudgetAllocationDrawer.tsx +8 -5
  65. package/src/features/budgets/components/CreateBudgetDrawer/CreateBudgetDrawer.tsx +31 -18
  66. package/src/features/budgets/components/DeleteBudgetAllocationDrawer/DeleteBudgetAllocationDrawer.tsx +17 -12
  67. package/src/features/budgets/components/EditBudgetDrawer/EditBudgetDrawer.tsx +14 -8
  68. package/src/features/budgets/components/EmptyState.tsx/EmptyState.tsx +4 -1
  69. package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +7 -5
  70. package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +5 -3
  71. package/src/features/budgets/messages/budgetNotifications.ts +5 -5
  72. package/src/features/budgets/utils/handleBudgetError.tsx +5 -8
  73. package/src/features/budgets/utils/handleBudgetError.types.ts +3 -0
  74. package/src/features/buying-policies/components/AccountingFieldCriteriaSelector/AccountingFieldCriteriaSelector.tsx +5 -3
  75. package/src/features/buying-policies/components/AccountingFieldCriteriaSelector/AccountingValueCriteriaSelector.tsx +20 -9
  76. package/src/features/buying-policies/components/AddBuyingPolicyDrawer/AddBuyingPolicyDrawer.tsx +8 -5
  77. package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/BasicBuyingPolicyDrawer.tsx +49 -33
  78. package/src/features/buying-policies/components/BudgetCriteriaSelector/BudgetCriteriaSelector.tsx +8 -2
  79. package/src/features/buying-policies/components/BuyingPolicyDropdownMenu/BuyingPolicyDropdownMenu.tsx +5 -3
  80. package/src/features/buying-policies/components/DeleteBuyingPolicyDrawer/DeleteBuyingPolicyDrawer.tsx +28 -24
  81. package/src/features/buying-policies/components/UpdateBuyingPolicyDrawer/UpdateBuyingPolicyDrawer.tsx +10 -7
  82. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +11 -4
  83. package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/BuyingPolicyDetailsLayout.tsx +26 -9
  84. package/src/features/buying-policies/utils/accountingFieldCriteriaHelpers.ts +2 -2
  85. package/src/features/buying-policies/utils/buyingPoliciesWorkflowTypes.ts +3 -3
  86. package/src/features/buying-policies/utils/orderFieldsCriteriaOptions.ts +8 -8
  87. package/src/features/buying-policies/utils/spendingLimitsCriteriaOptions.ts +6 -6
  88. package/src/features/contracts/components/ContractsCard/ContractsCard.tsx +7 -5
  89. package/src/features/contracts/layouts/ContractsLayout/ContractsLayout.tsx +9 -4
  90. package/src/features/credit-cards/components/CreateCreditCardDrawer/CreateCreditCardDrawer.tsx +17 -11
  91. package/src/features/credit-cards/components/CreditCardDropdownMenu/CreditCardDropdownMenu.tsx +17 -11
  92. package/src/features/credit-cards/components/CreditCardForm/CreditCardForm.tsx +8 -5
  93. package/src/features/credit-cards/components/CreditCardSettingsDrawer/CreditCardSettingsDrawer.tsx +10 -8
  94. package/src/features/credit-cards/components/DeleteCreditCardDrawer/DeleteCreditCardDrawer.tsx +19 -14
  95. package/src/features/credit-cards/components/EditCreditCardDrawer/EditCreditCardDrawer.tsx +14 -13
  96. package/src/features/credit-cards/components/RemoveCreditCardDrawer/RemoveCreditCardDrawer.tsx +18 -15
  97. package/src/features/credit-cards/layouts/CreditCardsLayout/CreditCardLayout.tsx +10 -4
  98. package/src/features/order-entry/layouts/OrderEntryLayout.tsx +3 -1
  99. package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +11 -9
  100. package/src/features/org-units/components/AuthSetupDrawer/AuthSetupDrawer.tsx +28 -16
  101. package/src/features/org-units/components/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +18 -12
  102. package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +28 -29
  103. package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbLink.tsx +4 -4
  104. package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/OrgUnitDetailsDropdownMenu.tsx +4 -2
  105. package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +23 -5
  106. package/src/features/org-units/components/OrgUnitDetailsNavbar/org-unit-details-navbar.scss +18 -2
  107. package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +6 -4
  108. package/src/features/org-units/components/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +9 -6
  109. package/src/features/org-units/components/OrganizationalUnitsCard/OrganizationalUnitsCard.tsx +15 -7
  110. package/src/features/org-units/components/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +15 -9
  111. package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +27 -26
  112. package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +8 -3
  113. package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +29 -18
  114. package/src/features/payment-methods/components/PaymentMethodSettingsDrawer/PaymentMethodSettingsDrawer.tsx +13 -9
  115. package/src/features/payment-methods/components/RemoveMethodButton/RemoveMethodButton.tsx +5 -2
  116. package/src/features/payment-methods/components/RemovePaymentMethodsDrawer/RemovePaymentMethodsDrawer.tsx +10 -7
  117. package/src/features/payment-methods/hooks/useRemovePaymentMethodSubmit.ts +6 -4
  118. package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +21 -15
  119. package/src/features/product-assortment/components/ProductAssortmentTable/ProductAssortmentTable.tsx +11 -7
  120. package/src/features/product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx +9 -6
  121. package/src/features/profile/components/ProfileCard/ProfileCard.tsx +8 -5
  122. package/src/features/profile/components/ProfileSummary/ProfileSummary.tsx +13 -6
  123. package/src/features/profile/layouts/ProfileLayout/ProfileLayout.tsx +16 -6
  124. package/src/features/roles/layout/RoleDetailsLayout/RoleDetailsLayout.tsx +4 -2
  125. package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +5 -3
  126. package/src/features/shared/components/BasicCard/BasicCard.tsx +6 -4
  127. package/src/features/shared/components/BasicCard/BasicCardLine.tsx +5 -4
  128. package/src/features/shared/components/CustomerSwitch/CustomerSwitchDrawer.tsx +10 -2
  129. package/src/features/shared/components/CustomerSwitch/CustomerSwitchSearch.tsx +4 -1
  130. package/src/features/shared/components/DropdownFilter/DropdownFilter.tsx +11 -7
  131. package/src/features/shared/components/Error/Error.tsx +13 -6
  132. package/src/features/shared/components/HeaderInside/HeaderInside.tsx +5 -2
  133. package/src/features/shared/components/InternalSearch/InternalSearch.tsx +4 -1
  134. package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +7 -5
  135. package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +23 -8
  136. package/src/features/shared/components/OrgUnitInputSearch/OrgUnitInputSearch.tsx +7 -2
  137. package/src/features/shared/components/Pagination/Pagination.tsx +6 -2
  138. package/src/features/shared/components/Paginator/Counter.tsx +11 -5
  139. package/src/features/shared/components/Paginator/Interval.tsx +4 -3
  140. package/src/features/shared/components/Paginator/NextPageButton.tsx +6 -2
  141. package/src/features/shared/components/SettingsDrawer/SettingsDrawer.tsx +6 -4
  142. package/src/features/shared/components/SettingsDrawer/SettingsDrawerListType.tsx +11 -10
  143. package/src/features/shared/components/SettingsDrawer/listTypeOptions.ts +10 -7
  144. package/src/features/shared/components/SortFilter/SortFilter.tsx +15 -8
  145. package/src/features/shared/components/Table/TableRow/TableRow.tsx +5 -1
  146. package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +7 -3
  147. package/src/features/shared/layouts/BaseTabsLayout/Navbar.tsx +28 -4
  148. package/src/features/shared/layouts/BaseTabsLayout/about-drawer/AboutDrawer.tsx +15 -5
  149. package/src/features/shared/layouts/BaseTabsLayout/base-tabs-layout.scss +24 -9
  150. package/src/features/shared/layouts/BaseTabsLayout/sidebar-drawer/SidebarDrawer.tsx +5 -2
  151. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +10 -5
  152. package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +7 -4
  153. package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +9 -4
  154. package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +7 -4
  155. package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +3 -0
  156. package/src/features/shared/layouts/SumaPageLayout/FullSidebarNav.tsx +13 -7
  157. package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +9 -5
  158. package/src/features/shared/localization/LocalizationContext.tsx +35 -0
  159. package/src/features/shared/localization/__tests__/createLocalize.test.ts +166 -0
  160. package/src/features/shared/localization/__tests__/get-localization-labels.service.test.ts +202 -0
  161. package/src/features/shared/localization/clients/LocalizationClient.ts +19 -0
  162. package/src/features/shared/localization/constants.ts +31 -0
  163. package/src/features/shared/localization/createLocalize.ts +78 -0
  164. package/src/features/shared/localization/services/get-localization-labels.service.ts +76 -0
  165. package/src/features/shared/localization/types.ts +66 -0
  166. package/src/features/shared/localization/withLocalization.tsx +22 -0
  167. package/src/features/shared/types/AuthRouteProps.ts +5 -0
  168. package/src/features/shared/types/LoaderData.ts +1 -0
  169. package/src/features/shared/utils/addresLabelToPropMapping.ts +10 -10
  170. package/src/features/shared/utils/constants.ts +1 -4
  171. package/src/features/shared/utils/getContractSettingsLinks.ts +17 -12
  172. package/src/features/shared/utils/getFinanceSettingsLinks.ts +14 -9
  173. package/src/features/shared/utils/getKeyByValue.ts +2 -2
  174. package/src/features/shared/utils/getOrganizationSettingsLinks.ts +13 -3
  175. package/src/features/shared/utils/getSumaListingSidebarLinks.ts +15 -10
  176. package/src/features/shared/utils/index.ts +2 -0
  177. package/src/features/shared/utils/routeLayoutMapping.ts +30 -30
  178. package/src/features/shared/utils/search.tsx +10 -0
  179. package/src/features/shared/utils/withAuth.tsx +6 -0
  180. package/src/features/shared/utils/withAuthLoader.ts +11 -0
  181. package/src/features/shared/utils/withLoaderErrorBoundary.ts +9 -0
  182. package/src/features/shared/utils/withProviders.tsx +13 -2
  183. package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +39 -27
  184. package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +41 -39
  185. package/src/features/users/components/DeleteUserDrawer/DeleteUserDrawer.tsx +27 -23
  186. package/src/features/users/components/EmailTransactionalSection/EmailTransactionalSection.tsx +6 -8
  187. package/src/features/users/components/LoginField/LoginField.tsx +4 -4
  188. package/src/features/users/components/ReassignOrgUnitDrawer/ReassignOrgUnitDrawer.tsx +22 -19
  189. package/src/features/users/components/ResetPasswordDrawer/ResetPasswordDrawer.tsx +16 -21
  190. package/src/features/users/components/UpdateUserDrawer/UpdateUserDrawer.tsx +26 -15
  191. package/src/features/users/components/UpdateUserDrawerWithUsername/UpdateUserDrawerWithUsername.tsx +22 -8
  192. package/src/features/users/components/UserDropdownMenu/UserDropdownMenu.tsx +7 -5
  193. package/src/features/users/components/UserFormFields/UserFormFields.tsx +9 -8
  194. package/src/features/users/components/UsersCard/UsersCard.tsx +4 -2
  195. package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +26 -10
  196. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +12 -8
  197. package/src/pages/accounting-field.tsx +28 -15
  198. package/src/pages/address-details.tsx +37 -26
  199. package/src/pages/addresses.tsx +27 -12
  200. package/src/pages/budgets-details.tsx +25 -15
  201. package/src/pages/budgets.tsx +31 -17
  202. package/src/pages/buyer-organization-manager.tsx +23 -12
  203. package/src/pages/buying-policies.tsx +38 -20
  204. package/src/pages/buying-policy-details.tsx +20 -19
  205. package/src/pages/contracts.tsx +15 -1
  206. package/src/pages/credit-cards.tsx +30 -17
  207. package/src/pages/order-entry.tsx +26 -15
  208. package/src/pages/org-unit-details.tsx +20 -6
  209. package/src/pages/org-units.tsx +20 -6
  210. package/src/pages/payment-groups.tsx +15 -12
  211. package/src/pages/productAssortment.tsx +10 -1
  212. package/src/pages/profile.tsx +14 -1
  213. package/src/pages/role-details.tsx +19 -6
  214. package/src/pages/roles.tsx +27 -14
  215. package/src/pages/user-details.tsx +29 -17
  216. package/src/pages/users.tsx +11 -0
  217. package/vitest.config.ts +13 -0
  218. package/src/features/addresses/constants/messages.ts +0 -8
  219. package/src/features/credit-cards/constants/messages.ts +0 -6
@@ -4,6 +4,8 @@ import { ProductAssortmentLayout } from "../features/product-assortment/layouts"
4
4
  import { withErrorBoundary } from "../features/shared/components";
5
5
  import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
6
6
  import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
7
+ import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
8
+ import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
7
9
  import {
8
10
  type ClientContext,
9
11
  withAuthLoader,
@@ -29,6 +31,7 @@ export type ProductAssortmentPageData = {
29
31
  currentOrgUnit: OrgUnitBasicData;
30
32
  currentContract: ContractData | null;
31
33
  currentUser: UserData | null;
34
+ localization: { labels: Record<string, string> };
32
35
  };
33
36
  hasError?: boolean;
34
37
  error?: ErrorBoundaryProps;
@@ -38,11 +41,12 @@ const loaderFunction = async (
38
41
  data: LoaderData<ProductAssortmentQuery>
39
42
  ): Promise<AuthRouteProps<ProductAssortmentPageData>> => {
40
43
  const { contractId, orgUnitId } = data.query;
44
+ const locale = data.locale ?? "";
41
45
 
42
46
  return withAuthLoader(
43
47
  data,
44
48
  async ({ customerId, cookie, userId, ...clientContext }) => {
45
- const [orgUnit, contract, user] = await Promise.all([
49
+ const [orgUnit, contract, user, localizationLabels] = await Promise.all([
46
50
  getOrgUnitBasicDataService({
47
51
  id: orgUnitId,
48
52
  cookie,
@@ -53,6 +57,10 @@ const loaderFunction = async (
53
57
  cookie,
54
58
  }),
55
59
  getUserByIdService({ orgUnitId, userId, cookie }),
60
+ getLocalizationLabelsService({
61
+ entryIds: LOCALIZATION_ENTRY_IDS.productAssortment,
62
+ locale,
63
+ }),
56
64
  ]);
57
65
 
58
66
  return {
@@ -66,6 +74,7 @@ const loaderFunction = async (
66
74
  currentOrgUnit: orgUnit,
67
75
  currentContract: contract,
68
76
  currentUser: user,
77
+ localization: { labels: localizationLabels },
69
78
  },
70
79
  };
71
80
  }
@@ -4,6 +4,8 @@ import { ProfileLayout } from "../features/profile/layouts";
4
4
  import { withErrorBoundary } from "../features/shared/components";
5
5
  import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
6
6
  import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
7
+ import { LOCALIZATION_ENTRY_IDS } from "../features/shared/localization/constants";
8
+ import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
7
9
  import {
8
10
  type ClientContext,
9
11
  withLoaderErrorBoundary,
@@ -24,6 +26,7 @@ export type ProfilePageData = {
24
26
  currentOrgUnit: OrgUnitBasicData | null;
25
27
  currentContract: ContractData | null;
26
28
  currentUser: UserData | null;
29
+ localization: { labels: Record<string, string> };
27
30
  };
28
31
  hasError?: boolean;
29
32
  error?: ErrorBoundaryProps;
@@ -42,7 +45,14 @@ export async function loaderFunction(
42
45
  return withAuthLoader(
43
46
  data,
44
47
  async ({ customerId, cookie, userId, ...clientContext }) => {
48
+ const labelsPromise = getLocalizationLabelsService({
49
+ entryIds: LOCALIZATION_ENTRY_IDS.profile,
50
+ locale: data.locale,
51
+ });
52
+
45
53
  if (!contractId || !orgUnitId) {
54
+ const localizationLabels = await labelsPromise;
55
+
46
56
  return {
47
57
  data: null,
48
58
  context: {
@@ -50,11 +60,12 @@ export async function loaderFunction(
50
60
  currentOrgUnit: null,
51
61
  currentContract: null,
52
62
  currentUser: null,
63
+ localization: { labels: localizationLabels },
53
64
  },
54
65
  };
55
66
  }
56
67
 
57
- const [orgUnit, contract, user] = await Promise.all([
68
+ const [orgUnit, contract, user, localizationLabels] = await Promise.all([
58
69
  getOrgUnitBasicDataService({
59
70
  cookie,
60
71
  id: orgUnitId,
@@ -65,6 +76,7 @@ export async function loaderFunction(
65
76
  unitId: orgUnitId,
66
77
  }),
67
78
  getUserByIdService({ orgUnitId, userId, cookie }),
79
+ labelsPromise,
68
80
  ]);
69
81
 
70
82
  return {
@@ -74,6 +86,7 @@ export async function loaderFunction(
74
86
  currentOrgUnit: orgUnit,
75
87
  currentContract: contract,
76
88
  currentUser: user,
89
+ localization: { labels: localizationLabels },
77
90
  },
78
91
  };
79
92
  }
@@ -5,6 +5,9 @@ import { RolePermission } from "../features/roles/types";
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 { createLocalize } from "../features/shared/localization/createLocalize";
10
+ import { getLocalizationLabelsService } from "../features/shared/localization/services/get-localization-labels.service";
8
11
  import {
9
12
  type ClientContext,
10
13
  withLoaderErrorBoundary,
@@ -26,6 +29,7 @@ export type RoleDetailsPageData = {
26
29
  clientContext: ClientContext;
27
30
  currentOrgUnit: OrgUnitBasicData | null;
28
31
  currentUser: UserData | null;
32
+ localization: { labels: Record<string, string> };
29
33
  };
30
34
  hasError?: boolean;
31
35
  error?: ErrorBoundaryProps;
@@ -37,12 +41,19 @@ const loaderFunction = async (
37
41
  const { orgUnitId, roleName } = data.query;
38
42
 
39
43
  return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
40
- const rolesAndPermissions = await getRolesAndPermissionsService({
41
- customerId: clientContext.customerId,
42
- unitId: orgUnitId,
43
- cookie,
44
- });
44
+ const [rolesAndPermissions, localizationLabels] = await Promise.all([
45
+ getRolesAndPermissionsService({
46
+ customerId: clientContext.customerId,
47
+ unitId: orgUnitId,
48
+ cookie,
49
+ }),
50
+ getLocalizationLabelsService({
51
+ entryIds: LOCALIZATION_ENTRY_IDS.roles,
52
+ locale: data.locale,
53
+ }),
54
+ ]);
45
55
 
56
+ const t = createLocalize(localizationLabels);
46
57
  const roles = Object.keys(rolesAndPermissions);
47
58
 
48
59
  const cleanRoleName = String(roleName)
@@ -62,13 +73,14 @@ const loaderFunction = async (
62
73
  if (!currentRole) {
63
74
  return {
64
75
  data: {
65
- roleName: "Not Found",
76
+ roleName: t("roles.details.notFound"),
66
77
  roles: [],
67
78
  },
68
79
  context: {
69
80
  clientContext: { cookie, userId, ...clientContext },
70
81
  currentOrgUnit,
71
82
  currentUser: user,
83
+ localization: { labels: localizationLabels },
72
84
  },
73
85
  };
74
86
  }
@@ -84,6 +96,7 @@ const loaderFunction = async (
84
96
  clientContext: { cookie, userId, ...clientContext },
85
97
  currentOrgUnit,
86
98
  currentUser: user,
99
+ localization: { labels: localizationLabels },
87
100
  },
88
101
  };
89
102
  });
@@ -6,6 +6,8 @@ import { RolePermission } from "../features/roles/types";
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,
@@ -28,6 +30,7 @@ export type RolesPageData = {
28
30
  currentOrgUnit: OrgUnitBasicData | null;
29
31
  currentContract: ContractData | null;
30
32
  currentUser: UserData | null;
33
+ localization: { labels: Record<string, string> };
31
34
  };
32
35
  hasError?: boolean;
33
36
  error?: ErrorBoundaryProps;
@@ -51,20 +54,29 @@ const loaderFunction = async (
51
54
  ? getContractDetailsService({ contractId, unitId: orgUnitId, cookie })
52
55
  : Promise.resolve(null);
53
56
 
54
- const [rolesAndPermissions, currentOrgUnit, user, currentContract] =
55
- await Promise.all([
56
- getRolesAndPermissionsService({
57
- unitId: orgUnitId,
58
- customerId: clientContext.customerId,
59
- cookie,
60
- }),
61
- getOrgUnitBasicDataService({
62
- id: orgUnitId,
63
- cookie,
64
- }),
65
- getUserByIdService({ orgUnitId, userId, cookie }),
66
- contractDetailsPromise,
67
- ]);
57
+ const [
58
+ rolesAndPermissions,
59
+ currentOrgUnit,
60
+ user,
61
+ currentContract,
62
+ localizationLabels,
63
+ ] = await Promise.all([
64
+ getRolesAndPermissionsService({
65
+ unitId: orgUnitId,
66
+ customerId: clientContext.customerId,
67
+ cookie,
68
+ }),
69
+ getOrgUnitBasicDataService({
70
+ id: orgUnitId,
71
+ cookie,
72
+ }),
73
+ getUserByIdService({ orgUnitId, userId, cookie }),
74
+ contractDetailsPromise,
75
+ getLocalizationLabelsService({
76
+ entryIds: LOCALIZATION_ENTRY_IDS.roles,
77
+ locale: data.locale,
78
+ }),
79
+ ]);
68
80
 
69
81
  return {
70
82
  data: {
@@ -75,6 +87,7 @@ const loaderFunction = async (
75
87
  currentOrgUnit,
76
88
  currentContract,
77
89
  currentUser: user,
90
+ localization: { labels: localizationLabels },
78
91
  },
79
92
  };
80
93
  });
@@ -6,6 +6,8 @@ import { getRolesIdsService } from "../features/roles/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,
@@ -17,6 +19,7 @@ import { getUserByIdService } from "../features/users/services/get-user-by-id.se
17
19
 
18
20
  import type { OrgUnitBasicData } from "../features/org-units/types";
19
21
  import type { RoleData } from "../features/roles/types";
22
+ import type { LabelMap } from "../features/shared/localization/types";
20
23
  import type { AuthRouteProps, LoaderData } from "../features/shared/types";
21
24
  import type { UserData } from "../features/users/types";
22
25
 
@@ -35,6 +38,7 @@ export type UserDetailsPageData = {
35
38
  clientContext: ClientContext;
36
39
  currentOrgUnit: OrgUnitBasicData | null;
37
40
  currentUser: UserData | null;
41
+ localization?: { labels: LabelMap };
38
42
  };
39
43
  hasError?: boolean;
40
44
  error?: ErrorBoundaryProps;
@@ -55,23 +59,30 @@ const loaderFunction = async (
55
59
  data.res?.end();
56
60
  }
57
61
 
58
- const [currentOrgUnit, orgUnitFromUser, rolesOptions] = await Promise.all(
59
- [
60
- getOrgUnitBasicDataService({
61
- id: orgUnitId,
62
- cookie,
63
- }),
64
- getOrgUnitByUserIdService({
65
- userId,
66
- cookie,
67
- }),
68
- getRolesIdsService({
69
- unitId: orgUnitId,
70
- customerId,
71
- cookie,
72
- }),
73
- ]
74
- );
62
+ const [
63
+ currentOrgUnit,
64
+ orgUnitFromUser,
65
+ rolesOptions,
66
+ localizationLabels,
67
+ ] = await Promise.all([
68
+ getOrgUnitBasicDataService({
69
+ id: orgUnitId,
70
+ cookie,
71
+ }),
72
+ getOrgUnitByUserIdService({
73
+ userId,
74
+ cookie,
75
+ }),
76
+ getRolesIdsService({
77
+ unitId: orgUnitId,
78
+ customerId,
79
+ cookie,
80
+ }),
81
+ getLocalizationLabelsService({
82
+ entryIds: LOCALIZATION_ENTRY_IDS.users,
83
+ locale: data.locale,
84
+ }),
85
+ ]);
75
86
 
76
87
  return {
77
88
  data: {
@@ -86,6 +97,7 @@ const loaderFunction = async (
86
97
  clientContext: { cookie, customerId, ...clientContext },
87
98
  currentOrgUnit,
88
99
  currentUser: user,
100
+ localization: { labels: localizationLabels },
89
101
  },
90
102
  };
91
103
  }
@@ -5,6 +5,8 @@ import { RoleData } from "../features/roles/types";
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,
@@ -20,6 +22,7 @@ import {
20
22
 
21
23
  import type { ContractData } from "../features/contracts/types";
22
24
  import type { OrgUnitBasicData } from "../features/org-units/types";
25
+ import type { LabelMap } from "../features/shared/localization/types";
23
26
  import type { AuthRouteProps, LoaderData } from "../features/shared/types";
24
27
  import type {
25
28
  GetUsersByOrgUnitIdServiceProps,
@@ -40,6 +43,7 @@ export type UsersPageData = {
40
43
  currentContract: ContractData | null;
41
44
  currentUser: UserData | null;
42
45
  rolesOptions: RoleData[];
46
+ localization?: { labels: LabelMap };
43
47
  };
44
48
  hasError?: boolean;
45
49
  error?: ErrorBoundaryProps;
@@ -62,6 +66,11 @@ const loaderFunction = async (
62
66
  async ({ cookie, userId, customerId, ...clientContext }) => {
63
67
  const validPage = getValidPage(page);
64
68
 
69
+ const localizationLabels = await getLocalizationLabelsService({
70
+ entryIds: LOCALIZATION_ENTRY_IDS.users,
71
+ locale: data.locale,
72
+ });
73
+
65
74
  if (!orgUnitId) {
66
75
  return {
67
76
  data: {
@@ -77,6 +86,7 @@ const loaderFunction = async (
77
86
  currentOrgUnit: null,
78
87
  currentContract: null,
79
88
  rolesOptions: [],
89
+ localization: { labels: localizationLabels },
80
90
  },
81
91
  };
82
92
  }
@@ -141,6 +151,7 @@ const loaderFunction = async (
141
151
  currentContract,
142
152
  currentUser: user,
143
153
  rolesOptions,
154
+ localization: { labels: localizationLabels },
144
155
  },
145
156
  };
146
157
  }
package/vitest.config.ts CHANGED
@@ -1,6 +1,19 @@
1
+ import { fileURLToPath } from "node:url";
2
+
1
3
  import { defineConfig } from "vitest/config";
2
4
 
3
5
  export default defineConfig({
6
+ resolve: {
7
+ alias: {
8
+ // `discovery.config` is provided by the host store at runtime and is not
9
+ // available in the test environment. Return an empty module so that any
10
+ // code that transitively imports it (e.g. the OTLP logger context) does
11
+ // not break unit tests.
12
+ "discovery.config": fileURLToPath(
13
+ new URL("./src/__mocks__/discovery.config.ts", import.meta.url)
14
+ ),
15
+ },
16
+ },
4
17
  test: {
5
18
  environment: "node",
6
19
  coverage: {
@@ -1,8 +0,0 @@
1
- export const ADDRESS_MESSAGES = {
2
- defaultSaved: "Default address saved successfully",
3
- defaultUnset: "Default address unset successfully",
4
- defaultError: "An error occurred while setting the default address",
5
- defaultUnsetError: "An error occurred while removing the default address",
6
- locationSettingsError: "Failed on update Location data",
7
- locationSettings: "Failed on fetch Location data",
8
- };
@@ -1,6 +0,0 @@
1
- export const CREDIT_CARD_MESSAGES = {
2
- defaultSaved: "Default credit card saved",
3
- defaultUnset: "Default credit card unset",
4
- defaultError: "Error setting default credit card",
5
- defaultUnsetError: "Error unsetting default credit card",
6
- };