Please sign in to view your billing information.
;
+ if (!userId) return Please sign in to view your billing information.
;
+ if (error) return Error loading transactions. Please try again later.
;
return (
@@ -114,4 +119,4 @@ const TeacherBilling = () => {
);
};
-export default TeacherBilling;
+export default TeacherBilling;
\ No newline at end of file
diff --git a/client/src/app/(dashboard)/teacher/courses/page.tsx b/client/src/app/(dashboard)/teacher/courses/page.tsx
index d620322..68b6e41 100644
--- a/client/src/app/(dashboard)/teacher/courses/page.tsx
+++ b/client/src/app/(dashboard)/teacher/courses/page.tsx
@@ -10,13 +10,21 @@ import {
useDeleteCourseMutation,
useGetCoursesQuery,
} from "@/state/api";
-import { useUser } from "@clerk/nextjs";
import { useRouter } from "next/navigation";
import React, { useMemo, useState } from "react";
+import useAuth from "@/hooks/useAuth"; // Use the updated custom authentication hook
+
+// Define the structure for a Course
+interface Course {
+ courseId: string;
+ title: string;
+ category: string;
+ teacherId: string;
+}
const Courses = () => {
const router = useRouter();
- const { user } = useUser();
+ const { user, isLoaded } = useAuth(); // Use the updated custom useAuth hook
const {
data: courses,
isLoading,
@@ -32,7 +40,7 @@ const Courses = () => {
const filteredCourses = useMemo(() => {
if (!courses) return [];
- return courses.filter((course) => {
+ return courses.filter((course: Course) => {
const matchesSearch = course.title
.toLowerCase()
.includes(searchTerm.toLowerCase());
@@ -55,10 +63,13 @@ const Courses = () => {
};
const handleCreateCourse = async () => {
- if (!user) return;
+ if (!user || !user.id) {
+ alert("You must be signed in as a teacher to create a course.");
+ return;
+ }
const result = await createCourse({
- teacherId: user.id,
+ teacherId: user.id, // Ensured to be a string at this point
teacherName: user.fullName || "Unknown Teacher",
}).unwrap();
router.push(`/teacher/courses/${result.courseId}`, {
@@ -66,6 +77,8 @@ const Courses = () => {
});
};
+ if (!isLoaded) return
;
+ if (!user) return
Please sign in to view your courses.
;
if (isLoading) return
;
if (isError || !courses) return
Error loading courses.
;
@@ -94,7 +107,7 @@ const Courses = () => {
course={course}
onEdit={handleEdit}
onDelete={handleDelete}
- isOwner={course.teacherId === user?.id}
+ isOwner={course.teacherId === user.id}
/>
))}
@@ -102,4 +115,4 @@ const Courses = () => {
);
};
-export default Courses;
+export default Courses;
\ No newline at end of file
diff --git a/client/src/app/(dashboard)/teacher/profile/[[...profile]]/page.tsx b/client/src/app/(dashboard)/teacher/profile/[[...profile]]/page.tsx
index 2653584..d697741 100644
--- a/client/src/app/(dashboard)/teacher/profile/[[...profile]]/page.tsx
+++ b/client/src/app/(dashboard)/teacher/profile/[[...profile]]/page.tsx
@@ -1,29 +1,34 @@
+"use client";
+
import Header from "@/components/Header";
-import { UserProfile } from "@clerk/nextjs";
-import { dark } from "@clerk/themes";
import React from "react";
+import useAuth from "@/hooks/useAuth"; // Custom authentication hook
const TeacherProfilePage = () => {
+ const { user, isLoaded } = useAuth(); // Replace Clerk's useUser with custom useAuth
+
+ if (!isLoaded) return Loading...
;
+ if (!user) return Please sign in to view your profile.
;
+
return (
<>