mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE): Show detailed stock usage and remove limit check
This commit is contained in:
@@ -1078,14 +1078,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
if ((type as 'add' | 'edit' | 'detail') === 'detail') return null;
|
if ((type as 'add' | 'edit' | 'detail') === 'detail') return null;
|
||||||
const stock = formik.values.stocks?.[stockIdx];
|
const stock = formik.values.stocks?.[stockIdx];
|
||||||
if (!stock || !stock.product_warehouse_id) return null;
|
if (!stock || !stock.product_warehouse_id) return null;
|
||||||
const availableStock = getAvailableStock(stock.product_warehouse_id);
|
|
||||||
const requestedUsage = Number(stock.qty) || 0;
|
|
||||||
if (requestedUsage > availableStock) {
|
|
||||||
return `Jumlah pakai melebihi stok tersedia! Maksimal: ${formatNumber(availableStock)}`;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
[formik.values.stocks, getAvailableStock, type]
|
[formik.values.stocks, type]
|
||||||
);
|
);
|
||||||
|
|
||||||
const getStockUsageAdornment = useCallback(
|
const getStockUsageAdornment = useCallback(
|
||||||
@@ -1099,7 +1094,10 @@ 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: {formatNumber(remainingStock)})
|
(tersedia: {formatNumber(availableStock)} | pakai:{' '}
|
||||||
|
{formatNumber(requestedUsage)} | sisa:{' '}
|
||||||
|
{formatNumber(Math.max(remainingStock, 0))} | dipinjam:{' '}
|
||||||
|
{formatNumber(Math.max(-remainingStock, 0))})
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user