mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
fix: make vehicle_number and transport_per_item required if expedition_vendor exist
This commit is contained in:
@@ -185,7 +185,12 @@ const PurchaseAcceptApprovalItemObjectSchema: Yup.ObjectSchema<PurchaseAcceptApp
|
|||||||
.typeError('No. Surat jalan wajib diisi!'),
|
.typeError('No. Surat jalan wajib diisi!'),
|
||||||
vehicle_number: Yup.string()
|
vehicle_number: Yup.string()
|
||||||
.nullable()
|
.nullable()
|
||||||
.optional()
|
.when('expedition_vendor', {
|
||||||
|
is: (expeditionVendor?: { value?: number; label?: string } | null) =>
|
||||||
|
Boolean(expeditionVendor?.value),
|
||||||
|
then: (schema) => schema.required('Nomor kendaraan wajib diisi!'),
|
||||||
|
otherwise: (schema) => schema.optional(),
|
||||||
|
})
|
||||||
.typeError('Nomor kendaraan harus berupa plat nomor!'),
|
.typeError('Nomor kendaraan harus berupa plat nomor!'),
|
||||||
expedition_vendor: Yup.object({
|
expedition_vendor: Yup.object({
|
||||||
value: Yup.number().min(1).required(),
|
value: Yup.number().min(1).required(),
|
||||||
@@ -213,7 +218,13 @@ const PurchaseAcceptApprovalItemObjectSchema: Yup.ObjectSchema<PurchaseAcceptApp
|
|||||||
.typeError('Jumlah diterima harus berupa angka!'),
|
.typeError('Jumlah diterima harus berupa angka!'),
|
||||||
transport_per_item: Yup.mixed<string | number>()
|
transport_per_item: Yup.mixed<string | number>()
|
||||||
.nullable()
|
.nullable()
|
||||||
.optional()
|
.when('expedition_vendor', {
|
||||||
|
is: (expeditionVendor?: { value?: number; label?: string } | null) =>
|
||||||
|
Boolean(expeditionVendor?.value),
|
||||||
|
then: (schema) =>
|
||||||
|
schema.required('Biaya transport per item wajib diisi!'),
|
||||||
|
otherwise: (schema) => schema.optional(),
|
||||||
|
})
|
||||||
.test(
|
.test(
|
||||||
'is-valid-transport-per-item',
|
'is-valid-transport-per-item',
|
||||||
'Biaya transport per item harus berupa angka lebih dari atau sama dengan 0!',
|
'Biaya transport per item harus berupa angka lebih dari atau sama dengan 0!',
|
||||||
|
|||||||
Reference in New Issue
Block a user