diff --git a/frontend/edu-connect/src/app/(admin)/admin/category/_partials/CategoryTable.tsx b/frontend/edu-connect/src/app/(admin)/admin/category/_partials/CategoryTable.tsx new file mode 100644 index 0000000..6a25b7d --- /dev/null +++ b/frontend/edu-connect/src/app/(admin)/admin/category/_partials/CategoryTable.tsx @@ -0,0 +1,113 @@ +import DataTable from "@/components/(dashboard)/common/DataTable/DataTable" +import { Button } from "@/components/(dashboard)/ui/button" +import { Badge } from "@/components/ui/badge" +import { routes } from "@/lib/routes" +import { ColumnDef } from "@tanstack/react-table" +import { ArrowUpDown } from "lucide-react" + +const CategoryTable: React.FC<{ + mutate: () => void + Data: Array + isLoading: boolean +}> = ({ + mutate, + Data, + isLoading + }) => { + + const columns: ColumnDef[] = [ + { + accessorKey: "sn", + header: "SN", + cell: ({ row }) => ( +
{row.index + 1}
+ ), + }, + { + id: 'name', + accessorFn: (row: any) => row.original?.name, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+

{row.original?.name}

+
+ ), + }, + { + id: 'description', + accessorFn: (row: any) => row.original?.description, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
{row.original?.description ?? '-'}
+ ), + }, + { + id: 'creationDate', + accessorFn: (row: any) => row.original?.creationDate, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+ {row.original?.creationDate ? new Date(row.original.creationDate).toLocaleDateString() : '-'} +
+ ), + }, + { + id: 'isActive', + accessorFn: (row: any) => row.original?.isActive, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
{row.original?.isActive ? Active : Deactive}
+ ), + }, + ] + + return( + <> + + + ) +} + +export default CategoryTable \ No newline at end of file diff --git a/frontend/edu-connect/src/app/(admin)/admin/category/page.tsx b/frontend/edu-connect/src/app/(admin)/admin/category/page.tsx new file mode 100644 index 0000000..7d2df1a --- /dev/null +++ b/frontend/edu-connect/src/app/(admin)/admin/category/page.tsx @@ -0,0 +1,49 @@ +'use client' +import BreadCrumbNav from "@/components/(dashboard)/common/BreadCumbNav/BreadCrumbNav" +import ContentContainer from "@/components/(dashboard)/elements/ContentContainer" +import { PageHeading } from "@/components/(dashboard)/ui/title" +import CommonContainer from "@/components/elements/CommonContainer" +import AppContextProvider from "@/helpers/context/AppContextProvider" +import { defaultFetcher } from "@/helpers/fetch.helper" +import { routes } from "@/lib/routes" +import { APP_BASE_URL } from "@/utils/constants" +import AdminView from "@/views/AdminView" +import useSWR from "swr" +import CategoryTable from "./_partials/CategoryTable" + + +const CategoryIndexPage = () => { + const CategoryListURL = `${APP_BASE_URL}/api/courses/getCategories` + const { data, mutate, isLoading } = useSWR(CategoryListURL, defaultFetcher); + + return( + + + + Categories + + +
+ +
+
+
+
+
+ ) +} + +export default CategoryIndexPage \ No newline at end of file diff --git a/frontend/edu-connect/src/app/(admin)/admin/course/_partials/CourseTable.tsx b/frontend/edu-connect/src/app/(admin)/admin/course/_partials/CourseTable.tsx new file mode 100644 index 0000000..2f4e1eb --- /dev/null +++ b/frontend/edu-connect/src/app/(admin)/admin/course/_partials/CourseTable.tsx @@ -0,0 +1,172 @@ +import DataTable from "@/components/(dashboard)/common/DataTable/DataTable" +import { Button } from "@/components/(dashboard)/ui/button" +import { Avatar, AvatarImage } from "@/components/ui/avatar" +import { Badge } from "@/components/ui/badge" +import { ColumnDef } from "@tanstack/react-table" +import { ArrowUpDown } from "lucide-react" + +const CourseTable: React.FC<{ + mutate: () => void + Data: Array + isLoading: boolean +}> = ({ + mutate, + Data, + isLoading + }) => { + + const columns: ColumnDef[] = [ + { + accessorKey: "sn", + header: "SN", + cell: ({ row }) => ( +
{row.index + 1}
+ ), + }, + { + id: 'name', + accessorFn: (row: any) => row.original?.name, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+ + + +

{row.original?.name}

+
+ ), + }, + { + id: 'description', + accessorFn: (row: any) => row.original?.description, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
{row.original?.description ?? '-'}
+ ), + }, + { + id: 'author', + accessorFn: (row: any) => row.original?.author?.firstName, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
{row.original?.author?.firstName} {row.original?.author?.lastName}
+ ), + }, + { + id: 'category', + accessorFn: (row: any) => row.original?.category?.name, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
{row.original?.category?.name}
+ ), + }, + { + id: 'creationDate', + accessorFn: (row: any) => row.original?.creationDate, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+ {row.original?.creationDate ? new Date(row.original.creationDate).toLocaleDateString() : '-'} +
+ ), + }, + { + id: 'isActive', + accessorFn: (row: any) => row.original?.isActive, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
{row.original?.isActive ? Active : Deactive}
+ ), + }, + { + id: 'totalEnrolled', + accessorFn: (row: any) => row.original?.totalEnrolled, + header: ({ column }) => ( + + ), + cell: ({ row }) => ( +
+ {row.original?.totalEnrolled ?? '-'} +
+ ), + }, + ] + + return( + <> + + + ) +} + +export default CourseTable \ No newline at end of file diff --git a/frontend/edu-connect/src/app/(admin)/admin/course/page.tsx b/frontend/edu-connect/src/app/(admin)/admin/course/page.tsx new file mode 100644 index 0000000..3f840e6 --- /dev/null +++ b/frontend/edu-connect/src/app/(admin)/admin/course/page.tsx @@ -0,0 +1,48 @@ +'use client' +import BreadCrumbNav from "@/components/(dashboard)/common/BreadCumbNav/BreadCrumbNav" +import ContentContainer from "@/components/(dashboard)/elements/ContentContainer" +import { PageHeading } from "@/components/(dashboard)/ui/title" +import CommonContainer from "@/components/elements/CommonContainer" +import AppContextProvider from "@/helpers/context/AppContextProvider" +import { defaultFetcher } from "@/helpers/fetch.helper" +import { routes } from "@/lib/routes" +import { APP_BASE_URL } from "@/utils/constants" +import AdminView from "@/views/AdminView" +import useSWR from "swr" +import CourseTable from "./_partials/CourseTable" + +const CourseIndexPage = () => { + const CourseListURL = `${APP_BASE_URL}/api/course/listall` + const { data, mutate, isLoading } = useSWR(CourseListURL, defaultFetcher); + + return ( + + + + Courses + + +
+ +
+
+
+
+
+ ) +} + +export default CourseIndexPage \ No newline at end of file diff --git a/frontend/edu-connect/src/lib/routes.ts b/frontend/edu-connect/src/lib/routes.ts index 011951d..d13a759 100644 --- a/frontend/edu-connect/src/lib/routes.ts +++ b/frontend/edu-connect/src/lib/routes.ts @@ -5,7 +5,9 @@ export const routes = { DASHBOARD_ROUTE : '/admin/dashboard', PROFILE_ROUTE : '/user/profile', MY_COURSES_INDEX : '/my-courses', - USER_INDEX_PAGE : '/admin/users' + USER_INDEX_PAGE : '/admin/users', + COURSE_INDEX_PAGE: '/admin/course', + CATEGORY_INDEX_PAGE: '/admin/category' } export const privateRoutes = ['/user/profile']