import {ServiceSchema} from "../../../../client";
import {FC, RefObject} from "react";
import {useServicesTableColumns} from "./columns.tsx";
import {BaseTable, BaseTableRef} from "../../../../components/BaseTable/BaseTable.tsx";
import {MRT_TableOptions} from "mantine-react-table";

type Props = {
    services: ServiceSchema[];
    tableRef?: RefObject<BaseTableRef<ServiceSchema>>
}
const ServicesTable: FC<Props> = ({services, tableRef}) => {
    const columns = useServicesTableColumns();
    return (
        <BaseTable
            ref={tableRef}
            data={services}
            columns={columns}
            restProps={{
                enableGrouping: true,
                initialState: {grouping: ["category"]},
                enableColumnActions: false,
                mantineCreateRowModalProps: {
                    transitionProps: {transition: 'rotate-left', duration: 300}
                },
            } as MRT_TableOptions<ServiceSchema>}
        />
    )
}

export default ServicesTable;