forked from expertiza/reimplementation-front-end
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CourseColumns.tsx
77 lines (70 loc) · 2.23 KB
/
CourseColumns.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { createColumnHelper, Row } from "@tanstack/react-table";
import { Button } from "react-bootstrap";
import { BsPencilFill, BsPersonXFill } from "react-icons/bs";
import { MdContentCopy, MdDelete } from "react-icons/md";
import { ICourseResponse as ICourse } from "../../utils/interfaces";
/**
* @author Atharva Thorve, on December, 2023
* @author Mrityunjay Joshi on December, 2023
*/
// Course Columns Configuration: Defines the columns for the courses table
type Fn = (row: Row<ICourse>) => void;
const columnHelper = createColumnHelper<ICourse>();
export const courseColumns = (handleEdit: Fn, handleDelete: Fn, handleTA: Fn, handleCopy: Fn) => [
// Column for the course name
columnHelper.accessor("name", {
id: "name",
header: "Name",
enableSorting: true,
enableColumnFilter: true,
enableGlobalFilter: false
}),
// Column for the institution name
columnHelper.accessor("institution.name", {
id: "institution",
header: "Institution",
enableSorting: true,
enableMultiSort: true,
enableGlobalFilter: false
}),
// Column for the creation date
columnHelper.accessor("created_at", {
header: "Creation Date",
enableSorting: true,
enableColumnFilter: false,
enableGlobalFilter: false
}),
// Column for the last updated date
columnHelper.accessor("updated_at", {
header: "Updated Date",
enableSorting: true,
enableColumnFilter: false,
enableGlobalFilter: false
}),
// Actions column with edit, delete, TA, and copy buttons
columnHelper.display({
id: "actions",
header: "Actions",
cell: ({ row }) => (
<>
<Button variant="outline-warning" size="sm" onClick={() => handleEdit(row)}>
<BsPencilFill />
</Button>
<Button
variant="outline-danger"
size="sm"
className="ms-sm-2"
onClick={() => handleDelete(row)}
>
<MdDelete />
</Button>
<Button variant="outline-info" size="sm" className="ms-sm-2" onClick={() => handleTA(row)}>
<BsPersonXFill />
</Button>
<Button variant="outline-primary" size="sm" className="ms-sm-2" onClick={() => handleCopy(row)}>
<MdContentCopy />
</Button>
</>
),
}),
];