mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
refactor(FE-137): simplify stock display in MovementForm and RecordingForm, enhance input handling in SelectInput
This commit is contained in:
@@ -123,8 +123,8 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
projectFlock.kandangs.forEach((kandang) => {
|
||||
const isAlreadyRecorded = recordedProjectFlockIds.has(projectFlock.id);
|
||||
const label = isAlreadyRecorded
|
||||
? `${projectFlock.flock.name} - ${projectFlock.area.name} - ${kandang.name} (Sudah Direcord)`
|
||||
: `${projectFlock.flock.name} - ${projectFlock.area.name} - ${kandang.name}`;
|
||||
? `${projectFlock.flock.name} - ${kandang.name} (Sudah Direcord)`
|
||||
: `${projectFlock.flock.name} - ${kandang.name}`;
|
||||
|
||||
options.push({
|
||||
value: projectFlock.id,
|
||||
@@ -140,22 +140,21 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
if (isResponseSuccess(stockProducts)) {
|
||||
stockProducts.data.forEach((product) => {
|
||||
const warehouse = product.warehouse;
|
||||
const stockText = product.quantity.toLocaleString('id-ID');
|
||||
|
||||
product.quantity.toLocaleString('en-US');
|
||||
const hasPakanFlag = product.product.flags?.includes('PAKAN');
|
||||
const hasOvkFlag = product.product.flags?.includes('OVK');
|
||||
|
||||
if (hasPakanFlag) {
|
||||
options.push({
|
||||
value: product.id,
|
||||
label: `[PAKAN] ${product.product.name} - ${warehouse?.name || ''} (${stockText})`
|
||||
label: `[PAKAN] ${product.product.name} - ${warehouse?.name || ''}`
|
||||
});
|
||||
}
|
||||
|
||||
if (hasOvkFlag) {
|
||||
options.push({
|
||||
value: product.id,
|
||||
label: `[OVK] ${product.product.name} - ${warehouse?.name || ''} (${stockText})`
|
||||
label: `[OVK] ${product.product.name} - ${warehouse?.name || ''}`
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -293,7 +292,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
const availableStock = getAvailableStock(stock.product_warehouse_id);
|
||||
const requestedUsage = Number(stock.usage_amount) || 0;
|
||||
if (requestedUsage > availableStock) {
|
||||
return `Jumlah pakai melebihi stok tersedia! Maksimal: ${availableStock.toLocaleString('id-ID')}`;
|
||||
return `Jumlah pakai melebihi stok tersedia! Maksimal: ${availableStock.toLocaleString('en-US')}`;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -311,13 +310,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
if (requestedUsage > 0) {
|
||||
return (
|
||||
<span className='text-sm text-gray-600 whitespace-nowrap'>
|
||||
(sisa: {remainingStock.toLocaleString('id-ID')})
|
||||
(sisa: {remainingStock.toLocaleString('en-US')})
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span className='text-sm text-gray-600 whitespace-nowrap'>
|
||||
(tersedia: {availableStock.toLocaleString('id-ID')})
|
||||
(tersedia: {availableStock.toLocaleString('en-US')})
|
||||
</span>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user