feat(FE-170,174): enhance number formatting in RecordingForm validation messages

This commit is contained in:
rstubryan
2025-11-20 11:25:36 +07:00
parent d0f2fefe1c
commit 1310c7401c
@@ -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 (
<span className='text-sm text-gray-600 whitespace-nowrap'>
(sisa: {remainingStock.toLocaleString('en-US')})
(sisa: {formatNumber(remainingStock)})
</span>
);
}
return (
<span className='text-sm text-gray-600 whitespace-nowrap'>
(tersedia: {availableStock.toLocaleString('en-US')})
(tersedia: {formatNumber(availableStock)})
</span>
);
},
@@ -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
}