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);
firstName: string;
secondName: string;
patronymic: string;
comment: string;
passportData?: (string | null);
isAdmin: boolean;
isBlocked: boolean;
isDeleted: boolean;

View File

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

View File

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

View File

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

View File

@@ -1,17 +1,8 @@
import { ContextModalProps } from "@mantine/modals";
import BaseFormModal, {
CreateEditFormProps,
} from "../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
import BaseFormModal, { CreateEditFormProps } from "../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
import { UserSchema } from "../../../../client";
import { useForm } from "@mantine/form";
import {
Checkbox,
Fieldset,
Input,
Stack,
Textarea,
TextInput,
} from "@mantine/core";
import { Checkbox, Fieldset, Input, Stack, Textarea, TextInput } from "@mantine/core";
import RoleSelect from "../../components/RoleSelect/RoleSelect.tsx";
import PositionSelect from "../../components/PositionSelect/PositionSelect.tsx";
import { UserRoleEnum } from "../../../../shared/enums/UserRole.ts";
@@ -22,20 +13,20 @@ import PayRateSelect from "../../../../components/Selects/PayRateSelect/PayRateS
type Props = CreateEditFormProps<UserSchema>;
const UserFormModal = ({
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
const isEditing = "element" in innerProps;
const initialValues = isEditing
? innerProps.element
: {
isAdmin: false,
isBlocked: false,
isDeleted: false,
comment: "",
roleKey: UserRoleEnum.USER,
};
isAdmin: false,
isBlocked: false,
isDeleted: false,
comment: "",
roleKey: UserRoleEnum.USER,
};
const form = useForm<Partial<UserSchema>>({
initialValues: initialValues,
@@ -64,20 +55,6 @@ const UserFormModal = ({
<>
<Fieldset legend={"Общая информация"}>
<Stack>
<TextInput
label={"Имя"}
placeholder={"Введите имя пользователя"}
{...form.getInputProps("firstName")}
onChange={event =>
form
.getInputProps("firstName")
.onChange(
capitalize(
event.target.value
).trim()
)
}
/>
<TextInput
{...form.getInputProps("secondName")}
label={"Фамилия"}
@@ -87,8 +64,36 @@ const UserFormModal = ({
.getInputProps("secondName")
.onChange(
capitalize(
event.target.value
).trim()
event.target.value,
).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")}
/>
</Input.Wrapper>
<Input.Wrapper
label={"Серия и номер паспорта"}
error={form.getInputProps("passportData").error}>
<Input
component={IMaskInput}
mask="00 00 000000"
placeholder={"Введите серию и номер паспорта"}
{...form.getInputProps("passportData")}
/>
</Input.Wrapper>
</Stack>
</Fieldset>
<Fieldset legend={"Роль и должность"}>
@@ -113,23 +128,23 @@ const UserFormModal = ({
/>
{form.values.role?.key ===
UserRoleEnum.EMPLOYEE && (
<>
<PositionSelect
label={"Должность сотрудника"}
placeholder={
"Выберите должность сотрудника"
}
{...form.getInputProps("position")}
/>
<PayRateSelect
label={"Тариф"}
placeholder={
"Выберите тариф сотрудника"
}
{...form.getInputProps("payRate")}
/>
</>
)}
<>
<PositionSelect
label={"Должность сотрудника"}
placeholder={
"Выберите должность сотрудника"
}
{...form.getInputProps("position")}
/>
<PayRateSelect
label={"Тариф"}
placeholder={
"Выберите тариф сотрудника"
}
{...form.getInputProps("payRate")}
/>
</>
)}
</Stack>
</Fieldset>
<Fieldset legend={"Дополнительные параметры"}>