"use client";

import DataTableWithAuth from "@/core/components/DataTableWithAuth";
import { GET_COUNTRY_KEYPRESS_REPORT } from "@/core/utils/routes";
import { Box } from "@mui/material";
import { useMemo } from "react";

const DataTable = () => {
    const columns = useMemo(
        () => [
            {
                accessorKey: "province_name",
                header: "استان",
                id: "province_id",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                columnFilterModeOptions: ["equals", "contains"],
                grow: false,
                size: 100,
            },
            {
                accessorKey: "total",
                header: "مجموع تماس ها",
                id: "total",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                grow: false,
                size: 100,
            },
            {
                header: "تماس با اعداد",
                id: "call_with_nums",
                enableColumnFilter: false,
                enableSorting: false,
                grow: false,
                size: 50,
                columns: [
                    {
                        accessorKey: "key1",
                        header: "کلید 1",
                        id: "key1",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key2",
                        header: "کلید 2",
                        id: "key2",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key3",
                        header: "کلید 3",
                        id: "key3",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key4",
                        header: "کلید 4",
                        id: "key4",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key5",
                        header: "کلید 5",
                        id: "key5",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key6",
                        header: "کلید 6",
                        id: "key6",
                        enableColumnFilter: true,
                        datatype: "text",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                ],
            },
            {
                accessorKey: "key9",
                header: "منوی مدیریت",
                id: "key9",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                grow: false,
                size: 100,
            },
            {
                accessorKey: "key4_1",
                header: "تماس با استان",
                id: "key4_1",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                grow: false,
                size: 100,
            },
            {
                accessorKey: "key4_2",
                header: "تماس با تهران",
                id: "key4_2",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                grow: false,
                size: 100,
            },
            {
                accessorKey: "key5_1",
                header: "تماس راننده با استان",
                id: "key5_1",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                grow: false,
                size: 100,
            },
            {
                accessorKey: "key5_2",
                header: "تماس راننده با تهران",
                id: "key5_2",
                enableColumnFilter: true,
                datatype: "text",
                filterMode: "equals",
                sortDescFirst: false,
                grow: false,
                size: 100,
            },
            {
                header: "محدودیت",
                id: "limits",
                enableColumnFilter: false,
                enableSorting: false,
                grow: false,
                size: 50,
                columns: [
                    {
                        accessorKey: "key2_1",
                        header: "انسداد فصلی",
                        id: "key2_1",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key2_2",
                        header: "تردد وسایل نقلیه سنگین و موتورسیکلت",
                        id: "key2_2",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                    {
                        accessorKey: "key2_3",
                        header: "سایر",
                        id: "key2_3",
                        enableColumnFilter: true,
                        datatype: "integer",
                        filterMode: "equals",
                        sortDescFirst: false,
                        columnFilterModeOptions: ["equals", "contains"],
                        grow: false,
                        size: 100,
                    },
                ],
            },
        ],
        []
    );

    return (
        <>
            <Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
                <DataTableWithAuth
                    need_filter={true}
                    columns={columns}
                    table_url={GET_COUNTRY_KEYPRESS_REPORT}
                    page_name={"countryKeypressReportPage"}
                    table_name={"countryKeypressReportList"}
                    positionActionsColumn={"last"}
                />
            </Box>
        </>
    );
};
export default DataTable;
