From b05807bfc1bb30e932b33b27cb64dc53706b6695 Mon Sep 17 00:00:00 2001 From: Paolo Rossi Date: Tue, 8 Apr 2025 08:31:18 -0500 Subject: [PATCH] feat(inventory): Add quantity across locations translation and formatting (#11564) Co-authored-by: Stevche Radevski --- .../src/i18n/translations/$schema.json | 4 +++ .../dashboard/src/i18n/translations/en.json | 1 + .../dashboard/src/i18n/translations/es.json | 1 + .../inventory-item-general-section.tsx | 32 ++++++++----------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/admin/dashboard/src/i18n/translations/$schema.json b/packages/admin/dashboard/src/i18n/translations/$schema.json index ef42da4ac9..2b0c5c2162 100644 --- a/packages/admin/dashboard/src/i18n/translations/$schema.json +++ b/packages/admin/dashboard/src/i18n/translations/$schema.json @@ -3043,6 +3043,9 @@ "editItemDetails": { "type": "string" }, + "quantityAcrossLocations": { + "type": "string" + }, "create": { "type": "object", "properties": { @@ -3258,6 +3261,7 @@ "manageLocationQuantity", "deleteWarning", "editItemDetails", + "quantityAcrossLocations", "create", "reservation", "adjustInventory", diff --git a/packages/admin/dashboard/src/i18n/translations/en.json b/packages/admin/dashboard/src/i18n/translations/en.json index 59ce6102f8..cc98308d0c 100644 --- a/packages/admin/dashboard/src/i18n/translations/en.json +++ b/packages/admin/dashboard/src/i18n/translations/en.json @@ -814,6 +814,7 @@ "manageLocationQuantity": "Manage location quantity", "deleteWarning": "You are about to delete an inventory item. This action cannot be undone.", "editItemDetails": "Edit item details", + "quantityAcrossLocations": "{{quantity}} across {{locations}} locations", "create": { "title": "Create Inventory Item", "details": "Details", diff --git a/packages/admin/dashboard/src/i18n/translations/es.json b/packages/admin/dashboard/src/i18n/translations/es.json index 7504cf2157..2f4c61efd5 100644 --- a/packages/admin/dashboard/src/i18n/translations/es.json +++ b/packages/admin/dashboard/src/i18n/translations/es.json @@ -772,6 +772,7 @@ "manageLocations": "Gestionar ubicaciones", "deleteWarning": "Estás a punto de eliminar un ítem de inventario. Esta acción no puede deshacerse.", "editItemDetails": "Editar detalles del ítem", + "quantityAcrossLocations": "{{quantity}} en {{locations}} ubicaciones", "create": { "title": "Crear Ítem de Inventario", "details": "Detalles", diff --git a/packages/admin/dashboard/src/routes/inventory/inventory-detail/components/inventory-item-general-section.tsx b/packages/admin/dashboard/src/routes/inventory/inventory-detail/components/inventory-item-general-section.tsx index b97362580b..c2a6a8c9ce 100644 --- a/packages/admin/dashboard/src/routes/inventory/inventory-detail/components/inventory-item-general-section.tsx +++ b/packages/admin/dashboard/src/routes/inventory/inventory-detail/components/inventory-item-general-section.tsx @@ -13,6 +13,17 @@ export const InventoryItemGeneralSection = ({ inventoryItem, }: InventoryItemGeneralSectionProps) => { const { t } = useTranslation() + + const getQuantityFormat = (quantity: number) => { + if (quantity !== undefined && !isNaN(quantity)) { + return t("inventory.quantityAcrossLocations", { + quantity, + locations: inventoryItem.location_levels?.length, + }) + } + + return "-" + } return (
@@ -36,34 +47,19 @@ export const InventoryItemGeneralSection = ({ ) } - -const getQuantityFormat = (quantity: number, locations?: number) => { - if (quantity !== undefined && !isNaN(quantity)) { - return `${quantity} across ${locations ?? "-"} locations` - } - - return "-" -}