72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { TableColumnsType } from "antd";
|
|
import { Student_Package } from "../../../types/Item";
|
|
import { ModalEnum } from "../../../enums/Model";
|
|
import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
|
import { useModalState } from "../../../zustand/Modal";
|
|
import { useTranslation } from "react-i18next";
|
|
import { canDeleteUser, canEditUser } from "../../../utils/hasAbilityFn";
|
|
import ActionButtons from "../../../Components/Table/ActionButtons";
|
|
|
|
export const useColumns = () => {
|
|
const [t] = useTranslation();
|
|
|
|
const { setIsOpen } = useModalState((state) => state);
|
|
|
|
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
|
const handelDelete = (record: any) => {
|
|
setObjectToEdit(record);
|
|
setIsOpen(ModalEnum?.USER_DELETE);
|
|
};
|
|
const handleEdit = (record: any) => {
|
|
setObjectToEdit(record);
|
|
setIsOpen(ModalEnum?.USER_EDIT);
|
|
};
|
|
|
|
const columns: TableColumnsType<Student_Package> = [
|
|
{
|
|
title: t("columns.id"),
|
|
dataIndex: "id",
|
|
key: "id",
|
|
align: "center",
|
|
},
|
|
{
|
|
title: t("columns.activation_date"),
|
|
dataIndex: "activation_date",
|
|
key: "activation_date",
|
|
align: "center",
|
|
},
|
|
{
|
|
title: t("columns.expiration_date"),
|
|
dataIndex: "expiration_date",
|
|
key: "expiration_date",
|
|
align: "center",
|
|
},
|
|
{
|
|
title: t("columns.first_name"),
|
|
key: "first_name",
|
|
align: "center",
|
|
render: (row) => {
|
|
return row?.student?.first_name;
|
|
},
|
|
},
|
|
{
|
|
title: t("columns.last_name"),
|
|
key: "last_name",
|
|
align: "center",
|
|
render: (row) => {
|
|
return row?.student?.last_name;
|
|
},
|
|
},
|
|
{
|
|
title: t("columns.sex"),
|
|
key: "sex",
|
|
align: "center",
|
|
render: (row) => {
|
|
return row?.student?.sex;
|
|
},
|
|
},
|
|
];
|
|
|
|
return columns;
|
|
};
|