refactor(FE): Allow supplier to be optional in movement form

This commit is contained in:
rstubryan
2026-01-26 21:21:40 +07:00
parent 2847f50bf7
commit 4c336f81c7
3 changed files with 7 additions and 15 deletions
@@ -37,7 +37,7 @@ type MovementFormSchemaType = {
value: number; value: number;
label: string; label: string;
} | null; } | null;
supplier_id: number; supplier_id?: number | null;
products: { products: {
product?: { product?: {
value: number; value: number;
@@ -69,7 +69,7 @@ export type DeliverySchema = {
value: number; value: number;
label: string; label: string;
} | null; } | null;
supplier_id: number; supplier_id?: number | null;
products: { products: {
product?: { product?: {
value: number; value: number;
@@ -151,9 +151,10 @@ const DeliveryObjectSchema: Yup.ObjectSchema<DeliverySchema> = Yup.object({
label: Yup.string().required(), label: Yup.string().required(),
}).nullable(), }).nullable(),
supplier_id: Yup.number() supplier_id: Yup.number()
.required('Supplier wajib diisi!') .optional()
.nullable()
.min(1, 'Supplier wajib diisi!') .min(1, 'Supplier wajib diisi!')
.typeError('Supplier wajib diisi!'), .typeError('Supplier harus berupa angka!'),
products: Yup.array() products: Yup.array()
.of(DeliveryProductObjectSchema) .of(DeliveryProductObjectSchema)
.min(1, 'Minimal harus ada 1 produk!') .min(1, 'Minimal harus ada 1 produk!')
@@ -1665,15 +1665,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
<span className='text-error'>*</span> <span className='text-error'>*</span>
</span> </span>
</th> </th>
<th> <th>Supplier</th>
Supplier
<span
className='tooltip tooltip-error tooltip-bottom z-9999'
data-tip='required'
>
<span className='text-error'>*</span>
</span>
</th>
<th> <th>
Plat Nomor Plat Nomor
<span <span
@@ -1787,7 +1779,6 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
</td> </td>
<td> <td>
<SelectInput <SelectInput
required
placeholder='Pilih supplier...' placeholder='Pilih supplier...'
value={delivery.supplier} value={delivery.supplier}
onChange={(val) => onChange={(val) =>
+1 -1
View File
@@ -73,7 +73,7 @@ export type CreateMovementPayloadData = {
document_index?: number; document_index?: number;
driver_name: string; driver_name: string;
vehicle_plate: string; vehicle_plate: string;
supplier_id: number; supplier_id?: number | null;
products: { products: {
product_id: number; product_id: number;
product_qty: number; product_qty: number;