feat: patronymic and passport data for user
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[]
|
[]
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -22,20 +13,20 @@ import PayRateSelect from "../../../../components/Selects/PayRateSelect/PayRateS
|
|||||||
|
|
||||||
type Props = CreateEditFormProps<UserSchema>;
|
type Props = CreateEditFormProps<UserSchema>;
|
||||||
const UserFormModal = ({
|
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
|
||||||
: {
|
: {
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
isBlocked: false,
|
isBlocked: false,
|
||||||
isDeleted: false,
|
isDeleted: false,
|
||||||
comment: "",
|
comment: "",
|
||||||
roleKey: UserRoleEnum.USER,
|
roleKey: UserRoleEnum.USER,
|
||||||
};
|
};
|
||||||
|
|
||||||
const form = useForm<Partial<UserSchema>>({
|
const form = useForm<Partial<UserSchema>>({
|
||||||
initialValues: initialValues,
|
initialValues: initialValues,
|
||||||
@@ -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={"Роль и должность"}>
|
||||||
@@ -113,23 +128,23 @@ const UserFormModal = ({
|
|||||||
/>
|
/>
|
||||||
{form.values.role?.key ===
|
{form.values.role?.key ===
|
||||||
UserRoleEnum.EMPLOYEE && (
|
UserRoleEnum.EMPLOYEE && (
|
||||||
<>
|
<>
|
||||||
<PositionSelect
|
<PositionSelect
|
||||||
label={"Должность сотрудника"}
|
label={"Должность сотрудника"}
|
||||||
placeholder={
|
placeholder={
|
||||||
"Выберите должность сотрудника"
|
"Выберите должность сотрудника"
|
||||||
}
|
}
|
||||||
{...form.getInputProps("position")}
|
{...form.getInputProps("position")}
|
||||||
/>
|
/>
|
||||||
<PayRateSelect
|
<PayRateSelect
|
||||||
label={"Тариф"}
|
label={"Тариф"}
|
||||||
placeholder={
|
placeholder={
|
||||||
"Выберите тариф сотрудника"
|
"Выберите тариф сотрудника"
|
||||||
}
|
}
|
||||||
{...form.getInputProps("payRate")}
|
{...form.getInputProps("payRate")}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Fieldset>
|
</Fieldset>
|
||||||
<Fieldset legend={"Дополнительные параметры"}>
|
<Fieldset legend={"Дополнительные параметры"}>
|
||||||
|
|||||||
Reference in New Issue
Block a user