-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Admin Dashboard Instructors Page Active Instructor Table
- Loading branch information
Showing
6 changed files
with
255 additions
and
20 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/(admin)/admin/instructors/_components/ActiveInstructor.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { DataTable } from "@/app/dashboard/courses/_components/data-table"; | ||
import { getAdminInstructors } from "@/queries/admin"; | ||
import { columns } from "./columns"; | ||
import { getCourseDetailsByInstructor } from "@/queries/courses"; | ||
|
||
const ActiveInstructor = async () => { | ||
const activeInstructors = await getAdminInstructors("Teacher"); | ||
|
||
const modifiedInstructors = await Promise.all(activeInstructors.map(async instructor => { | ||
const { courses, enrollments, ratings } = await getCourseDetailsByInstructor(instructor?.id); | ||
|
||
return { | ||
id: instructor.id, | ||
role: instructor.role, | ||
image: instructor?.profilePicture?.url, | ||
name: instructor?.firstName + " " + instructor?.lastName, | ||
email: instructor.email, | ||
status: "Active", | ||
courses, | ||
enrollments, | ||
ratings | ||
} | ||
})) | ||
|
||
console.log(modifiedInstructors); | ||
|
||
return ( | ||
<div> | ||
<DataTable columns={columns} data={modifiedInstructors} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ActiveInstructor; |
10 changes: 10 additions & 0 deletions
10
app/(admin)/admin/instructors/_components/PendingInstructor.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
const PendingInstructor = () => { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
export default PendingInstructor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
"use client"; | ||
|
||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
import { cn } from "@/lib/utils"; | ||
import { GraduationCap, Trash } from "lucide-react"; | ||
import { Star } from "lucide-react"; | ||
import { ArrowUpDown, MoreHorizontal, Pencil } from "lucide-react"; | ||
import Link from "next/link"; | ||
|
||
export const columns = [ | ||
{ | ||
accessorKey: "image", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
> | ||
Photo | ||
</Button> | ||
); | ||
}, | ||
cell: ({ row }) => { | ||
const photo = row?.original?.image; | ||
const name = row?.original?.name; | ||
|
||
return <div className="ml-3"> | ||
<Avatar> | ||
<AvatarImage className="object-cover" src={photo} alt={name} /> | ||
<AvatarFallback>{name.slice(0, 2)}</AvatarFallback> | ||
</Avatar> | ||
</div>; | ||
}, | ||
}, | ||
{ | ||
accessorKey: "name", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
> | ||
Name <ArrowUpDown className="w-4 h-4 ml-2" /> | ||
</Button> | ||
); | ||
} | ||
}, | ||
{ | ||
accessorKey: "email", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
> | ||
Email <ArrowUpDown className="w-4 h-4 ml-2" /> | ||
</Button> | ||
); | ||
} | ||
}, | ||
{ | ||
accessorKey: "courses", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
> | ||
Course <ArrowUpDown className="w-4 h-4 ml-2" /> | ||
</Button> | ||
); | ||
}, | ||
cell: ({ row }) => { | ||
const courses = row.original.courses; | ||
|
||
return ( | ||
<div className="ml-4"> | ||
{courses} | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: "enrollments", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
> | ||
Enrollment <ArrowUpDown className="w-4 h-4 ml-2" /> | ||
</Button> | ||
); | ||
}, | ||
cell: ({ row }) => { | ||
const enrollments = row.original.enrollments; | ||
|
||
return ( | ||
<div className="ml-4"> | ||
{enrollments} | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: "ratings", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
> | ||
Rating <ArrowUpDown className="w-4 h-4 ml-2" /> | ||
</Button> | ||
); | ||
}, | ||
cell: ({ row }) => { | ||
const ratings = row.original.ratings; | ||
|
||
return ( | ||
<div className="ml-4"> | ||
{ratings} | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: "status", | ||
header: ({ column }) => { | ||
return ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
> | ||
Status <ArrowUpDown className="w-4 h-4 ml-2" /> | ||
</Button> | ||
); | ||
}, | ||
cell: ({ row }) => { | ||
const status = row.original.status; | ||
|
||
return ( | ||
<Badge className={cn("bg-gray-500 ml-4", status === "Active" && "bg-success")}> | ||
{status === "Active" && "Active"} | ||
</Badge> | ||
); | ||
}, | ||
}, | ||
{ | ||
id: "actions", | ||
cell: ({ row }) => { | ||
const { id } = row.original; | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="w-8 h-4 p-0"> | ||
<span className="sr-only">Open Menu</span> | ||
<MoreHorizontal className="w-4 h-4" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<button className="w-full"> | ||
<DropdownMenuItem className="flex items-center w-full gap-2 cursor-pointer"> | ||
<Trash className="w-4 h-4" /> | ||
Delete | ||
</DropdownMenuItem> | ||
</button> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters