optimize: use only number fields
This commit is contained in:
parent
967f65846c
commit
0c2053e2f4
@ -3,12 +3,63 @@ import elementsProps from '@/Components/Calculation/config/elements-props';
|
||||
import { getElementName } from '@/Components/Calculation/config/map/values';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { Values } from '@/stores/calculation/values/types';
|
||||
import type { InputNumberProps } from 'antd/es/input-number';
|
||||
import { z } from 'zod';
|
||||
|
||||
const Schema = ValuesSchema.pick({
|
||||
IRR_Perc: true,
|
||||
VATInLeaseObjectPrice: true,
|
||||
addEquipmentPrice: true,
|
||||
bonusCoefficient: true,
|
||||
calcBrokerRewardSum: true,
|
||||
calcDoubleAgentRewardSumm: true,
|
||||
comissionPerc: true,
|
||||
comissionRub: true,
|
||||
countSeats: true,
|
||||
creditRate: true,
|
||||
dealerBrokerRewardSumm: true,
|
||||
dealerRewardSumm: true,
|
||||
engineHours: true,
|
||||
engineVolume: true,
|
||||
finDepartmentRewardSumm: true,
|
||||
firstPaymentPerc: true,
|
||||
firstPaymentRub: true,
|
||||
importProgramSum: true,
|
||||
importerRewardPerc: true,
|
||||
importerRewardRub: true,
|
||||
indAgentRewardSumm: true,
|
||||
insFranchise: true,
|
||||
insKaskoPriceLeasePeriod: true,
|
||||
lastPaymentPerc: true,
|
||||
lastPaymentRub: true,
|
||||
leaseObjectCount: true,
|
||||
leaseObjectMotorPower: true,
|
||||
leaseObjectPrice: true,
|
||||
leaseObjectPriceWthtVAT: true,
|
||||
leaseObjectYear: true,
|
||||
leasingPeriod: true,
|
||||
maxMass: true,
|
||||
maxPriceChange: true,
|
||||
maxSpeed: true,
|
||||
mileage: true,
|
||||
minPriceChange: true,
|
||||
parmentsDecreasePercent: true,
|
||||
pi: true,
|
||||
redemptionPaymentSum: true,
|
||||
saleBonus: true,
|
||||
subsidySum: true,
|
||||
supplierDiscountPerc: true,
|
||||
supplierDiscountRub: true,
|
||||
tarif: true,
|
||||
totalPayments: true,
|
||||
vehicleTaxInLeasingPeriod: true,
|
||||
vehicleTaxInYear: true,
|
||||
});
|
||||
|
||||
type Values = keyof z.infer<typeof Schema>;
|
||||
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.omit({ insurance: true }).superRefine(async (values, ctx) => {
|
||||
return Schema.superRefine(async (values, ctx) => {
|
||||
/**
|
||||
* На изменение поля Процет убывания платежей tbxParmentsDecreasePercent необходимо заложить проверку:
|
||||
* Если значение поля меньше значения в поле "Минимальный % убывания платежей" evo_min_decreasing_perc из записи,
|
||||
@ -42,7 +93,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
}
|
||||
}
|
||||
|
||||
(Object.keys(values) as Array<Exclude<Values, 'insurance'>>).forEach((valueName) => {
|
||||
(Object.keys(values) as Values[]).forEach((valueName) => {
|
||||
const elementName = getElementName(valueName);
|
||||
if (elementName) {
|
||||
const props = elementsProps[elementName] as InputNumberProps<number>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user