mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE-137): replace stock availability text with Badge component in MovementForm
This commit is contained in:
@@ -30,6 +30,7 @@ import { ProductWarehouseApi } from '@/services/api/inventory';
|
|||||||
import { toast } from 'react-hot-toast';
|
import { toast } from 'react-hot-toast';
|
||||||
import FileInput from '@/components/input/FileInput';
|
import FileInput from '@/components/input/FileInput';
|
||||||
import CheckboxInput from '@/components/input/CheckboxInput';
|
import CheckboxInput from '@/components/input/CheckboxInput';
|
||||||
|
import Badge from '@/components/Badge';
|
||||||
|
|
||||||
interface MovementFormProps {
|
interface MovementFormProps {
|
||||||
type?: 'add' | 'edit' | 'detail';
|
type?: 'add' | 'edit' | 'detail';
|
||||||
@@ -518,16 +519,31 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
const stockInfo = warehouseStockMap.get(warehouseId);
|
const stockInfo = warehouseStockMap.get(warehouseId);
|
||||||
if (!stockInfo) {
|
if (!stockInfo) {
|
||||||
return (
|
return (
|
||||||
<span className='text-sm text-gray-500 whitespace-nowrap'>
|
<Badge
|
||||||
(Kosong)
|
variant="ghost"
|
||||||
</span>
|
color="neutral"
|
||||||
|
size="sm"
|
||||||
|
className={{ badge: 'whitespace-nowrap font-semibold' }}
|
||||||
|
>
|
||||||
|
Kosong
|
||||||
|
</Badge>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { productCount } = stockInfo;
|
||||||
|
let color: 'neutral' | 'success' | 'warning' = 'neutral';
|
||||||
|
if (productCount === 0) color = 'warning';
|
||||||
|
else if (productCount > 0) color = 'success';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className='text-sm text-gray-500 whitespace-nowrap'>
|
<Badge
|
||||||
(Tersedia {stockInfo.productCount} produk)
|
variant="soft"
|
||||||
</span>
|
color={color}
|
||||||
|
size="sm"
|
||||||
|
className={{ badge: 'whitespace-nowrap font-semibold' }}
|
||||||
|
>
|
||||||
|
Tersedia {productCount} produk
|
||||||
|
</Badge>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[warehouseStockMap]
|
[warehouseStockMap]
|
||||||
|
|||||||
Reference in New Issue
Block a user