feat: refactor column definitions to use dynamic rendering based on permissions
This commit is contained in:
parent
4350f7d9ea
commit
56c41db373
@ -26,7 +26,7 @@ export function createAssignmentColumns(
|
|||||||
canViewSubmissions,
|
canViewSubmissions,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Assignment>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'title',
|
accessorKey: 'title',
|
||||||
header: () => <span>Judul</span>,
|
header: () => <span>Judul</span>,
|
||||||
@ -96,7 +96,10 @@ export function createAssignmentColumns(
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canViewSubmissions || canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -133,6 +136,8 @@ export function createAssignmentColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,10 @@ export default function SubmissionIndex({
|
|||||||
<div className="text-center">{row.original.score ?? '-'}</div>
|
<div className="text-center">{row.original.score ?? '-'}</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -156,8 +159,8 @@ export default function SubmissionIndex({
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export function createMaterialColumns(
|
|||||||
): ColumnDef<Material>[] {
|
): ColumnDef<Material>[] {
|
||||||
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Material>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'meeting_number',
|
accessorKey: 'meeting_number',
|
||||||
header: () => <span className="block text-center">Pertemuan</span>,
|
header: () => <span className="block text-center">Pertemuan</span>,
|
||||||
@ -86,7 +86,10 @@ export function createMaterialColumns(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -117,6 +120,8 @@ export function createMaterialColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export function createTuitionInvoiceColumns(
|
|||||||
canViewPayments,
|
canViewPayments,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<TuitionInvoice>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'student.student_number',
|
accessorKey: 'student.student_number',
|
||||||
header: () => <span>Mahasiswa</span>,
|
header: () => <span>Mahasiswa</span>,
|
||||||
@ -126,7 +126,10 @@ export function createTuitionInvoiceColumns(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canViewPayments || canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -163,6 +166,8 @@ export function createTuitionInvoiceColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,7 +148,10 @@ export default function TuitionPaymentIndex({ invoice, payments }: Props) {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -175,8 +178,8 @@ export default function TuitionPaymentIndex({ invoice, payments }: Props) {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export function createAnnouncementColumns(
|
|||||||
): ColumnDef<Announcement>[] {
|
): ColumnDef<Announcement>[] {
|
||||||
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Announcement>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'title',
|
accessorKey: 'title',
|
||||||
header: () => <span>Judul</span>,
|
header: () => <span>Judul</span>,
|
||||||
@ -71,7 +71,10 @@ export function createAnnouncementColumns(
|
|||||||
cell: ({ row }) =>
|
cell: ({ row }) =>
|
||||||
format(new Date(row.original.created_at), 'd MMM yyyy, HH:mm'),
|
format(new Date(row.original.created_at), 'd MMM yyyy, HH:mm'),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -98,6 +101,8 @@ export function createAnnouncementColumns(
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export function createCourseClassColumns(
|
|||||||
canViewEnrollments,
|
canViewEnrollments,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<CourseClass>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'course.name',
|
accessorKey: 'course.name',
|
||||||
header: () => <span>Mata Kuliah</span>,
|
header: () => <span>Mata Kuliah</span>,
|
||||||
@ -90,7 +90,10 @@ export function createCourseClassColumns(
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canViewEnrollments || canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -127,6 +130,8 @@ export function createCourseClassColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,10 @@ export default function ClassEnrollmentIndex({
|
|||||||
: '-';
|
: '-';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -103,8 +106,8 @@ export default function ClassEnrollmentIndex({
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export function createAcademicTermColumns(
|
|||||||
canUpdateStatus,
|
canUpdateStatus,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<AcademicTerm>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'name',
|
accessorKey: 'name',
|
||||||
header: () => <span>Nama</span>,
|
header: () => <span>Nama</span>,
|
||||||
@ -89,7 +89,10 @@ export function createAcademicTermColumns(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -120,6 +123,8 @@ export function createAcademicTermColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export function createCourseColumns(
|
|||||||
): ColumnDef<Course>[] {
|
): ColumnDef<Course>[] {
|
||||||
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Course>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'code',
|
accessorKey: 'code',
|
||||||
header: () => <span>Kode</span>,
|
header: () => <span>Kode</span>,
|
||||||
@ -73,7 +73,10 @@ export function createCourseColumns(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -104,6 +107,8 @@ export function createCourseColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export function createDepartmentColumns(
|
|||||||
): ColumnDef<Department>[] {
|
): ColumnDef<Department>[] {
|
||||||
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Department>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'code',
|
accessorKey: 'code',
|
||||||
header: () => <span>Kode</span>,
|
header: () => <span>Kode</span>,
|
||||||
@ -55,7 +55,10 @@ export function createDepartmentColumns(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -86,6 +89,8 @@ export function createDepartmentColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export function createAcademicAdvisingLogColumns(
|
|||||||
): ColumnDef<AcademicAdvisingLog>[] {
|
): ColumnDef<AcademicAdvisingLog>[] {
|
||||||
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<AcademicAdvisingLog>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'student.student_number',
|
accessorKey: 'student.student_number',
|
||||||
header: () => <span>Mahasiswa</span>,
|
header: () => <span>Mahasiswa</span>,
|
||||||
@ -72,7 +72,10 @@ export function createAcademicAdvisingLogColumns(
|
|||||||
: '-';
|
: '-';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -99,6 +102,8 @@ export function createAcademicAdvisingLogColumns(
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export function createLetterRequestColumns(
|
|||||||
): ColumnDef<LetterRequest>[] {
|
): ColumnDef<LetterRequest>[] {
|
||||||
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<LetterRequest>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'student.student_number',
|
accessorKey: 'student.student_number',
|
||||||
header: () => <span>Mahasiswa</span>,
|
header: () => <span>Mahasiswa</span>,
|
||||||
@ -132,7 +132,10 @@ export function createLetterRequestColumns(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -159,6 +162,8 @@ export function createLetterRequestColumns(
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ export function createAdministratorColumns(
|
|||||||
canUpdateStatus,
|
canUpdateStatus,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Administrator>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'profile.full_name',
|
accessorKey: 'profile.full_name',
|
||||||
header: () => <span>Nama Lengkap</span>,
|
header: () => <span>Nama Lengkap</span>,
|
||||||
@ -86,7 +86,10 @@ export function createAdministratorColumns(
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canResetPassword || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -123,6 +126,8 @@ export function createAdministratorColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export function createLecturerColumns(
|
|||||||
canUpdateStatus,
|
canUpdateStatus,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Lecturer>[] = [
|
||||||
{
|
{
|
||||||
id: 'identity',
|
id: 'identity',
|
||||||
header: () => <span>NIDN</span>,
|
header: () => <span>NIDN</span>,
|
||||||
@ -104,7 +104,10 @@ export function createLecturerColumns(
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canResetPassword || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -141,6 +144,8 @@ export function createLecturerColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,7 @@ export function createStudentColumns(
|
|||||||
canUpdateAccountStatus,
|
canUpdateAccountStatus,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return [
|
const columns: ColumnDef<Student>[] = [
|
||||||
{
|
{
|
||||||
id: 'identity',
|
id: 'identity',
|
||||||
header: () => <span>NIM</span>,
|
header: () => <span>NIM</span>,
|
||||||
@ -143,7 +143,10 @@ export function createStudentColumns(
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (canUpdate || canResetPassword || canDelete) {
|
||||||
|
columns.push({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
header: () => <span className="block text-center">Aksi</span>,
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
meta: {
|
meta: {
|
||||||
@ -180,6 +183,8 @@ export function createStudentColumns(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return columns;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user