feat: patronymic and passport data for user

This commit is contained in:
2024-11-22 15:14:18 +04:00
parent dc882ccd9c
commit 20616d9e81
5 changed files with 82 additions and 55 deletions

View File

@@ -8,7 +8,9 @@ export type UserCreate = {
phoneNumber?: (string | null); phoneNumber?: (string | null);
firstName: string; firstName: string;
secondName: string; secondName: string;
patronymic: string;
comment: string; comment: string;
passportData?: (string | null);
isAdmin: boolean; isAdmin: boolean;
isBlocked: boolean; isBlocked: boolean;
isDeleted: boolean; isDeleted: boolean;

View File

@@ -10,7 +10,9 @@ export type UserSchema = {
phoneNumber?: (string | null); phoneNumber?: (string | null);
firstName: string; firstName: string;
secondName: string; secondName: string;
patronymic: string;
comment: string; comment: string;
passportData?: (string | null);
isAdmin: boolean; isAdmin: boolean;
isBlocked: boolean; isBlocked: boolean;
isDeleted: boolean; isDeleted: boolean;

View File

@@ -8,7 +8,9 @@ export type UserUpdate = {
phoneNumber?: (string | null); phoneNumber?: (string | null);
firstName: string; firstName: string;
secondName: string; secondName: string;
patronymic: string;
comment: string; comment: string;
passportData?: (string | null);
isAdmin: boolean; isAdmin: boolean;
isBlocked: boolean; isBlocked: boolean;
isDeleted: boolean; isDeleted: boolean;

View File

@@ -9,12 +9,16 @@ export const useUsersTableColumns = () => {
{ {
header: "ФИО", header: "ФИО",
Cell: ({ row }) => Cell: ({ row }) =>
`${row.original.firstName} ${row.original.secondName}`, `${row.original.secondName} ${row.original.firstName} ${row.original.patronymic}`,
}, },
{ {
accessorKey: "phoneNumber", accessorKey: "phoneNumber",
header: "Номер телефона", header: "Номер телефона",
}, },
{
accessorKey: "passportData",
header: "Серия и номер паспорта"
},
{ {
accessorKey: "role.name", accessorKey: "role.name",
header: "Роль", header: "Роль",
@@ -36,12 +40,14 @@ export const useUsersTableColumns = () => {
header: "Администратор", header: "Администратор",
Cell: ({ row }) => Cell: ({ row }) =>
row.original.isAdmin ? <IconCheck /> : <IconX />, row.original.isAdmin ? <IconCheck /> : <IconX />,
size: 10,
}, },
{ {
accessorKey: "isBlocked", accessorKey: "isBlocked",
header: "Заблокирован", header: "Заблокирован",
Cell: ({ row }) => Cell: ({ row }) =>
row.original.isBlocked ? <IconCheck /> : <IconX />, row.original.isBlocked ? <IconCheck /> : <IconX />,
size: 10,
}, },
], ],
[] []

View File

@@ -1,17 +1,8 @@
import { ContextModalProps } from "@mantine/modals"; import { ContextModalProps } from "@mantine/modals";
import BaseFormModal, { import BaseFormModal, { CreateEditFormProps } from "../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
CreateEditFormProps,
} from "../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
import { UserSchema } from "../../../../client"; import { UserSchema } from "../../../../client";
import { useForm } from "@mantine/form"; import { useForm } from "@mantine/form";
import { import { Checkbox, Fieldset, Input, Stack, Textarea, TextInput } from "@mantine/core";
Checkbox,
Fieldset,
Input,
Stack,
Textarea,
TextInput,
} from "@mantine/core";
import RoleSelect from "../../components/RoleSelect/RoleSelect.tsx"; import RoleSelect from "../../components/RoleSelect/RoleSelect.tsx";
import PositionSelect from "../../components/PositionSelect/PositionSelect.tsx"; import PositionSelect from "../../components/PositionSelect/PositionSelect.tsx";
import { UserRoleEnum } from "../../../../shared/enums/UserRole.ts"; import { UserRoleEnum } from "../../../../shared/enums/UserRole.ts";
@@ -25,7 +16,7 @@ const UserFormModal = ({
context, context,
id, id,
innerProps, innerProps,
}: ContextModalProps<Props>) => { }: ContextModalProps<Props>) => {
const isEditing = "element" in innerProps; const isEditing = "element" in innerProps;
const initialValues = isEditing const initialValues = isEditing
? innerProps.element ? innerProps.element
@@ -64,20 +55,6 @@ const UserFormModal = ({
<> <>
<Fieldset legend={"Общая информация"}> <Fieldset legend={"Общая информация"}>
<Stack> <Stack>
<TextInput
label={"Имя"}
placeholder={"Введите имя пользователя"}
{...form.getInputProps("firstName")}
onChange={event =>
form
.getInputProps("firstName")
.onChange(
capitalize(
event.target.value
).trim()
)
}
/>
<TextInput <TextInput
{...form.getInputProps("secondName")} {...form.getInputProps("secondName")}
label={"Фамилия"} label={"Фамилия"}
@@ -87,8 +64,36 @@ const UserFormModal = ({
.getInputProps("secondName") .getInputProps("secondName")
.onChange( .onChange(
capitalize( capitalize(
event.target.value event.target.value,
).trim() ).trim(),
)
}
/>
<TextInput
label={"Имя"}
placeholder={"Введите имя пользователя"}
{...form.getInputProps("firstName")}
onChange={event =>
form
.getInputProps("firstName")
.onChange(
capitalize(
event.target.value,
).trim(),
)
}
/>
<TextInput
{...form.getInputProps("patronymic")}
label={"Отчество"}
placeholder={"Введите отчество пользователя"}
onChange={event =>
form
.getInputProps("patronymic")
.onChange(
capitalize(
event.target.value,
).trim(),
) )
} }
/> />
@@ -102,6 +107,16 @@ const UserFormModal = ({
{...form.getInputProps("phoneNumber")} {...form.getInputProps("phoneNumber")}
/> />
</Input.Wrapper> </Input.Wrapper>
<Input.Wrapper
label={"Серия и номер паспорта"}
error={form.getInputProps("passportData").error}>
<Input
component={IMaskInput}
mask="00 00 000000"
placeholder={"Введите серию и номер паспорта"}
{...form.getInputProps("passportData")}
/>
</Input.Wrapper>
</Stack> </Stack>
</Fieldset> </Fieldset>
<Fieldset legend={"Роль и должность"}> <Fieldset legend={"Роль и должность"}>