refactor(FE-137): replace stock availability text with Badge component in MovementForm

This commit is contained in:
rstubryan
2025-10-27 11:25:15 +07:00
parent 58369b8ffa
commit 0b0ecd3bc4
@@ -30,6 +30,7 @@ import { ProductWarehouseApi } from '@/services/api/inventory';
import { toast } from 'react-hot-toast';
import FileInput from '@/components/input/FileInput';
import CheckboxInput from '@/components/input/CheckboxInput';
import Badge from '@/components/Badge';
interface MovementFormProps {
type?: 'add' | 'edit' | 'detail';
@@ -518,16 +519,31 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
const stockInfo = warehouseStockMap.get(warehouseId);
if (!stockInfo) {
return (
<span className='text-sm text-gray-500 whitespace-nowrap'>
(Kosong)
</span>
<Badge
variant="ghost"
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 (
<span className='text-sm text-gray-500 whitespace-nowrap'>
(Tersedia {stockInfo.productCount} produk)
</span>
<Badge
variant="soft"
color={color}
size="sm"
className={{ badge: 'whitespace-nowrap font-semibold' }}
>
Tersedia {productCount} produk
</Badge>
);
},
[warehouseStockMap]