From 120a7ebdf9a99e33d269ad2a529cdd984a5b25bc Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 5 Aug 2025 11:03:06 +1000 Subject: [PATCH] Enhance formatting for item render functions (#10127) --- src/frontend/src/components/render/Part.tsx | 3 ++- src/frontend/src/components/render/Stock.tsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/components/render/Part.tsx b/src/frontend/src/components/render/Part.tsx index ac6b68a32c..b678109c61 100644 --- a/src/frontend/src/components/render/Part.tsx +++ b/src/frontend/src/components/render/Part.tsx @@ -3,6 +3,7 @@ import { Badge } from '@mantine/core'; import type { ReactNode } from 'react'; import { ModelType } from '@lib/enums/ModelType'; +import { formatDecimal } from '@lib/functions/Formatting'; import { getDetailUrl } from '@lib/functions/Navigation'; import { ApiIcon } from '../items/ApiIcon'; import { type InstanceRenderInterface, RenderInlineModel } from './Instance'; @@ -27,7 +28,7 @@ export function RenderPart( badgeColor = 'orange'; badgeText = t`No stock`; } else if (stock != null) { - badgeText = `${t`Stock`}: ${stock}`; + badgeText = `${t`Stock`}: ${formatDecimal(stock)}`; badgeColor = instance.minimum_stock > stock ? 'yellow' : 'green'; } diff --git a/src/frontend/src/components/render/Stock.tsx b/src/frontend/src/components/render/Stock.tsx index 3384bec3a3..f683dc7b7e 100644 --- a/src/frontend/src/components/render/Stock.tsx +++ b/src/frontend/src/components/render/Stock.tsx @@ -3,6 +3,7 @@ import { Text } from '@mantine/core'; import type { ReactNode } from 'react'; import { ModelType } from '@lib/enums/ModelType'; +import { formatDecimal } from '@lib/functions/Formatting'; import { getDetailUrl } from '@lib/functions/Navigation'; import { ApiIcon } from '../items/ApiIcon'; import { type InstanceRenderInterface, RenderInlineModel } from './Instance'; @@ -63,9 +64,9 @@ export function RenderStockItem( quantity_string += `${t`Serial Number`}: ${instance.serial}`; } else if (allocated > 0) { const available: number = Math.max(0, instance.quantity - allocated); - quantity_string = `${t`Available`}: ${available} / ${instance.quantity}`; + quantity_string = `${t`Available`}: ${formatDecimal(available)} / ${formatDecimal(instance.quantity)}`; } else if (instance?.quantity) { - quantity_string = `${t`Quantity`}: ${instance.quantity}`; + quantity_string = `${t`Quantity`}: ${formatDecimal(instance.quantity)}`; } let batch_string = '';