import {useMemo} from "react";
import {MRT_ColumnDef} from "mantine-react-table";
import {UserSchema} from "../../../../client";
import {IconCheck, IconX} from "@tabler/icons-react";

export const useUsersTableColumns = () => {
    return useMemo<MRT_ColumnDef<UserSchema>[]>(() => [

        {
            header: "ФИО",
            Cell: ({row}) => `${row.original.firstName} ${row.original.secondName}`
        },
        {
            accessorKey: "phoneNumber",
            header: "Номер телефона"
        },
        {
            accessorKey: "role.name",
            header: "Роль"
        },
        {
            accessorKey: "position.name",
            header: "Должность"
        },
        {
            accessorKey: "payRate.name",
            header: "Тариф"
        },
        {
            accessorKey: "comment",
            header: "Дополнительная информация"
        },
        {
            accessorKey: "isAdmin",
            header: "Администратор",
            Cell: ({row}) => row.original.isAdmin ? <IconCheck/> : <IconX/>
        },
        {
            accessorKey: "isBlocked",
            header: "Заблокирован",
            Cell: ({row}) => row.original.isBlocked ? <IconCheck/> : <IconX/>
        },
    ], []);
}

