feat(inventory): Add quantity across locations translation and formatting (#11564)

Co-authored-by: Stevche Radevski <sradevski@live.com>
This commit is contained in:
Paolo Rossi
2025-04-08 08:31:18 -05:00
committed by GitHub
parent 78ee2e3063
commit b05807bfc1
4 changed files with 20 additions and 18 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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 (
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
@@ -36,34 +47,19 @@ export const InventoryItemGeneralSection = ({
<SectionRow title={t("fields.sku")} value={inventoryItem.sku ?? "-"} />
<SectionRow
title={t("fields.inStock")}
value={getQuantityFormat(
inventoryItem.stocked_quantity,
inventoryItem.location_levels?.length
)}
value={getQuantityFormat(inventoryItem.stocked_quantity)}
/>
<SectionRow
title={t("inventory.reserved")}
value={getQuantityFormat(
inventoryItem.reserved_quantity,
inventoryItem.location_levels?.length
)}
value={getQuantityFormat(inventoryItem.reserved_quantity)}
/>
<SectionRow
title={t("inventory.available")}
value={getQuantityFormat(
inventoryItem.stocked_quantity - inventoryItem.reserved_quantity,
inventoryItem.location_levels?.length
inventoryItem.stocked_quantity - inventoryItem.reserved_quantity
)}
/>
</Container>
)
}
const getQuantityFormat = (quantity: number, locations?: number) => {
if (quantity !== undefined && !isNaN(quantity)) {
return `${quantity} across ${locations ?? "-"} locations`
}
return "-"
}