From 1310c7401cb2f24fe45355f9453f8152f96499ea Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 20 Nov 2025 11:25:36 +0700 Subject: [PATCH] feat(FE-170,174): enhance number formatting in RecordingForm validation messages --- .../recording/form/RecordingForm.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index aa47950f..5900c84a 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -51,7 +51,7 @@ import { } from './RecordingForm.schema'; import { isResponseSuccess, isResponseError } from '@/lib/api-helper'; -import { formatDate } from '@/lib/helper'; +import { formatDate, formatNumber } from '@/lib/helper'; import toast from 'react-hot-toast'; import ApprovalSteps, { useApprovalSteps, @@ -856,7 +856,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { if (!totalChickQty) return null; if (qty > totalChickQty) { - return `Jumlah ayam tidak boleh melebihi total ayam tersedia! Maksimal: ${totalChickQty.toLocaleString('en-US')}`; + return `Jumlah ayam tidak boleh melebihi total ayam tersedia! Maksimal: ${formatNumber(totalChickQty)}`; } return null; @@ -904,7 +904,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const availableStock = getAvailableStock(stock.product_warehouse_id); const requestedUsage = Number(stock.qty) || 0; if (requestedUsage > availableStock) { - return `Jumlah pakai melebihi stok tersedia! Maksimal: ${availableStock.toLocaleString('en-US')}`; + return `Jumlah pakai melebihi stok tersedia! Maksimal: ${formatNumber(availableStock)}`; } return null; }, @@ -922,13 +922,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { if (requestedUsage > 0) { return ( - (sisa: {remainingStock.toLocaleString('en-US')}) + (sisa: {formatNumber(remainingStock)}) ); } return ( - (tersedia: {availableStock.toLocaleString('en-US')}) + (tersedia: {formatNumber(availableStock)}) ); }, @@ -1986,7 +1986,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { ? `Total Ayam: ${ getLatestTotalChickQty( formik.values.project_flock_kandang_id - ) ?? 'N/A' + ) !== null + ? formatNumber( + getLatestTotalChickQty( + formik.values.project_flock_kandang_id + )! + ) + : 'N/A' }` : undefined }