Add routes placeholders, some of them implemented
- add Login, LoginCompany, Profile, RegisterCompany pages - add Zustand for handling current user state and token - add components - add company, user models
This commit is contained in:
40
src/renderer/src/models/user/dtos.ts
Normal file
40
src/renderer/src/models/user/dtos.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const UserEmployeeDto = z.object({
|
||||
id: z.number(),
|
||||
login: z.string(),
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
middleName: z.string(),
|
||||
creationDate: z.date(),
|
||||
phone: z.string(),
|
||||
companyId: z.number(),
|
||||
});
|
||||
|
||||
export const UserLoginDto = z.object({
|
||||
login: z.string()
|
||||
.regex(/^[a-zA-Zа-яА-ЯёЁ0-9_]+$/, { message: "Поле должно содержать буквы, цифры и нижнее подчеркивание" })
|
||||
.max(24, { message: "Логин слишком длинный" })
|
||||
.nonempty(),
|
||||
password: z.string()
|
||||
.nonempty(),
|
||||
});
|
||||
|
||||
export const EmployeeUpdateDto = z.object({
|
||||
firstName: z.string()
|
||||
.regex(/^[а-яА-ЯёЁ-]+$/, { message: "Поле должно содержать только кириллические буквы, а также дефис" })
|
||||
.max(24, { message: "Имя слишком длинное" })
|
||||
.optional(),
|
||||
lastName: z.string()
|
||||
.regex(/^[а-яА-ЯёЁ-]+$/, { message: "Поле должно содержать только кириллические буквы, а также дефис" })
|
||||
.max(24, { message: "Фамилия слишком длинная" })
|
||||
.optional(),
|
||||
middleName: z.string()
|
||||
.regex(/^[а-яА-ЯёЁ-]+$/, { message: "Поле должно содержать только кириллические буквы, а также дефис" })
|
||||
.max(24, { message: "Отчество слишком длинное" })
|
||||
.optional(),
|
||||
phone: z.string()
|
||||
.regex(/^\+\d{1,15}$/, { message: "Недопустимый формат номера телефона" })
|
||||
.max(15, { message: "Номер слишком длинный" })
|
||||
.optional(),
|
||||
});
|
||||
6
src/renderer/src/models/user/types.ts
Normal file
6
src/renderer/src/models/user/types.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import z from "zod/v4";
|
||||
import { UserEmployeeDto, UserLoginDto, EmployeeUpdateDto } from "./dtos";
|
||||
|
||||
export type UserEmployeeDto = z.infer<typeof UserEmployeeDto>;
|
||||
export type UserLoginDto = z.infer<typeof UserLoginDto>;
|
||||
export type EmployeeUpdateDto = z.infer<typeof EmployeeUpdateDto>;
|
||||
Reference in New Issue
Block a user