mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
F: Rework zod schema names and DeleteOperation dialog
This commit is contained in:
parent
c5bf72f889
commit
a967e957b3
|
@ -55,7 +55,7 @@ export function ModalForm({
|
|||
header,
|
||||
overflowVisible,
|
||||
|
||||
canSubmit,
|
||||
canSubmit = true,
|
||||
submitText = 'Продолжить',
|
||||
submitInvalidTooltip,
|
||||
beforeSubmit,
|
||||
|
|
|
@ -20,7 +20,7 @@ export interface ICurrentUser {
|
|||
/**
|
||||
* Represents login data, used to authenticate users.
|
||||
*/
|
||||
export const UserLoginSchema = z.object({
|
||||
export const schemaUserLogin = z.object({
|
||||
username: z.string().nonempty(errors.requiredField),
|
||||
password: z.string().nonempty(errors.requiredField)
|
||||
});
|
||||
|
@ -28,12 +28,12 @@ export const UserLoginSchema = z.object({
|
|||
/**
|
||||
* Represents login data, used to authenticate users.
|
||||
*/
|
||||
export type IUserLoginDTO = z.infer<typeof UserLoginSchema>;
|
||||
export type IUserLoginDTO = z.infer<typeof schemaUserLogin>;
|
||||
|
||||
/**
|
||||
* Represents data needed to update password for current user.
|
||||
*/
|
||||
export const ChangePasswordSchema = z
|
||||
export const schemaChangePassword = z
|
||||
.object({
|
||||
old_password: z.string().nonempty(errors.requiredField),
|
||||
new_password: z.string().nonempty(errors.requiredField),
|
||||
|
@ -51,7 +51,7 @@ export const ChangePasswordSchema = z
|
|||
/**
|
||||
* Represents data needed to update password for current user.
|
||||
*/
|
||||
export type IChangePasswordDTO = z.infer<typeof ChangePasswordSchema>;
|
||||
export type IChangePasswordDTO = z.infer<typeof schemaChangePassword>;
|
||||
|
||||
/**
|
||||
* Represents password reset request data.
|
||||
|
|
|
@ -12,7 +12,7 @@ import { TextInput } from '@/components/Input';
|
|||
import useQueryStrings from '@/hooks/useQueryStrings';
|
||||
import { resources } from '@/utils/constants';
|
||||
|
||||
import { IUserLoginDTO, UserLoginSchema } from '../backend/api';
|
||||
import { IUserLoginDTO, schemaUserLogin } from '../backend/api';
|
||||
import { useAuthSuspense } from '../backend/useAuth';
|
||||
import { useLogin } from '../backend/useLogin';
|
||||
import ExpectedAnonymous from '../components/ExpectedAnonymous';
|
||||
|
@ -29,7 +29,7 @@ function LoginPage() {
|
|||
resetField,
|
||||
formState: { errors }
|
||||
} = useForm({
|
||||
resolver: zodResolver(UserLoginSchema),
|
||||
resolver: zodResolver(schemaUserLogin),
|
||||
defaultValues: { username: initialName, password: '' }
|
||||
});
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ export interface IRenameLocationDTO {
|
|||
/**
|
||||
* Represents data, used for cloning {@link IRSForm}.
|
||||
*/
|
||||
export const CloneLibraryItemSchema = z.object({
|
||||
export const schemaCloneLibraryItem = z.object({
|
||||
id: z.number(),
|
||||
item_type: z.nativeEnum(LibraryItemType),
|
||||
title: z.string().nonempty(errors.requiredField),
|
||||
|
@ -39,12 +39,12 @@ export const CloneLibraryItemSchema = z.object({
|
|||
/**
|
||||
* Represents data, used for cloning {@link IRSForm}.
|
||||
*/
|
||||
export type ICloneLibraryItemDTO = z.infer<typeof CloneLibraryItemSchema>;
|
||||
export type ICloneLibraryItemDTO = z.infer<typeof schemaCloneLibraryItem>;
|
||||
|
||||
/**
|
||||
* Represents data, used for creating {@link IRSForm}.
|
||||
*/
|
||||
export const CreateLibraryItemSchema = z
|
||||
export const schemaCreateLibraryItem = z
|
||||
.object({
|
||||
item_type: z.nativeEnum(LibraryItemType),
|
||||
title: z.string().optional(),
|
||||
|
@ -70,12 +70,12 @@ export const CreateLibraryItemSchema = z
|
|||
/**
|
||||
* Represents data, used for creating {@link IRSForm}.
|
||||
*/
|
||||
export type ICreateLibraryItemDTO = z.infer<typeof CreateLibraryItemSchema>;
|
||||
export type ICreateLibraryItemDTO = z.infer<typeof schemaCreateLibraryItem>;
|
||||
|
||||
/**
|
||||
* Represents update data for editing {@link ILibraryItem}.
|
||||
*/
|
||||
export const UpdateLibraryItemSchema = z.object({
|
||||
export const schemaUpdateLibraryItem = z.object({
|
||||
id: z.number(),
|
||||
item_type: z.nativeEnum(LibraryItemType),
|
||||
title: z.string().nonempty(errors.requiredField),
|
||||
|
@ -88,12 +88,12 @@ export const UpdateLibraryItemSchema = z.object({
|
|||
/**
|
||||
* Represents update data for editing {@link ILibraryItem}.
|
||||
*/
|
||||
export type IUpdateLibraryItemDTO = z.infer<typeof UpdateLibraryItemSchema>;
|
||||
export type IUpdateLibraryItemDTO = z.infer<typeof schemaUpdateLibraryItem>;
|
||||
|
||||
/**
|
||||
* Create version metadata in persistent storage.
|
||||
*/
|
||||
export const VersionCreateSchema = z.object({
|
||||
export const schemaVersionCreate = z.object({
|
||||
version: z.string(),
|
||||
description: z.string(),
|
||||
items: z.array(z.number()).optional()
|
||||
|
@ -102,7 +102,7 @@ export const VersionCreateSchema = z.object({
|
|||
/**
|
||||
* Create version metadata in persistent storage.
|
||||
*/
|
||||
export type IVersionCreateDTO = z.infer<typeof VersionCreateSchema>;
|
||||
export type IVersionCreateDTO = z.infer<typeof schemaVersionCreate>;
|
||||
|
||||
/**
|
||||
* Represents data response when creating {@link IVersionInfo}.
|
||||
|
@ -115,7 +115,7 @@ export interface IVersionCreatedResponse {
|
|||
/**
|
||||
* Represents version data, intended to update version metadata in persistent storage.
|
||||
*/
|
||||
export const VersionUpdateSchema = z.object({
|
||||
export const schemaVersionUpdate = z.object({
|
||||
id: z.number(),
|
||||
version: z.string().nonempty(errors.requiredField),
|
||||
description: z.string()
|
||||
|
@ -124,7 +124,7 @@ export const VersionUpdateSchema = z.object({
|
|||
/**
|
||||
* Represents version data, intended to update version metadata in persistent storage.
|
||||
*/
|
||||
export type IVersionUpdateDTO = z.infer<typeof VersionUpdateSchema>;
|
||||
export type IVersionUpdateDTO = z.infer<typeof schemaVersionUpdate>;
|
||||
|
||||
export const libraryApi = {
|
||||
baseKey: 'library',
|
||||
|
|
|
@ -15,7 +15,7 @@ import { Label, TextArea, TextInput } from '@/components/Input';
|
|||
import { useAuthSuspense } from '@/features/auth/backend/useAuth';
|
||||
import { EXTEOR_TRS_FILE } from '@/utils/constants';
|
||||
|
||||
import { CreateLibraryItemSchema, ICreateLibraryItemDTO } from '../../backend/api';
|
||||
import { schemaCreateLibraryItem, ICreateLibraryItemDTO } from '../../backend/api';
|
||||
import { useCreateItem } from '../../backend/useCreateItem';
|
||||
import SelectAccessPolicy from '../../components/SelectAccessPolicy';
|
||||
import SelectItemType from '../../components/SelectItemType';
|
||||
|
@ -41,7 +41,7 @@ function FormCreateItem() {
|
|||
control,
|
||||
formState: { errors }
|
||||
} = useForm<ICreateLibraryItemDTO>({
|
||||
resolver: zodResolver(CreateLibraryItemSchema),
|
||||
resolver: zodResolver(schemaCreateLibraryItem),
|
||||
defaultValues: {
|
||||
item_type: LibraryItemType.RSFORM,
|
||||
access_policy: AccessPolicy.PUBLIC,
|
||||
|
|
|
@ -29,6 +29,20 @@ export interface IOperationSchemaDTO extends ILibraryItemData {
|
|||
substitutions: ICstSubstituteEx[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} position.
|
||||
*/
|
||||
export const schemaOperationPosition = z.object({
|
||||
id: z.number(),
|
||||
position_x: z.number(),
|
||||
position_y: z.number()
|
||||
});
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} position.
|
||||
*/
|
||||
export type IOperationPosition = z.infer<typeof schemaOperationPosition>;
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} data, used in creation process.
|
||||
*/
|
||||
|
@ -66,10 +80,17 @@ export interface ITargetOperation {
|
|||
/**
|
||||
* Represents {@link IOperation} data, used in destruction process.
|
||||
*/
|
||||
export interface IOperationDeleteDTO extends ITargetOperation {
|
||||
keep_constituents: boolean;
|
||||
delete_schema: boolean;
|
||||
}
|
||||
export const schemaOperationDelete = z.object({
|
||||
target: z.number(),
|
||||
positions: z.array(schemaOperationPosition),
|
||||
keep_constituents: z.boolean(),
|
||||
delete_schema: z.boolean()
|
||||
});
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} data, used in destruction process.
|
||||
*/
|
||||
export type IOperationDeleteDTO = z.infer<typeof schemaOperationDelete>;
|
||||
|
||||
/**
|
||||
* Represents data response when creating {@link IRSForm} for Input {@link IOperation}.
|
||||
|
@ -79,33 +100,19 @@ export interface IInputCreatedResponse {
|
|||
oss: IOperationSchemaDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} position.
|
||||
*/
|
||||
export const OperationPositionSchema = z.object({
|
||||
id: z.number(),
|
||||
position_x: z.number(),
|
||||
position_y: z.number()
|
||||
});
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} position.
|
||||
*/
|
||||
export type IOperationPosition = z.infer<typeof OperationPositionSchema>;
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} data, used in setInput process.
|
||||
*/
|
||||
export const InputUpdateSchema = z.object({
|
||||
export const schemaInputUpdate = z.object({
|
||||
target: z.number(),
|
||||
positions: z.array(OperationPositionSchema),
|
||||
positions: z.array(schemaOperationPosition),
|
||||
input: z.number().nullable()
|
||||
});
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} data, used in setInput process.
|
||||
*/
|
||||
export type IInputUpdateDTO = z.infer<typeof InputUpdateSchema>;
|
||||
export type IInputUpdateDTO = z.infer<typeof schemaInputUpdate>;
|
||||
|
||||
/**
|
||||
* Represents {@link IOperation} data, used in update process.
|
||||
|
|
|
@ -13,7 +13,7 @@ import { ILibraryItem, LibraryItemType } from '@/features/library/models/library
|
|||
import PickSchema from '@/features/rsform/components/PickSchema';
|
||||
import { useDialogsStore } from '@/stores/dialogs';
|
||||
|
||||
import { IInputUpdateDTO, InputUpdateSchema, IOperationPosition } from '../backend/api';
|
||||
import { IInputUpdateDTO, IOperationPosition, schemaInputUpdate } from '../backend/api';
|
||||
import { useInputUpdate } from '../backend/useInputUpdate';
|
||||
import { IOperation, IOperationSchema } from '../models/oss';
|
||||
import { sortItemsForOSS } from '../models/ossAPI';
|
||||
|
@ -29,7 +29,7 @@ function DlgChangeInputSchema() {
|
|||
const { inputUpdate } = useInputUpdate();
|
||||
|
||||
const { setValue, handleSubmit, control } = useForm<IInputUpdateDTO>({
|
||||
resolver: zodResolver(InputUpdateSchema),
|
||||
resolver: zodResolver(schemaInputUpdate),
|
||||
defaultValues: {
|
||||
target: target.id,
|
||||
positions: positions,
|
||||
|
|
|
@ -1,27 +1,40 @@
|
|||
'use client';
|
||||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import clsx from 'clsx';
|
||||
import { useState } from 'react';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
|
||||
import { Checkbox, TextInput } from '@/components/Input';
|
||||
import { ModalForm } from '@/components/Modal';
|
||||
import { HelpTopic } from '@/features/help/models/helpTopic';
|
||||
import { IOperation, OperationID } from '@/features/oss/models/oss';
|
||||
import { IOperation, IOperationSchema } from '@/features/oss/models/oss';
|
||||
import { useDialogsStore } from '@/stores/dialogs';
|
||||
|
||||
import { IOperationDeleteDTO, IOperationPosition, schemaOperationDelete } from '../backend/api';
|
||||
import { useOperationDelete } from '../backend/useOperationDelete';
|
||||
|
||||
export interface DlgDeleteOperationProps {
|
||||
oss: IOperationSchema;
|
||||
target: IOperation;
|
||||
onSubmit: (targetID: OperationID, keepConstituents: boolean, deleteSchema: boolean) => void;
|
||||
positions: IOperationPosition[];
|
||||
}
|
||||
|
||||
function DlgDeleteOperation() {
|
||||
const { target, onSubmit } = useDialogsStore(state => state.props as DlgDeleteOperationProps);
|
||||
const [keepConstituents, setKeepConstituents] = useState(false);
|
||||
const [deleteSchema, setDeleteSchema] = useState(false);
|
||||
const { oss, target, positions } = useDialogsStore(state => state.props as DlgDeleteOperationProps);
|
||||
const { operationDelete } = useOperationDelete();
|
||||
|
||||
function handleSubmit() {
|
||||
onSubmit(target.id, keepConstituents, deleteSchema);
|
||||
return true;
|
||||
const { handleSubmit, control } = useForm<IOperationDeleteDTO>({
|
||||
resolver: zodResolver(schemaOperationDelete),
|
||||
defaultValues: {
|
||||
target: target.id,
|
||||
positions: positions,
|
||||
keep_constituents: false,
|
||||
delete_schema: false
|
||||
}
|
||||
});
|
||||
|
||||
function onSubmit(data: IOperationDeleteDTO) {
|
||||
operationDelete({ itemID: oss.id, data: data });
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -29,19 +42,29 @@ function DlgDeleteOperation() {
|
|||
overflowVisible
|
||||
header='Удаление операции'
|
||||
submitText='Подтвердить удаление'
|
||||
canSubmit={true}
|
||||
onSubmit={handleSubmit}
|
||||
onSubmit={event => void handleSubmit(onSubmit)(event)}
|
||||
className={clsx('w-[35rem]', 'pb-3 px-6 cc-column', 'select-none')}
|
||||
helpTopic={HelpTopic.CC_PROPAGATION}
|
||||
>
|
||||
<TextInput disabled dense noBorder id='operation_alias' label='Операция' value={target.alias} />
|
||||
<Controller
|
||||
control={control}
|
||||
name='keep_constituents'
|
||||
render={({ field }) => (
|
||||
<Checkbox
|
||||
label='Сохранить наследованные конституенты'
|
||||
titleHtml='Наследованные конституенты <br/>превратятся в дописанные'
|
||||
value={keepConstituents}
|
||||
onChange={setKeepConstituents}
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
disabled={target.result === null}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={control}
|
||||
name='delete_schema'
|
||||
render={({ field }) => (
|
||||
<Checkbox
|
||||
label='Удалить схему'
|
||||
titleHtml={
|
||||
|
@ -49,10 +72,12 @@ function DlgDeleteOperation() {
|
|||
? 'Привязанную схему нельзя удалить'
|
||||
: 'Удалить схему вместе с операцией'
|
||||
}
|
||||
value={deleteSchema}
|
||||
onChange={setDeleteSchema}
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
disabled={!target.is_owned || target.result === null}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</ModalForm>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import { useForm, useWatch } from 'react-hook-form';
|
|||
import { SubmitButton } from '@/components/Control';
|
||||
import { IconSave } from '@/components/Icons';
|
||||
import { TextArea, TextInput } from '@/components/Input';
|
||||
import { IUpdateLibraryItemDTO, UpdateLibraryItemSchema } from '@/features/library/backend/api';
|
||||
import { IUpdateLibraryItemDTO, schemaUpdateLibraryItem } from '@/features/library/backend/api';
|
||||
import { useUpdateItem } from '@/features/library/backend/useUpdateItem';
|
||||
import { LibraryItemType } from '@/features/library/models/library';
|
||||
import ToolbarItemAccess from '@/features/rsform/pages/RSFormPage/EditorRSFormCard/ToolbarItemAccess';
|
||||
|
@ -33,7 +33,7 @@ function FormOSS() {
|
|||
reset,
|
||||
formState: { isDirty, errors }
|
||||
} = useForm<IUpdateLibraryItemDTO>({
|
||||
resolver: zodResolver(UpdateLibraryItemSchema),
|
||||
resolver: zodResolver(schemaUpdateLibraryItem),
|
||||
defaultValues: {
|
||||
id: controller.schema.id,
|
||||
item_type: LibraryItemType.RSFORM,
|
||||
|
|
|
@ -17,7 +17,6 @@ import { prompts } from '@/utils/labels';
|
|||
|
||||
import { IOperationPosition } from '../../backend/api';
|
||||
import { useOperationCreate } from '../../backend/useOperationCreate';
|
||||
import { useOperationDelete } from '../../backend/useOperationDelete';
|
||||
import { useOperationUpdate } from '../../backend/useOperationUpdate';
|
||||
import { useOssSuspense } from '../../backend/useOSS';
|
||||
import { useRelocateConstituents } from '../../backend/useRelocateConstituents';
|
||||
|
@ -103,7 +102,6 @@ export const OssEditState = ({ itemID, children }: React.PropsWithChildren<OssEd
|
|||
const { deleteItem } = useDeleteItem();
|
||||
const { updatePositions } = useUpdatePositions();
|
||||
const { operationCreate } = useOperationCreate();
|
||||
const { operationDelete } = useOperationDelete();
|
||||
const { operationUpdate } = useOperationUpdate();
|
||||
const { relocateConstituents } = useRelocateConstituents();
|
||||
|
||||
|
@ -199,18 +197,9 @@ export const OssEditState = ({ itemID, children }: React.PropsWithChildren<OssEd
|
|||
return;
|
||||
}
|
||||
showDeleteOperation({
|
||||
target: operation,
|
||||
onSubmit: (targetID, keepConstituents, deleteSchema) => {
|
||||
operationDelete({
|
||||
itemID: schema.id,
|
||||
data: {
|
||||
target: targetID,
|
||||
oss: schema,
|
||||
positions: positions,
|
||||
keep_constituents: keepConstituents,
|
||||
delete_schema: deleteSchema
|
||||
}
|
||||
});
|
||||
}
|
||||
target: operation
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ export interface ICstCreatedResponse {
|
|||
/**
|
||||
* Represents data, used in updating persistent attributes in {@link IConstituenta}.
|
||||
*/
|
||||
export const CstUpdateSchema = z.object({
|
||||
export const schemaCstUpdate = z.object({
|
||||
target: z.number(),
|
||||
item_data: z.object({
|
||||
convention: z.string().optional(),
|
||||
|
@ -95,12 +95,12 @@ export const CstUpdateSchema = z.object({
|
|||
/**
|
||||
* Represents data, used in updating persistent attributes in {@link IConstituenta}.
|
||||
*/
|
||||
export type ICstUpdateDTO = z.infer<typeof CstUpdateSchema>;
|
||||
export type ICstUpdateDTO = z.infer<typeof schemaCstUpdate>;
|
||||
|
||||
/**
|
||||
* Represents data, used in renaming {@link IConstituenta}.
|
||||
*/
|
||||
export const CstRenameSchema = z.object({
|
||||
export const schemaCstRename = z.object({
|
||||
target: z.number(),
|
||||
alias: z.string(),
|
||||
cst_type: z.nativeEnum(CstType)
|
||||
|
@ -109,7 +109,7 @@ export const CstRenameSchema = z.object({
|
|||
/**
|
||||
* Represents data, used in renaming {@link IConstituenta}.
|
||||
*/
|
||||
export type ICstRenameDTO = z.infer<typeof CstRenameSchema>;
|
||||
export type ICstRenameDTO = z.infer<typeof schemaCstRename>;
|
||||
|
||||
/**
|
||||
* Represents data, used in ordering a list of {@link IConstituenta}.
|
||||
|
|
|
@ -10,7 +10,7 @@ import { VisibilityIcon } from '@/components/DomainIcons';
|
|||
import { Checkbox, Label, TextArea, TextInput } from '@/components/Input';
|
||||
import { ModalForm } from '@/components/Modal';
|
||||
import { useAuthSuspense } from '@/features/auth/backend/useAuth';
|
||||
import { CloneLibraryItemSchema, ICloneLibraryItemDTO } from '@/features/library/backend/api';
|
||||
import { schemaCloneLibraryItem, ICloneLibraryItemDTO } from '@/features/library/backend/api';
|
||||
import { useCloneItem } from '@/features/library/backend/useCloneItem';
|
||||
import SelectAccessPolicy from '@/features/library/components/SelectAccessPolicy';
|
||||
import SelectLocationContext from '@/features/library/components/SelectLocationContext';
|
||||
|
@ -42,7 +42,7 @@ function DlgCloneLibraryItem() {
|
|||
control,
|
||||
formState: { errors, isValid }
|
||||
} = useForm<ICloneLibraryItemDTO>({
|
||||
resolver: zodResolver(CloneLibraryItemSchema),
|
||||
resolver: zodResolver(schemaCloneLibraryItem),
|
||||
defaultValues: {
|
||||
id: base.id,
|
||||
item_type: base.item_type,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Controller, useForm, useWatch } from 'react-hook-form';
|
|||
|
||||
import { Checkbox, TextArea, TextInput } from '@/components/Input';
|
||||
import { ModalForm } from '@/components/Modal';
|
||||
import { IVersionCreateDTO, VersionCreateSchema } from '@/features/library/backend/api';
|
||||
import { IVersionCreateDTO, schemaVersionCreate } from '@/features/library/backend/api';
|
||||
import { useVersionCreate } from '@/features/library/backend/useVersionCreate';
|
||||
import { IVersionInfo, LibraryItemID, VersionID } from '@/features/library/models/library';
|
||||
import { nextVersion } from '@/features/library/models/libraryAPI';
|
||||
|
@ -34,7 +34,7 @@ function DlgCreateVersion() {
|
|||
const { versionCreate } = useVersionCreate();
|
||||
|
||||
const { register, handleSubmit, control } = useForm<IVersionCreateDTO>({
|
||||
resolver: zodResolver(VersionCreateSchema),
|
||||
resolver: zodResolver(schemaVersionCreate),
|
||||
defaultValues: {
|
||||
version: versions.length > 0 ? nextVersion(versions[0].version) : '1.0.0',
|
||||
description: '',
|
||||
|
|
|
@ -37,7 +37,6 @@ function DlgDeleteCst() {
|
|||
|
||||
return (
|
||||
<ModalForm
|
||||
canSubmit
|
||||
header='Удаление конституент'
|
||||
submitText={expandOut ? 'Удалить с зависимыми' : 'Удалить'}
|
||||
onSubmit={handleSubmit}
|
||||
|
|
|
@ -39,7 +39,6 @@ function DlgEditEditors() {
|
|||
|
||||
return (
|
||||
<ModalForm
|
||||
canSubmit
|
||||
header='Список редакторов'
|
||||
submitText='Сохранить список'
|
||||
className='flex flex-col w-[35rem] px-6 gap-3 pb-6'
|
||||
|
|
|
@ -9,7 +9,7 @@ import { MiniButton } from '@/components/Control';
|
|||
import { IconReset, IconSave } from '@/components/Icons';
|
||||
import { TextArea, TextInput } from '@/components/Input';
|
||||
import { ModalView } from '@/components/Modal';
|
||||
import { IVersionUpdateDTO, VersionUpdateSchema } from '@/features/library/backend/api';
|
||||
import { IVersionUpdateDTO, schemaVersionUpdate } from '@/features/library/backend/api';
|
||||
import { useMutatingLibrary } from '@/features/library/backend/useMutatingLibrary';
|
||||
import { useVersionDelete } from '@/features/library/backend/useVersionDelete';
|
||||
import { useVersionUpdate } from '@/features/library/backend/useVersionUpdate';
|
||||
|
@ -40,7 +40,7 @@ function DlgEditVersions() {
|
|||
reset,
|
||||
formState: { isDirty, errors: formErrors }
|
||||
} = useForm<IVersionUpdateDTO>({
|
||||
resolver: zodResolver(VersionUpdateSchema),
|
||||
resolver: zodResolver(schemaVersionUpdate),
|
||||
defaultValues: {
|
||||
id: schema.versions[0].id,
|
||||
version: schema.versions[0].version,
|
||||
|
|
|
@ -121,7 +121,6 @@ function DlgEditWordForms() {
|
|||
|
||||
return (
|
||||
<ModalForm
|
||||
canSubmit
|
||||
header='Редактирование словоформ'
|
||||
submitText='Сохранить'
|
||||
onSubmit={handleSubmit}
|
||||
|
|
|
@ -23,7 +23,6 @@ function DlgGraphParams() {
|
|||
|
||||
return (
|
||||
<ModalForm
|
||||
canSubmit
|
||||
header='Настройки графа термов'
|
||||
onSubmit={event => void handleSubmit(onSubmit)(event)}
|
||||
submitText='Применить'
|
||||
|
|
|
@ -9,7 +9,7 @@ import { ModalForm } from '@/components/Modal';
|
|||
import { HelpTopic } from '@/features/help/models/helpTopic';
|
||||
import { useDialogsStore } from '@/stores/dialogs';
|
||||
|
||||
import { CstRenameSchema, ICstRenameDTO } from '../backend/api';
|
||||
import { ICstRenameDTO, schemaCstRename } from '../backend/api';
|
||||
import { useCstRename } from '../backend/useCstRename';
|
||||
import { SelectCstType } from '../components/SelectCstType';
|
||||
import { CstType, IConstituenta, IRSForm } from '../models/rsform';
|
||||
|
@ -25,7 +25,7 @@ function DlgRenameCst() {
|
|||
const { cstRename } = useCstRename();
|
||||
|
||||
const { register, setValue, handleSubmit, control } = useForm<ICstRenameDTO>({
|
||||
resolver: zodResolver(CstRenameSchema),
|
||||
resolver: zodResolver(schemaCstRename),
|
||||
defaultValues: {
|
||||
target: target.id,
|
||||
alias: target.alias,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { useDialogsStore } from '@/stores/dialogs';
|
|||
import { useModificationStore } from '@/stores/modification';
|
||||
import { errors, labelCstTypification, labelTypification } from '@/utils/labels';
|
||||
|
||||
import { CstUpdateSchema, ICstUpdateDTO } from '../../../backend/api';
|
||||
import { ICstUpdateDTO, schemaCstUpdate } from '../../../backend/api';
|
||||
import { useCstUpdate } from '../../../backend/useCstUpdate';
|
||||
import { useMutatingRSForm } from '../../../backend/useMutatingRSForm';
|
||||
import RefsInput from '../../../components/RefsInput';
|
||||
|
@ -47,7 +47,7 @@ function FormConstituenta({ disabled, id, toggleReset, schema, activeCst, onOpen
|
|||
control,
|
||||
reset,
|
||||
formState: { isDirty }
|
||||
} = useForm<ICstUpdateDTO>({ resolver: zodResolver(CstUpdateSchema) });
|
||||
} = useForm<ICstUpdateDTO>({ resolver: zodResolver(schemaCstUpdate) });
|
||||
|
||||
const [localParse, setLocalParse] = useState<IExpressionParse | undefined>(undefined);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { urls, useConceptNavigation } from '@/app';
|
|||
import { SubmitButton } from '@/components/Control';
|
||||
import { IconSave } from '@/components/Icons';
|
||||
import { Label, TextArea, TextInput } from '@/components/Input';
|
||||
import { IUpdateLibraryItemDTO, UpdateLibraryItemSchema } from '@/features/library/backend/api';
|
||||
import { IUpdateLibraryItemDTO, schemaUpdateLibraryItem } from '@/features/library/backend/api';
|
||||
import { useUpdateItem } from '@/features/library/backend/useUpdateItem';
|
||||
import { LibraryItemType, VersionID } from '@/features/library/models/library';
|
||||
import { useModificationStore } from '@/stores/modification';
|
||||
|
@ -37,7 +37,7 @@ function FormRSForm() {
|
|||
reset,
|
||||
formState: { isDirty, errors }
|
||||
} = useForm<IUpdateLibraryItemDTO>({
|
||||
resolver: zodResolver(UpdateLibraryItemSchema),
|
||||
resolver: zodResolver(schemaUpdateLibraryItem),
|
||||
defaultValues: {
|
||||
id: controller.schema.id,
|
||||
item_type: LibraryItemType.RSFORM,
|
||||
|
|
|
@ -11,7 +11,7 @@ import { IUserInfo, IUserProfile } from '../models/user';
|
|||
/**
|
||||
* Represents signup data, used to create new users.
|
||||
*/
|
||||
export const UserSignupSchema = z
|
||||
export const schemaUserSignup = z
|
||||
.object({
|
||||
username: z.string().nonempty(errors.requiredField).regex(RegExp(patterns.login), errors.loginFormat),
|
||||
email: z.string().email(errors.emailField),
|
||||
|
@ -26,12 +26,12 @@ export const UserSignupSchema = z
|
|||
/**
|
||||
* Represents signup data, used to create new users.
|
||||
*/
|
||||
export type IUserSignupDTO = z.infer<typeof UserSignupSchema>;
|
||||
export type IUserSignupDTO = z.infer<typeof schemaUserSignup>;
|
||||
|
||||
/**
|
||||
* Represents user data, intended to update user profile in persistent storage.
|
||||
*/
|
||||
export const UpdateProfileSchema = z.object({
|
||||
export const schemaUpdateProfile = z.object({
|
||||
email: z.string().email(errors.emailField),
|
||||
first_name: z.string(),
|
||||
last_name: z.string()
|
||||
|
@ -40,7 +40,7 @@ export const UpdateProfileSchema = z.object({
|
|||
/**
|
||||
* Represents user data, intended to update user profile in persistent storage.
|
||||
*/
|
||||
export type IUpdateProfileDTO = z.infer<typeof UpdateProfileSchema>;
|
||||
export type IUpdateProfileDTO = z.infer<typeof schemaUpdateProfile>;
|
||||
|
||||
export const usersApi = {
|
||||
baseKey: 'users',
|
||||
|
|
|
@ -16,7 +16,7 @@ import { PrettyJson } from '@/components/View';
|
|||
import { HelpTopic } from '@/features/help/models/helpTopic';
|
||||
import { globals, patterns } from '@/utils/constants';
|
||||
|
||||
import { IUserSignupDTO, UserSignupSchema } from '../../backend/api';
|
||||
import { IUserSignupDTO, schemaUserSignup } from '../../backend/api';
|
||||
import { useSignup } from '../../backend/useSignup';
|
||||
|
||||
function FormSignup() {
|
||||
|
@ -31,7 +31,7 @@ function FormSignup() {
|
|||
clearErrors,
|
||||
formState: { errors, isDirty }
|
||||
} = useForm<IUserSignupDTO>({
|
||||
resolver: zodResolver(UserSignupSchema)
|
||||
resolver: zodResolver(schemaUserSignup)
|
||||
});
|
||||
|
||||
useBlockNavigation(isDirty);
|
||||
|
|
|
@ -10,7 +10,7 @@ import { FlexColumn } from '@/components/Container';
|
|||
import { SubmitButton } from '@/components/Control';
|
||||
import { ErrorData } from '@/components/InfoError';
|
||||
import { TextInput } from '@/components/Input';
|
||||
import { ChangePasswordSchema, IChangePasswordDTO } from '@/features/auth/backend/api';
|
||||
import { IChangePasswordDTO, schemaChangePassword } from '@/features/auth/backend/api';
|
||||
import { useChangePassword } from '@/features/auth/backend/useChangePassword';
|
||||
|
||||
function EditorPassword() {
|
||||
|
@ -22,7 +22,7 @@ function EditorPassword() {
|
|||
clearErrors,
|
||||
formState: { errors }
|
||||
} = useForm<IChangePasswordDTO>({
|
||||
resolver: zodResolver(ChangePasswordSchema)
|
||||
resolver: zodResolver(schemaChangePassword)
|
||||
});
|
||||
|
||||
function resetErrors() {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { SubmitButton } from '@/components/Control';
|
|||
import { ErrorData } from '@/components/InfoError';
|
||||
import { TextInput } from '@/components/Input';
|
||||
|
||||
import { IUpdateProfileDTO, UpdateProfileSchema } from '../../backend/api';
|
||||
import { IUpdateProfileDTO, schemaUpdateProfile } from '../../backend/api';
|
||||
import { useProfileSuspense } from '../../backend/useProfile';
|
||||
import { useUpdateProfile } from '../../backend/useUpdateProfile';
|
||||
|
||||
|
@ -24,7 +24,7 @@ function EditorProfile() {
|
|||
reset: resetForm,
|
||||
formState: { errors, isDirty }
|
||||
} = useForm<IUpdateProfileDTO>({
|
||||
resolver: zodResolver(UpdateProfileSchema),
|
||||
resolver: zodResolver(schemaUpdateProfile),
|
||||
defaultValues: {
|
||||
first_name: profile.first_name,
|
||||
last_name: profile.last_name,
|
||||
|
|
Loading…
Reference in New Issue
Block a user