diff --git a/app/admin/page.tsx b/app/admin/page.tsx index d9355dc..26c1c4a 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -35,6 +35,7 @@ export default function AdminPage() { let filtered_ratings: any = []; if (!isLoading) { + console.log(ratings); for (let rating of ratings) { const name = rating.User?.name; const email = rating.User?.email; diff --git a/app/api/submitReview/route.ts b/app/api/submitReview/route.ts index 3c922ef..f95f884 100644 --- a/app/api/submitReview/route.ts +++ b/app/api/submitReview/route.ts @@ -32,7 +32,6 @@ export async function POST(request: NextRequest) { }, }); if (user?.id && theClass && profs) { - /* const newReview = await prisma.rating.create({ data: { userId: user?.id, @@ -51,7 +50,6 @@ export async function POST(request: NextRequest) { profBannerId: profs.bannerId, profUid: profs.uid, }, - }); if (newReview) { @@ -107,9 +105,8 @@ export async function POST(request: NextRequest) { } } } - */ } //console.log(plans); - return NextResponse.json("Submission Failed, no user", { status: 500 }); + return NextResponse.json("Success", { status: 200 }); } diff --git a/components/CreatePlan.tsx b/components/CreatePlan.tsx index 70b169b..84f3f90 100644 --- a/components/CreatePlan.tsx +++ b/components/CreatePlan.tsx @@ -29,6 +29,7 @@ import { useDebouncedCallback } from "use-debounce"; import { setPlanName } from "../app/actions/setPlanName"; import { getCourseIds, + getCoursePlans, getPlanCourses1, removeCourseFromDBPlan, } from "app/actions/getCourses"; @@ -41,6 +42,8 @@ export default function CreatePlan(props: any) { const pathname = usePathname(); const { data: session, status } = useSession(); const [coursePlanName, setCoursePlanName]: any = useState(""); + const [alert, setAlert]: any = useState(undefined); + const [editable, setEditable]: any = useState(""); const [edit, setEdit]: any = useState(false); const [courses, setCourses] = useState(); @@ -49,15 +52,21 @@ export default function CreatePlan(props: any) { ); const [selectedCoursePlan, setSelectedCoursePlan]: any = useState([]); const [isScrolled, setIsScrolled] = useState(false); - const fetcher = (url: any) => fetch(url).then((r) => r.json()); + async function fetchNewData() { + const coursePlans: CoursePlan[] = await getCoursePlans(); + setCoursePlans(coursePlans); + } + const handleNameChange = useDebouncedCallback((newName: any, id: string) => { setPlanName(newName, id); + fetchNewData(); }, 50); async function createPlan() { if (coursePlanName) { + setAlert(undefined); await axios .post("/api/createplan", { planName: coursePlanName, @@ -66,12 +75,14 @@ export default function CreatePlan(props: any) { setCoursePlanName(""); setSelectedCoursePlan([response.data.id]); setPlanCookie(response.data.id); - + fetchNewData(); //console.log(response); }) .catch(function (error) { console.log(error); }); + } else { + setAlert("A name is required to create a course plan."); } } async function updateLocalPlan() { @@ -134,6 +145,7 @@ export default function CreatePlan(props: any) { if (courses && courses != undefined) { return courses.map((course: any) => ( + {alert ? ( +
{alert}
+ ) : null}
@@ -263,6 +280,7 @@ export default function CreatePlan(props: any) { ) : null}
diff --git a/components/Search.tsx b/components/Search.tsx index c0633cd..ceb5eba 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -85,7 +85,6 @@ export default function Search(props: any) { setSelectedDOTW(searchParams.get("dotw")?.toString().split(",")); setSelectedStartTime(searchParams.get("stime")?.toString().split(",")); //handleSelectionChange({ target: { value: selectedTerm } }); - }, [searchParams]); useEffect(() => { @@ -140,7 +139,6 @@ export default function Search(props: any) { return (
- { + {/* Mobile?*/} + - - +
  • + +
  • +
  • + +
  • - - {/* Mobile?*/}
    {siteConfig.navItems.map((item, index) => ( @@ -193,7 +197,7 @@ export const Navbar = (props: any) => { {session.user?.name || "Account"} - + {/* Causes an awful error if rendered conditionally */} {/* Admin @@ -205,6 +209,7 @@ export const Navbar = (props: any) => { ) : (