@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
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
useAnalytics,
|
|
16
16
|
useBuyerPortal,
|
|
17
17
|
} from "../../../shared/hooks";
|
|
18
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
18
19
|
import { logMutationFailure } from "../../../shared/services/logger";
|
|
19
20
|
import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
|
|
20
21
|
import {
|
|
@@ -22,7 +23,6 @@ import {
|
|
|
22
23
|
sortingOptionsAllocations,
|
|
23
24
|
} from "../../../shared/utils";
|
|
24
25
|
import { parseAmount } from "../../../shared/utils/budgetAmountParse";
|
|
25
|
-
import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
|
|
26
26
|
import { getKeyByValue } from "../../../shared/utils/getKeyByValue";
|
|
27
27
|
import { useCreateBudget } from "../../hooks/useCreateBudget";
|
|
28
28
|
import { useGetAllocations } from "../../hooks/useGetAllocations";
|
|
@@ -79,6 +79,7 @@ export const CreateBudgetDrawer = ({
|
|
|
79
79
|
readonly = false,
|
|
80
80
|
...props
|
|
81
81
|
}: CreateBudgetDrawerProps) => {
|
|
82
|
+
const { t } = useLocalization();
|
|
82
83
|
const {
|
|
83
84
|
clientContext: { cookie },
|
|
84
85
|
} = useBuyerPortal();
|
|
@@ -218,7 +219,9 @@ export const CreateBudgetDrawer = ({
|
|
|
218
219
|
});
|
|
219
220
|
|
|
220
221
|
pushToast({
|
|
221
|
-
message:
|
|
222
|
+
message: `${t("budgets.toasts.budgetAdded")}\n${t(
|
|
223
|
+
"shared.messages.changesTimeout"
|
|
224
|
+
)}`,
|
|
222
225
|
status: "INFO",
|
|
223
226
|
});
|
|
224
227
|
close();
|
|
@@ -269,14 +272,18 @@ export const CreateBudgetDrawer = ({
|
|
|
269
272
|
}
|
|
270
273
|
|
|
271
274
|
pushToast({
|
|
272
|
-
message:
|
|
275
|
+
message: `${t("budgets.toasts.budgetAdded")}\n${t(
|
|
276
|
+
"shared.messages.changesTimeout"
|
|
277
|
+
)}`,
|
|
273
278
|
status: "INFO",
|
|
274
279
|
});
|
|
275
280
|
|
|
276
281
|
setTimeout(
|
|
277
282
|
() =>
|
|
278
283
|
pushToast({
|
|
279
|
-
message:
|
|
284
|
+
message: `${t("budgets.toasts.budgetPolicyAdded")}\n${t(
|
|
285
|
+
"shared.messages.changesTimeout"
|
|
286
|
+
)}`,
|
|
280
287
|
status: "INFO",
|
|
281
288
|
}),
|
|
282
289
|
1500
|
|
@@ -308,7 +315,7 @@ export const CreateBudgetDrawer = ({
|
|
|
308
315
|
});
|
|
309
316
|
|
|
310
317
|
pushToast({
|
|
311
|
-
message: error?.message || "
|
|
318
|
+
message: error?.message || t("budgets.errors.genericRetry"),
|
|
312
319
|
status: "ERROR",
|
|
313
320
|
});
|
|
314
321
|
},
|
|
@@ -351,7 +358,10 @@ export const CreateBudgetDrawer = ({
|
|
|
351
358
|
);
|
|
352
359
|
|
|
353
360
|
if (!isBudgetValid(budget)) {
|
|
354
|
-
pushToast({
|
|
361
|
+
pushToast({
|
|
362
|
+
message: t("budgets.validation.fillRequiredFields"),
|
|
363
|
+
status: "ERROR",
|
|
364
|
+
});
|
|
355
365
|
return;
|
|
356
366
|
}
|
|
357
367
|
const notifState = getBudgetNotificationSubmitState(budget.notifications);
|
|
@@ -363,7 +373,7 @@ export const CreateBudgetDrawer = ({
|
|
|
363
373
|
setShowNotificationsEmailError(true);
|
|
364
374
|
}
|
|
365
375
|
pushToast({
|
|
366
|
-
message: BUDGET_NOTIFICATION_BLOCK_MESSAGES[notifState.reason],
|
|
376
|
+
message: t(BUDGET_NOTIFICATION_BLOCK_MESSAGES[notifState.reason]),
|
|
367
377
|
status: "ERROR",
|
|
368
378
|
});
|
|
369
379
|
return;
|
|
@@ -411,7 +421,9 @@ export const CreateBudgetDrawer = ({
|
|
|
411
421
|
setShowNotificationsEmailError(true);
|
|
412
422
|
}
|
|
413
423
|
pushToast({
|
|
414
|
-
message:
|
|
424
|
+
message: t(
|
|
425
|
+
BUDGET_NOTIFICATION_BLOCK_MESSAGES[confirmNotifState.reason]
|
|
426
|
+
),
|
|
415
427
|
status: "ERROR",
|
|
416
428
|
});
|
|
417
429
|
return;
|
|
@@ -460,11 +472,11 @@ export const CreateBudgetDrawer = ({
|
|
|
460
472
|
data-fs-bp-create-budget-drawer-step-success={step === "confirmation"}
|
|
461
473
|
title={
|
|
462
474
|
step === "form" ? (
|
|
463
|
-
"
|
|
475
|
+
t("budgets.create.addNewBudget")
|
|
464
476
|
) : step === "allocations" ? (
|
|
465
477
|
<div data-fs-bp-create-budget-drawer-header-arrow>
|
|
466
478
|
<Icon name="ArrowPointLeft" onClick={() => setStep("form")} />
|
|
467
|
-
<span>
|
|
479
|
+
<span>{t("budgets.create.addBudgetAllocations")}</span>
|
|
468
480
|
</div>
|
|
469
481
|
) : (
|
|
470
482
|
""
|
|
@@ -540,7 +552,7 @@ export const CreateBudgetDrawer = ({
|
|
|
540
552
|
{step === "form" && (
|
|
541
553
|
<>
|
|
542
554
|
<BasicDrawer.Button variant="ghost" onClick={close}>
|
|
543
|
-
|
|
555
|
+
{t("shared.buttons.cancel")}
|
|
544
556
|
</BasicDrawer.Button>
|
|
545
557
|
<BasicDrawer.Button
|
|
546
558
|
variant="confirm"
|
|
@@ -560,7 +572,7 @@ export const CreateBudgetDrawer = ({
|
|
|
560
572
|
if (notificationsEnabled && !hasUsers)
|
|
561
573
|
setShowNotificationsUsersError(true);
|
|
562
574
|
pushToast({
|
|
563
|
-
message: "
|
|
575
|
+
message: t("budgets.validation.fillRequiredFields"),
|
|
564
576
|
status: "ERROR",
|
|
565
577
|
});
|
|
566
578
|
return;
|
|
@@ -583,10 +595,11 @@ export const CreateBudgetDrawer = ({
|
|
|
583
595
|
setShowNotificationsEmailError(true);
|
|
584
596
|
}
|
|
585
597
|
pushToast({
|
|
586
|
-
message:
|
|
598
|
+
message: t(
|
|
587
599
|
BUDGET_NOTIFICATION_BLOCK_MESSAGES[
|
|
588
600
|
continueNotifState.reason
|
|
589
|
-
]
|
|
601
|
+
]
|
|
602
|
+
),
|
|
590
603
|
status: "ERROR",
|
|
591
604
|
});
|
|
592
605
|
return;
|
|
@@ -596,7 +609,7 @@ export const CreateBudgetDrawer = ({
|
|
|
596
609
|
setStep("allocations");
|
|
597
610
|
}}
|
|
598
611
|
>
|
|
599
|
-
|
|
612
|
+
{t("shared.buttons.continue")}
|
|
600
613
|
</BasicDrawer.Button>
|
|
601
614
|
</>
|
|
602
615
|
)}
|
|
@@ -607,7 +620,7 @@ export const CreateBudgetDrawer = ({
|
|
|
607
620
|
variant="ghost"
|
|
608
621
|
onClick={() => handleAddBudget({ skipAllocations: true })}
|
|
609
622
|
>
|
|
610
|
-
|
|
623
|
+
{t("shared.buttons.skip")}
|
|
611
624
|
</BasicDrawer.Button>
|
|
612
625
|
<BasicDrawer.Button
|
|
613
626
|
isLoading={isCreatingBudget || listBudgetsLoading}
|
|
@@ -615,7 +628,7 @@ export const CreateBudgetDrawer = ({
|
|
|
615
628
|
disabled={!selectedAllocations.length}
|
|
616
629
|
onClick={() => handleAddBudget({})}
|
|
617
630
|
>
|
|
618
|
-
|
|
631
|
+
{t("shared.buttons.add")}
|
|
619
632
|
</BasicDrawer.Button>
|
|
620
633
|
</>
|
|
621
634
|
)}
|
|
@@ -626,7 +639,7 @@ export const CreateBudgetDrawer = ({
|
|
|
626
639
|
isLoading={isUpdateBudgetLoading}
|
|
627
640
|
onClick={handleConfirm}
|
|
628
641
|
>
|
|
629
|
-
|
|
642
|
+
{t("shared.buttons.confirm")}
|
|
630
643
|
</BasicDrawer.Button>
|
|
631
644
|
)}
|
|
632
645
|
</BasicDrawer.Footer>
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type BasicDrawerProps,
|
|
11
11
|
} from "../../../shared/components";
|
|
12
12
|
import { useBuyerPortal } from "../../../shared/hooks";
|
|
13
|
-
import {
|
|
13
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
14
14
|
import { useDeleteAllocation } from "../../hooks/useDeleteAllocations";
|
|
15
15
|
|
|
16
16
|
import type { BudgetAllocation } from "../../types";
|
|
@@ -35,6 +35,7 @@ export const DeleteBudgetAllocationDrawer = ({
|
|
|
35
35
|
contractId,
|
|
36
36
|
...otherProps
|
|
37
37
|
}: DeleteBudgetAllocationDrawerProps) => {
|
|
38
|
+
const { t } = useLocalization();
|
|
38
39
|
const [allocationNameConfirmation, setAllocationNameConfirmation] =
|
|
39
40
|
useState("");
|
|
40
41
|
const {
|
|
@@ -48,7 +49,9 @@ export const DeleteBudgetAllocationDrawer = ({
|
|
|
48
49
|
options: {
|
|
49
50
|
onSuccess: () => {
|
|
50
51
|
pushToast({
|
|
51
|
-
message:
|
|
52
|
+
message: `${t("budgets.toasts.allocationDeleted")}\n${t(
|
|
53
|
+
"shared.messages.changesTimeout"
|
|
54
|
+
)}`,
|
|
52
55
|
status: "INFO",
|
|
53
56
|
});
|
|
54
57
|
|
|
@@ -85,22 +88,24 @@ export const DeleteBudgetAllocationDrawer = ({
|
|
|
85
88
|
data-fs-bp-delete-allocation-drawer
|
|
86
89
|
close={close}
|
|
87
90
|
>
|
|
88
|
-
<BasicDrawer.Heading
|
|
91
|
+
<BasicDrawer.Heading
|
|
92
|
+
title={t("budgets.delete.allocationTitle")}
|
|
93
|
+
onClose={close}
|
|
94
|
+
/>
|
|
89
95
|
<BasicDrawer.Body data-fs-bp-delete-allocation-drawer-body>
|
|
90
96
|
<p>
|
|
91
|
-
|
|
97
|
+
{t("budgets.delete.permanentlyDeleteAllocation", [
|
|
98
|
+
<span key="allocation-name">{allocation.name}</span>,
|
|
99
|
+
])}
|
|
92
100
|
</p>
|
|
93
101
|
<br />
|
|
94
|
-
<p>
|
|
95
|
-
Deleting this allocation will permanently remove all its data, but
|
|
96
|
-
usage history will be kept for audit. This action cannot be undone.
|
|
97
|
-
</p>
|
|
102
|
+
<p>{t("budgets.delete.allocationWarning")}</p>
|
|
98
103
|
<br />
|
|
99
|
-
<p>
|
|
104
|
+
<p>{t("budgets.delete.confirmAllocationName")}</p>
|
|
100
105
|
<br />
|
|
101
106
|
|
|
102
107
|
<InputText
|
|
103
|
-
label="
|
|
108
|
+
label={t("budgets.forms.allocationName")}
|
|
104
109
|
value={allocationNameConfirmation}
|
|
105
110
|
onChange={(event) =>
|
|
106
111
|
setAllocationNameConfirmation(event.currentTarget.value)
|
|
@@ -110,7 +115,7 @@ export const DeleteBudgetAllocationDrawer = ({
|
|
|
110
115
|
|
|
111
116
|
<BasicDrawer.Footer>
|
|
112
117
|
<BasicDrawer.Button variant="ghost" onClick={close}>
|
|
113
|
-
|
|
118
|
+
{t("shared.buttons.cancel")}
|
|
114
119
|
</BasicDrawer.Button>
|
|
115
120
|
<BasicDrawer.Button
|
|
116
121
|
variant="confirm"
|
|
@@ -118,7 +123,7 @@ export const DeleteBudgetAllocationDrawer = ({
|
|
|
118
123
|
disabled={!isDeleteButtonEnabled || isLoadingDeleteAllocation}
|
|
119
124
|
isLoading={isLoadingDeleteAllocation}
|
|
120
125
|
>
|
|
121
|
-
|
|
126
|
+
{t("shared.buttons.delete")}
|
|
122
127
|
</BasicDrawer.Button>
|
|
123
128
|
</BasicDrawer.Footer>
|
|
124
129
|
</BasicDrawer>
|
|
@@ -6,9 +6,9 @@ import { useUI } from "@faststore/ui";
|
|
|
6
6
|
|
|
7
7
|
import { BasicDrawer, type BasicDrawerProps } from "../../../shared/components";
|
|
8
8
|
import { useAnalytics, useBuyerPortal } from "../../../shared/hooks";
|
|
9
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
9
10
|
import { ANALYTICS_EVENTS } from "../../../shared/services/logger/analytics/constants";
|
|
10
11
|
import { parseAmount } from "../../../shared/utils/budgetAmountParse";
|
|
11
|
-
import { CHANGES_TIMEOUT_MESSAGE } from "../../../shared/utils/constants";
|
|
12
12
|
import { useUpdateBudget } from "../../hooks";
|
|
13
13
|
import { BUDGET_NOTIFICATION_BLOCK_MESSAGES } from "../../messages/budgetNotifications";
|
|
14
14
|
import {
|
|
@@ -82,6 +82,7 @@ export const EditBudgetDrawer = ({
|
|
|
82
82
|
initialBudget,
|
|
83
83
|
...props
|
|
84
84
|
}: EditBudgetDrawerProps) => {
|
|
85
|
+
const { t } = useLocalization();
|
|
85
86
|
const { clientContext } = useBuyerPortal();
|
|
86
87
|
const { pushToast } = useUI();
|
|
87
88
|
const router = useRouter();
|
|
@@ -120,7 +121,9 @@ export const EditBudgetDrawer = ({
|
|
|
120
121
|
});
|
|
121
122
|
|
|
122
123
|
pushToast({
|
|
123
|
-
message:
|
|
124
|
+
message: `${t("budgets.toasts.budgetUpdated")}\n${t(
|
|
125
|
+
"shared.messages.changesTimeout"
|
|
126
|
+
)}`,
|
|
124
127
|
status: "INFO",
|
|
125
128
|
});
|
|
126
129
|
onSubmit?.(budget);
|
|
@@ -140,7 +143,7 @@ export const EditBudgetDrawer = ({
|
|
|
140
143
|
);
|
|
141
144
|
|
|
142
145
|
pushToast({
|
|
143
|
-
message: error?.message || "
|
|
146
|
+
message: error?.message || t("budgets.errors.genericRetry"),
|
|
144
147
|
status: "ERROR",
|
|
145
148
|
});
|
|
146
149
|
},
|
|
@@ -175,7 +178,7 @@ export const EditBudgetDrawer = ({
|
|
|
175
178
|
|
|
176
179
|
if (!isBudgetValid(budget)) {
|
|
177
180
|
pushToast({
|
|
178
|
-
message: "
|
|
181
|
+
message: t("budgets.validation.fillRequiredFieldsCorrectly"),
|
|
179
182
|
status: "ERROR",
|
|
180
183
|
});
|
|
181
184
|
return;
|
|
@@ -190,7 +193,7 @@ export const EditBudgetDrawer = ({
|
|
|
190
193
|
setShowNotificationsEmailError(true);
|
|
191
194
|
}
|
|
192
195
|
pushToast({
|
|
193
|
-
message: BUDGET_NOTIFICATION_BLOCK_MESSAGES[notifState.reason],
|
|
196
|
+
message: t(BUDGET_NOTIFICATION_BLOCK_MESSAGES[notifState.reason]),
|
|
194
197
|
status: "ERROR",
|
|
195
198
|
});
|
|
196
199
|
return;
|
|
@@ -225,7 +228,10 @@ export const EditBudgetDrawer = ({
|
|
|
225
228
|
size="large"
|
|
226
229
|
{...props}
|
|
227
230
|
>
|
|
228
|
-
<BasicDrawer.Heading
|
|
231
|
+
<BasicDrawer.Heading
|
|
232
|
+
title={t("budgets.edit.budgetSettings")}
|
|
233
|
+
onClose={close}
|
|
234
|
+
/>
|
|
229
235
|
|
|
230
236
|
<BasicDrawer.Body>
|
|
231
237
|
<BudgetAddForm
|
|
@@ -254,14 +260,14 @@ export const EditBudgetDrawer = ({
|
|
|
254
260
|
|
|
255
261
|
<BasicDrawer.Footer>
|
|
256
262
|
<BasicDrawer.Button variant="ghost" onClick={close}>
|
|
257
|
-
|
|
263
|
+
{t("shared.buttons.cancel")}
|
|
258
264
|
</BasicDrawer.Button>
|
|
259
265
|
<BasicDrawer.Button
|
|
260
266
|
variant="confirm"
|
|
261
267
|
isLoading={isLoading}
|
|
262
268
|
onClick={handleSubmit}
|
|
263
269
|
>
|
|
264
|
-
|
|
270
|
+
{t("shared.buttons.save")}
|
|
265
271
|
</BasicDrawer.Button>
|
|
266
272
|
</BasicDrawer.Footer>
|
|
267
273
|
</BasicDrawer>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Icon } from "../../../shared/components";
|
|
2
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
2
3
|
|
|
3
4
|
export function EmptyState() {
|
|
5
|
+
const { t } = useLocalization();
|
|
6
|
+
|
|
4
7
|
return (
|
|
5
8
|
<div data-fs-empty-state>
|
|
6
9
|
<div>
|
|
7
10
|
<Icon name="Paid" height={40} />
|
|
8
11
|
</div>
|
|
9
12
|
<div>
|
|
10
|
-
<p>
|
|
13
|
+
<p>{t("budgets.empty.noBudgets")}</p>
|
|
11
14
|
</div>
|
|
12
15
|
</div>
|
|
13
16
|
);
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useDrawerProps,
|
|
14
14
|
} from "../../../shared/hooks";
|
|
15
15
|
import { ContractTabsLayout, GlobalLayout } from "../../../shared/layouts";
|
|
16
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
16
17
|
import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
17
18
|
import { BudgetAllocationsTable } from "../../components/BudgetAllocationsTable/BudgetAllocationsTable";
|
|
18
19
|
import { BudgetDeleteDrawer } from "../../components/BudgetDeleteDrawer/BudgetDeleteDrawer";
|
|
@@ -30,6 +31,7 @@ export type BudgetsDetailsLayoutProps = {
|
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
34
|
+
const { t } = useLocalization();
|
|
33
35
|
const { currentOrgUnit: orgUnit, currentContract: contract } =
|
|
34
36
|
useBuyerPortal();
|
|
35
37
|
|
|
@@ -131,7 +133,7 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
|
131
133
|
|
|
132
134
|
pushToast({
|
|
133
135
|
status: "ERROR",
|
|
134
|
-
message: err.message || "
|
|
136
|
+
message: err.message || t("budgets.errors.unexpectedAllocationsLoad"),
|
|
135
137
|
});
|
|
136
138
|
},
|
|
137
139
|
},
|
|
@@ -144,7 +146,7 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
|
144
146
|
orgUnitId={orgUnit?.id ?? ""}
|
|
145
147
|
contractName={contract?.name ?? ""}
|
|
146
148
|
contractId={contract?.id ?? ""}
|
|
147
|
-
pageName="
|
|
149
|
+
pageName={t("budgets.titles.budgets")}
|
|
148
150
|
>
|
|
149
151
|
<div data-fs-bp-budgets-details-layout>
|
|
150
152
|
<header data-fs-bp-budgets-details-header-wrapper>
|
|
@@ -169,14 +171,14 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
|
169
171
|
onClick={openEditDrawer}
|
|
170
172
|
>
|
|
171
173
|
<Icon name="Edit" width={20} height={20} />
|
|
172
|
-
<span>
|
|
174
|
+
<span>{t("budgets.dropdown.editSettings")}</span>
|
|
173
175
|
</DropdownItem>
|
|
174
176
|
<DropdownItem
|
|
175
177
|
data-fs-bp-testid="budget-details-dropdown-allocation"
|
|
176
178
|
onClick={openAddAllocationDrawer}
|
|
177
179
|
>
|
|
178
180
|
<Icon name="Add" width={20} height={20} />
|
|
179
|
-
<span>
|
|
181
|
+
<span>{t("budgets.dropdown.addAllocations")}</span>
|
|
180
182
|
</DropdownItem>
|
|
181
183
|
<BasicDropdownMenu.Separator />
|
|
182
184
|
<DropdownItem
|
|
@@ -185,7 +187,7 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
|
|
|
185
187
|
onClick={openDeleteDrawer}
|
|
186
188
|
>
|
|
187
189
|
<Icon name="Delete" width={20} height={20} />
|
|
188
|
-
<span>
|
|
190
|
+
<span>{t("shared.buttons.delete")}</span>
|
|
189
191
|
</DropdownItem>
|
|
190
192
|
</BasicDropdownMenu>
|
|
191
193
|
</Dropdown>
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../../../shared/hooks";
|
|
11
11
|
import { FinanceTabsLayout, GlobalLayout } from "../../../shared/layouts";
|
|
12
12
|
import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
|
|
13
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
13
14
|
import { BudgetDeleteDrawer } from "../../components/BudgetDeleteDrawer/BudgetDeleteDrawer";
|
|
14
15
|
import { BudgetEditNotificationDrawer } from "../../components/BudgetEditNotificationDrawer/BudgetEditNotificationDrawer";
|
|
15
16
|
import { BudgetsTable } from "../../components/BudgetsTable/BudgetsTable";
|
|
@@ -33,6 +34,7 @@ export type BudgetsLayoutProps = {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export const BudgetsLayout = ({ data }: BudgetsLayoutProps) => {
|
|
37
|
+
const { t } = useLocalization();
|
|
36
38
|
const {
|
|
37
39
|
clientContext: { cookie },
|
|
38
40
|
currentOrgUnit: orgUnit,
|
|
@@ -166,13 +168,13 @@ export const BudgetsLayout = ({ data }: BudgetsLayoutProps) => {
|
|
|
166
168
|
const budgetsSection = (
|
|
167
169
|
<section data-fs-bp-budgets-layout>
|
|
168
170
|
<main data-fs-bp-main>
|
|
169
|
-
<HeaderInside title="
|
|
171
|
+
<HeaderInside title={t("budgets.titles.budgets")}>
|
|
170
172
|
<HeaderInside.Button onClick={openBudgetDrawer} />
|
|
171
173
|
</HeaderInside>
|
|
172
174
|
|
|
173
175
|
{budgetContent.length === 0 ? (
|
|
174
176
|
<div data-fs-empty-state>
|
|
175
|
-
<EmptyState title="
|
|
177
|
+
<EmptyState title={t("budgets.empty.noBudgets")} iconName="Paid" />
|
|
176
178
|
</div>
|
|
177
179
|
) : (
|
|
178
180
|
<section data-fs-bp-budgets-content>
|
|
@@ -277,7 +279,7 @@ export const BudgetsLayout = ({ data }: BudgetsLayoutProps) => {
|
|
|
277
279
|
{featureFlags?.suma ? (
|
|
278
280
|
<SumaPageLayout>{budgetsSection}</SumaPageLayout>
|
|
279
281
|
) : (
|
|
280
|
-
<FinanceTabsLayout pageName="
|
|
282
|
+
<FinanceTabsLayout pageName={t("budgets.titles.financeAndCompliance")}>
|
|
281
283
|
{budgetsSection}
|
|
282
284
|
</FinanceTabsLayout>
|
|
283
285
|
)}
|
|
@@ -5,17 +5,17 @@ export const BUDGET_NOTIFICATION_BLOCK_MESSAGES: Record<
|
|
|
5
5
|
string
|
|
6
6
|
> = {
|
|
7
7
|
[BUDGET_NOTIFICATION_REASONS.NO_USERS]:
|
|
8
|
-
"
|
|
8
|
+
"budgets.messages.noUsersNotification",
|
|
9
9
|
[BUDGET_NOTIFICATION_REASONS.NO_THRESHOLDS]:
|
|
10
|
-
"
|
|
10
|
+
"budgets.messages.noThresholdsNotification",
|
|
11
11
|
[BUDGET_NOTIFICATION_REASONS.INVALID_EMAIL]:
|
|
12
|
-
"
|
|
12
|
+
"budgets.messages.invalidEmailNotification",
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
/** Inline helper under the "Add users" Autocomplete when submit blocked for no users. */
|
|
16
16
|
export const BUDGET_NOTIFICATION_FORM_HELPER_NO_USERS =
|
|
17
|
-
"
|
|
17
|
+
"budgets.validation.selectAtLeastOneUser";
|
|
18
18
|
|
|
19
19
|
/** Inline helper when selected users include invalid emails while notifications are on. */
|
|
20
20
|
export const BUDGET_NOTIFICATION_FORM_HELPER_INVALID_EMAIL =
|
|
21
|
-
"
|
|
21
|
+
"budgets.validation.allUsersValidEmail";
|
|
@@ -6,8 +6,6 @@ import type {
|
|
|
6
6
|
ToastConfig,
|
|
7
7
|
} from "./handleBudgetError.types";
|
|
8
8
|
|
|
9
|
-
const DEFAULT_ERROR_MESSAGE = "An error occurred. Please try again.";
|
|
10
|
-
|
|
11
9
|
const parseError = (error: Error): ParsedError => {
|
|
12
10
|
try {
|
|
13
11
|
return JSON.parse(error.message);
|
|
@@ -15,8 +13,7 @@ const parseError = (error: Error): ParsedError => {
|
|
|
15
13
|
const errorObj = error as Error;
|
|
16
14
|
|
|
17
15
|
return {
|
|
18
|
-
message:
|
|
19
|
-
errorObj && errorObj.message ? errorObj.message : DEFAULT_ERROR_MESSAGE,
|
|
16
|
+
message: errorObj?.message ?? "",
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
19
|
};
|
|
@@ -25,6 +22,7 @@ export const handleBudgetError = ({
|
|
|
25
22
|
error,
|
|
26
23
|
orgUnitId,
|
|
27
24
|
onNavigateToUser,
|
|
25
|
+
t,
|
|
28
26
|
}: HandleBudgetErrorParams): ToastConfig => {
|
|
29
27
|
const parsedError = parseError(error as Error);
|
|
30
28
|
|
|
@@ -33,8 +31,7 @@ export const handleBudgetError = ({
|
|
|
33
31
|
const userId = userIdMatch?.[1];
|
|
34
32
|
|
|
35
33
|
return {
|
|
36
|
-
message:
|
|
37
|
-
"The selected user does not have any available email to receive the budget notifications.",
|
|
34
|
+
message: t("budgets.errors.userEmailNotFound"),
|
|
38
35
|
status: "ERROR",
|
|
39
36
|
icon:
|
|
40
37
|
userId && onNavigateToUser ? (
|
|
@@ -50,14 +47,14 @@ export const handleBudgetError = ({
|
|
|
50
47
|
);
|
|
51
48
|
}}
|
|
52
49
|
>
|
|
53
|
-
|
|
50
|
+
{t("budgets.actions.seeUserDetails")}
|
|
54
51
|
</button>
|
|
55
52
|
) : undefined,
|
|
56
53
|
};
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
return {
|
|
60
|
-
message: parsedError.message ||
|
|
57
|
+
message: parsedError.message || t("budgets.errors.genericRetry"),
|
|
61
58
|
status: "ERROR",
|
|
62
59
|
};
|
|
63
60
|
};
|
|
@@ -5,6 +5,7 @@ import { useUI } from "@faststore/ui";
|
|
|
5
5
|
import { useListAccountingFields } from "../../../accounting-fields/hooks";
|
|
6
6
|
import { CustomDropdown } from "../../../shared/components/CustomDropdown/CustomDropdown";
|
|
7
7
|
import { useBuyerPortal } from "../../../shared/hooks";
|
|
8
|
+
import { useLocalization } from "../../../shared/localization/LocalizationContext";
|
|
8
9
|
import {
|
|
9
10
|
extractFieldFromCriteria,
|
|
10
11
|
loadingOption,
|
|
@@ -22,6 +23,7 @@ export const AccountingFieldCriteriaSelector = ({
|
|
|
22
23
|
criteria,
|
|
23
24
|
onCriteriaChange,
|
|
24
25
|
}: AccountingFieldCriteriaSelectorProps) => {
|
|
26
|
+
const { t } = useLocalization();
|
|
25
27
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
26
28
|
const [fieldId, setFieldId] = useState<string>(
|
|
27
29
|
extractFieldFromCriteria(criteria)
|
|
@@ -39,7 +41,7 @@ export const AccountingFieldCriteriaSelector = ({
|
|
|
39
41
|
{
|
|
40
42
|
onError: () => {
|
|
41
43
|
pushToast({
|
|
42
|
-
message: "
|
|
44
|
+
message: t("buyingPolicies.errors.failedToFetchAccountingFields"),
|
|
43
45
|
status: "ERROR",
|
|
44
46
|
});
|
|
45
47
|
},
|
|
@@ -61,11 +63,11 @@ export const AccountingFieldCriteriaSelector = ({
|
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
const triggerLabel = listAccountingFieldLoading
|
|
64
|
-
? loadingOption[0].label
|
|
66
|
+
? t(loadingOption[0].label)
|
|
65
67
|
: field?.name;
|
|
66
68
|
|
|
67
69
|
const options = listAccountingFieldLoading
|
|
68
|
-
? loadingOption
|
|
70
|
+
? [{ label: t(loadingOption[0].label), value: loadingOption[0].value }]
|
|
69
71
|
: listAccountingFieldData?.map(({ name, id }) => ({
|
|
70
72
|
label: name,
|
|
71
73
|
value: id,
|