process/leasing-object: add selectConfiguration validation
This commit is contained in:
parent
4d9cdf79a4
commit
6adb1be0cf
@ -8,6 +8,7 @@ import { z } from 'zod';
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.pick({
|
||||
brand: true,
|
||||
configuration: true,
|
||||
countSeats: true,
|
||||
engineType: true,
|
||||
engineVolume: true,
|
||||
@ -30,6 +31,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
brand,
|
||||
model,
|
||||
leaseObjectUseFor,
|
||||
configuration,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
@ -57,6 +59,23 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
});
|
||||
}
|
||||
|
||||
if (model && !configuration) {
|
||||
const {
|
||||
data: { evo_equipments },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetConfigurationsDocument,
|
||||
variables: { modelId: model },
|
||||
});
|
||||
|
||||
if (evo_equipments?.length) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Не заполнено поле',
|
||||
path: ['selectConfiguration'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!leaseObjectUseFor) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user