mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
feat(FE-170,174): enhance number formatting in RecordingForm validation messages
This commit is contained in:
@@ -51,7 +51,7 @@ import {
|
|||||||
} from './RecordingForm.schema';
|
} from './RecordingForm.schema';
|
||||||
|
|
||||||
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
|
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 toast from 'react-hot-toast';
|
||||||
import ApprovalSteps, {
|
import ApprovalSteps, {
|
||||||
useApprovalSteps,
|
useApprovalSteps,
|
||||||
@@ -856,7 +856,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
if (!totalChickQty) return null;
|
if (!totalChickQty) return null;
|
||||||
|
|
||||||
if (qty > totalChickQty) {
|
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;
|
return null;
|
||||||
@@ -904,7 +904,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const availableStock = getAvailableStock(stock.product_warehouse_id);
|
const availableStock = getAvailableStock(stock.product_warehouse_id);
|
||||||
const requestedUsage = Number(stock.qty) || 0;
|
const requestedUsage = Number(stock.qty) || 0;
|
||||||
if (requestedUsage > availableStock) {
|
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;
|
return null;
|
||||||
},
|
},
|
||||||
@@ -922,13 +922,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
if (requestedUsage > 0) {
|
if (requestedUsage > 0) {
|
||||||
return (
|
return (
|
||||||
<span className='text-sm text-gray-600 whitespace-nowrap'>
|
<span className='text-sm text-gray-600 whitespace-nowrap'>
|
||||||
(sisa: {remainingStock.toLocaleString('en-US')})
|
(sisa: {formatNumber(remainingStock)})
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<span className='text-sm text-gray-600 whitespace-nowrap'>
|
<span className='text-sm text-gray-600 whitespace-nowrap'>
|
||||||
(tersedia: {availableStock.toLocaleString('en-US')})
|
(tersedia: {formatNumber(availableStock)})
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -1986,7 +1986,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
? `Total Ayam: ${
|
? `Total Ayam: ${
|
||||||
getLatestTotalChickQty(
|
getLatestTotalChickQty(
|
||||||
formik.values.project_flock_kandang_id
|
formik.values.project_flock_kandang_id
|
||||||
) ?? 'N/A'
|
) !== null
|
||||||
|
? formatNumber(
|
||||||
|
getLatestTotalChickQty(
|
||||||
|
formik.values.project_flock_kandang_id
|
||||||
|
)!
|
||||||
|
)
|
||||||
|
: 'N/A'
|
||||||
}`
|
}`
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user