add type ValidationContext
This commit is contained in:
parent
49d652c7fe
commit
14c16ec1c4
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import type { ProcessContext } from '../../types';
|
||||
import type { ValidationContext } from '../../types';
|
||||
import { getUser } from '@/api/user/query';
|
||||
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
|
||||
import { STALE_TIME } from '@/constants/request';
|
||||
@ -8,7 +8,7 @@ import dayjs from 'dayjs';
|
||||
|
||||
export type ProductId = ElementsTypes['selectProduct'];
|
||||
|
||||
export default function helper({ apolloClient, queryClient }: ProcessContext) {
|
||||
export default function helper({ apolloClient, queryClient }: ValidationContext) {
|
||||
return {
|
||||
async getCoefficient(productId: ProductId) {
|
||||
if (!productId) {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import type { ProcessContext } from '../types';
|
||||
import type { ValidationContext } from '../types';
|
||||
import helper from './lib/helper';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import { round } from 'tools';
|
||||
import { z } from 'zod';
|
||||
|
||||
export function createValidationSchema(context: ProcessContext) {
|
||||
export function createValidationSchema(context: ValidationContext) {
|
||||
const { getCoefficient } = helper(context);
|
||||
|
||||
return ValuesSchema.pick({ product: true, saleBonus: true }).superRefine(
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import type { ProcessContext } from '../types';
|
||||
import type { ValidationContext } from '../types';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { z } from 'zod';
|
||||
|
||||
export function createValidationSchema({ apolloClient }: ProcessContext) {
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.pick({ parmentsDecreasePercent: true, tarif: true }).superRefine(
|
||||
async ({ parmentsDecreasePercent, tarif: tarifId }, ctx) => {
|
||||
/**
|
||||
|
||||
@ -13,3 +13,5 @@ export type ProcessContext = {
|
||||
export type Process = {
|
||||
reactions: Record<string, (context: ProcessContext) => void>;
|
||||
};
|
||||
|
||||
export type ValidationContext = Omit<ProcessContext, 'store'>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user