mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
feat(FE-137): add product flag badges to RecordingForm for enhanced visibility
This commit is contained in:
@@ -148,14 +148,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
if (hasPakanFlag) {
|
if (hasPakanFlag) {
|
||||||
options.push({
|
options.push({
|
||||||
value: product.id,
|
value: product.id,
|
||||||
label: `[PAKAN] ${product.product.name} - ${warehouse?.name || ''}`
|
label: `${product.product.name} - ${warehouse?.name || ''}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasOvkFlag) {
|
if (hasOvkFlag) {
|
||||||
options.push({
|
options.push({
|
||||||
value: product.id,
|
value: product.id,
|
||||||
label: `[OVK] ${product.product.name} - ${warehouse?.name || ''}`
|
label: `${product.product.name} - ${warehouse?.name || ''}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -354,6 +354,47 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
[projectFlocks, recordedProjectFlockIds]
|
[projectFlocks, recordedProjectFlockIds]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getProductFlagBadgeAdornment = useCallback(
|
||||||
|
(productWarehouseId: number) => {
|
||||||
|
if (!isResponseSuccess(stockProducts)) return null;
|
||||||
|
|
||||||
|
const productWarehouse = stockProducts.data.find(pw => pw.id === productWarehouseId);
|
||||||
|
if (!productWarehouse) return null;
|
||||||
|
|
||||||
|
const hasPakanFlag = productWarehouse.product.flags?.includes('PAKAN');
|
||||||
|
const hasOvkFlag = productWarehouse.product.flags?.includes('OVK');
|
||||||
|
|
||||||
|
if (hasPakanFlag) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
variant="soft"
|
||||||
|
color="info"
|
||||||
|
size="sm"
|
||||||
|
className={{ badge: 'whitespace-nowrap font-semibold text-xs px-2 py-0.5' }}
|
||||||
|
>
|
||||||
|
PAKAN
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasOvkFlag) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
variant="soft"
|
||||||
|
color="secondary"
|
||||||
|
size="sm"
|
||||||
|
className={{ badge: 'whitespace-nowrap font-semibold text-xs px-2 py-0.5' }}
|
||||||
|
>
|
||||||
|
OVK
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
[stockProducts]
|
||||||
|
);
|
||||||
|
|
||||||
const hasExceededStock = useMemo(() => {
|
const hasExceededStock = useMemo(() => {
|
||||||
if (type === 'detail') return false;
|
if (type === 'detail') return false;
|
||||||
return (
|
return (
|
||||||
@@ -1105,6 +1146,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
}}
|
}}
|
||||||
isSearchable
|
isSearchable
|
||||||
isDisabled={type === 'detail'}
|
isDisabled={type === 'detail'}
|
||||||
|
startAdornment={
|
||||||
|
stock.product_warehouse_id
|
||||||
|
? getProductFlagBadgeAdornment(stock.product_warehouse_id)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user