mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
feat(FE-62,63,65): add document_path field to deliveries in MovementForm
This commit is contained in:
@@ -14,6 +14,7 @@ export type DeliverySchema = {
|
|||||||
delivery_cost?: number | undefined;
|
delivery_cost?: number | undefined;
|
||||||
delivery_cost_per_item?: number | undefined;
|
delivery_cost_per_item?: number | undefined;
|
||||||
document?: File | string | null;
|
document?: File | string | null;
|
||||||
|
document_path?: string | null;
|
||||||
driver_name: string;
|
driver_name: string;
|
||||||
vehicle_plate: string;
|
vehicle_plate: string;
|
||||||
supplier: {
|
supplier: {
|
||||||
@@ -86,6 +87,7 @@ const DeliveryObjectSchema: Yup.ObjectSchema<DeliverySchema> = Yup.object({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
document_path: Yup.string().optional(),
|
||||||
document_index: Yup.number().optional(),
|
document_index: Yup.number().optional(),
|
||||||
document: Yup.mixed<File | string>()
|
document: Yup.mixed<File | string>()
|
||||||
.nullable()
|
.nullable()
|
||||||
@@ -161,8 +163,8 @@ export const getMovementFormInitialValues = (
|
|||||||
? {
|
? {
|
||||||
value: initialValues.source_warehouse.id,
|
value: initialValues.source_warehouse.id,
|
||||||
label: initialValues.source_warehouse.name,
|
label: initialValues.source_warehouse.name,
|
||||||
area: initialValues.source_warehouse.area?.name,
|
area: initialValues.source_warehouse.area?.name ?? undefined,
|
||||||
location: initialValues.source_warehouse.location?.name,
|
location: initialValues.source_warehouse.location?.name ?? undefined,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
source_warehouse_id: initialValues?.source_warehouse?.id ?? 0,
|
source_warehouse_id: initialValues?.source_warehouse?.id ?? 0,
|
||||||
@@ -170,8 +172,9 @@ export const getMovementFormInitialValues = (
|
|||||||
? {
|
? {
|
||||||
value: initialValues.destination_warehouse.id,
|
value: initialValues.destination_warehouse.id,
|
||||||
label: initialValues.destination_warehouse.name,
|
label: initialValues.destination_warehouse.name,
|
||||||
area: initialValues.destination_warehouse.area?.name,
|
area: initialValues.destination_warehouse.area?.name ?? undefined,
|
||||||
location: initialValues.destination_warehouse.location?.name,
|
location:
|
||||||
|
initialValues.destination_warehouse.location?.name ?? undefined,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
destination_warehouse_id: initialValues?.destination_warehouse?.id ?? 0,
|
destination_warehouse_id: initialValues?.destination_warehouse?.id ?? 0,
|
||||||
@@ -185,19 +188,20 @@ export const getMovementFormInitialValues = (
|
|||||||
product_qty: detail.quantity,
|
product_qty: detail.quantity,
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
deliveries:
|
deliveries:
|
||||||
initialValues?.deliveries?.map((d) => {
|
initialValues?.deliveries?.map((d) => ({
|
||||||
return {
|
delivery_cost: d.shipping_cost_total ?? undefined,
|
||||||
delivery_cost: d.shipping_cost_total,
|
delivery_cost_per_item: d.shipping_cost_item ?? undefined,
|
||||||
delivery_cost_per_item: d.shipping_cost_item,
|
document_number: d.document_number ?? '',
|
||||||
document_index: 0,
|
document: d.document_path ?? null,
|
||||||
document: d.document_path || null,
|
document_path: d.document_path ?? null,
|
||||||
driver_name: d.driver_name,
|
driver_name: d.driver_name ?? '',
|
||||||
vehicle_plate: d.vehicle_plate,
|
vehicle_plate: d.vehicle_plate ?? '',
|
||||||
supplier: d.supplier
|
supplier: d.supplier
|
||||||
? { value: d.supplier.id, label: d.supplier.name }
|
? { value: d.supplier.id, label: d.supplier.name }
|
||||||
: null,
|
: null,
|
||||||
supplier_id: d.supplier?.id ?? 0,
|
supplier_id: d.supplier?.id ?? 0,
|
||||||
products: d.items.map((item) => {
|
products:
|
||||||
|
d.items?.map((item) => {
|
||||||
const productData = detailIdToProductId.get(
|
const productData = detailIdToProductId.get(
|
||||||
item.stock_transfer_detail_id
|
item.stock_transfer_detail_id
|
||||||
);
|
);
|
||||||
@@ -208,8 +212,7 @@ export const getMovementFormInitialValues = (
|
|||||||
product_id: productData?.id ?? 0,
|
product_id: productData?.id ?? 0,
|
||||||
product_qty: item.quantity,
|
product_qty: item.quantity,
|
||||||
};
|
};
|
||||||
}),
|
}) ?? [],
|
||||||
};
|
})) ?? [],
|
||||||
}) ?? [],
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
delivery_cost: d.delivery_cost ?? 0,
|
delivery_cost: d.delivery_cost ?? 0,
|
||||||
delivery_cost_per_item: d.delivery_cost_per_item ?? 0,
|
delivery_cost_per_item: d.delivery_cost_per_item ?? 0,
|
||||||
document_index: documentIndex,
|
document_index: documentIndex,
|
||||||
|
document_path: d.document_path,
|
||||||
driver_name: d.driver_name,
|
driver_name: d.driver_name,
|
||||||
vehicle_plate: d.vehicle_plate,
|
vehicle_plate: d.vehicle_plate,
|
||||||
supplier_id: d.supplier_id,
|
supplier_id: d.supplier_id,
|
||||||
@@ -1156,32 +1157,44 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<FileInput
|
{type === 'detail' ? (
|
||||||
name={`deliveries.${idx}.document`}
|
<TextInput
|
||||||
onChange={(e) => {
|
readOnly
|
||||||
const file = e.target.files?.[0];
|
value={delivery.document_path || '-'}
|
||||||
if (file) {
|
className={{
|
||||||
if (file.size > 2 * 1024 * 1024) {
|
wrapper: 'w-full min-w-52 md:w-72 lg:w-80',
|
||||||
toast.error('Ukuran dokumen maksimal 2 MB!');
|
}}
|
||||||
return;
|
name={`deliveries.${idx}.document_path`}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<FileInput
|
||||||
|
name={`deliveries.${idx}.document`}
|
||||||
|
onChange={(e) => {
|
||||||
|
const file = e.target.files?.[0];
|
||||||
|
if (file) {
|
||||||
|
if (file.size > 2 * 1024 * 1024) {
|
||||||
|
toast.error(
|
||||||
|
'Ukuran dokumen maksimal 2 MB!'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formik.setFieldValue(
|
||||||
|
`deliveries.${idx}.document`,
|
||||||
|
file
|
||||||
|
);
|
||||||
}
|
}
|
||||||
formik.setFieldValue(
|
}}
|
||||||
`deliveries.${idx}.document`,
|
{...isRepeaterInputError(
|
||||||
file
|
'deliveries',
|
||||||
);
|
'document',
|
||||||
}
|
idx
|
||||||
}}
|
)}
|
||||||
{...isRepeaterInputError(
|
className={{
|
||||||
'deliveries',
|
wrapper:
|
||||||
'document',
|
'w-full min-w-72 md:w-min-80 lg:w-min-96',
|
||||||
idx
|
}}
|
||||||
)}
|
/>
|
||||||
readOnly={type === 'detail'}
|
)}
|
||||||
className={{
|
|
||||||
wrapper:
|
|
||||||
'w-full min-w-72 md:w-min-80 lg:w-min-96',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|||||||
Reference in New Issue
Block a user