leaseObjectUsed improvements
This commit is contained in:
parent
6a95fbb3f2
commit
8e3fb86169
@ -16,15 +16,18 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
leaseObjectPrice: true,
|
||||
leaseObjectType: true,
|
||||
leaseObjectUseFor: true,
|
||||
leaseObjectUsed: true,
|
||||
leaseObjectYear: true,
|
||||
leasingPeriod: true,
|
||||
leasingWithoutKasko: true,
|
||||
legalClientRegion: true,
|
||||
maxMass: true,
|
||||
mileage: true,
|
||||
model: true,
|
||||
objectRegistration: true,
|
||||
opportunity: true,
|
||||
townRegistration: true,
|
||||
vin: true,
|
||||
withTrailer: true,
|
||||
}).superRefine(
|
||||
async (
|
||||
@ -45,6 +48,9 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
leaseObjectPrice,
|
||||
leaseObjectYear,
|
||||
leasingPeriod,
|
||||
vin,
|
||||
mileage,
|
||||
leaseObjectUsed,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
@ -198,6 +204,24 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
}
|
||||
}
|
||||
|
||||
if (leaseObjectUsed) {
|
||||
if (!vin) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не указан ' + titles.tbxVIN,
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
|
||||
if (!mileage) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не указан ' + titles.tbxMileage,
|
||||
path: ['eltKasko'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (insDecentral) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
|
||||
@ -48,21 +48,12 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
}
|
||||
}
|
||||
|
||||
if (leaseObjectUsed) {
|
||||
if (!mileage) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['tbxMileage'],
|
||||
});
|
||||
}
|
||||
if (!vin) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['tbxVIN'],
|
||||
});
|
||||
}
|
||||
if (leaseObjectUsed && !mileage) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['tbxMileage'],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user