Skip to content

Commit

Permalink
Added some basic pages
Browse files Browse the repository at this point in the history
  • Loading branch information
vilnor committed Apr 24, 2024
1 parent 2c012bb commit b8a13d1
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 7 deletions.
21 changes: 21 additions & 0 deletions frontend/src/app/courses/[courseCode]/course-profile/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useMemo } from 'react';
import { Course } from '@/types';

export default function CourseProfile({ params }: { params: { courseCode: string }}) {
const course: Course = useMemo(() => {
// query backend here
return {
coursecode: params.courseCode.toUpperCase(),
coursename: 'Course Name',
coursedescription: 'Some sort of description'
}
}, [params.courseCode])

return (
<main>
<h1>{course.coursename}</h1>
<h2>{course.coursecode}</h2>
<h2>{course.coursedescription}</h2>
</main>
);
}
21 changes: 21 additions & 0 deletions frontend/src/app/courses/[courseCode]/exams/[examId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useMemo } from 'react';

export default function Exam({ params }: { params: { courseCode: string, examId: number }}) {
const exam = useMemo(() => {
// query backend here
return {
examid: params.examId,
examyear: 2023,
examsemester: 1,
examtype: 'Final'
}
}, [params.examId])

return (
<main>
<h1>{`${params.courseCode} ${exam.examtype}`}</h1>
<h2>{`${exam.examyear} Semester ${exam.examsemester}`}</h2>
There will be some questions here
</main>
);
}
20 changes: 20 additions & 0 deletions frontend/src/app/courses/[courseCode]/exams/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useMemo } from 'react';
import { Course } from '@/types';

export default function Exams({ params }: { params: { courseCode: string }}) {
const course: Course = useMemo(() => {
// query backend here
return {
coursecode: params.courseCode.toUpperCase(),
coursename: 'Course Name',
coursedescription: 'Some sort of description'
}
}, [params.courseCode])

return (
<main>
<h1>Exams for {course.coursecode}</h1>
There will be some cards here
</main>
);
}
20 changes: 20 additions & 0 deletions frontend/src/app/courses/[courseCode]/notes/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useMemo } from 'react';
import { Course } from '@/types';

export default function Notes({ params }: { params: { courseCode: string }}) {
const course: Course = useMemo(() => {
// query backend here
return {
coursecode: params.courseCode.toUpperCase(),
coursename: 'Course Name',
coursedescription: 'Some sort of description'
}
}, [params.courseCode])

return (
<main>
<h1>Study material for {course.coursecode}</h1>
There will be some cards here
</main>
);
}
26 changes: 19 additions & 7 deletions frontend/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client'

import { useRef } from 'react'
import { useMemo, useRef } from 'react';
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { useParams, usePathname } from 'next/navigation';
import clsx from 'clsx'
import { AnimatePresence, motion, useIsPresent } from 'framer-motion'

Expand Down Expand Up @@ -33,7 +33,7 @@ function TopLevelNavItem({
children: React.ReactNode
}) {
return (
<li className="md:hidden">
<li>
<Link
href={href}
className="block py-1 text-sm text-zinc-600 transition hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white"
Expand Down Expand Up @@ -239,13 +239,25 @@ export const navigation: Array<NavGroup> = [
]

export function Navigation(props: React.ComponentPropsWithoutRef<'nav'>) {
const {courseCode} = useParams<{courseCode: string}>()

const sideNavigation: Array<NavGroup> = useMemo(() => [
{
title: `Exams`,
links: [
{ title: '2023 S1', href: `/courses/${courseCode}/exams/1` },
{ title: '2022 S1', href: `/courses/${courseCode}/exams/2` },
{ title: '2021 S1', href: `/courses/${courseCode}/exams/3` },
],
},
], [courseCode])

return (
<nav {...props}>
<ul role="list">
<TopLevelNavItem href="/">API</TopLevelNavItem>
<TopLevelNavItem href="#">Documentation</TopLevelNavItem>
<TopLevelNavItem href="#">Support</TopLevelNavItem>
{navigation.map((group, groupIndex) => (
<TopLevelNavItem href={`/courses/${courseCode}/course-profile`}>Course Profile</TopLevelNavItem>
<TopLevelNavItem href={`/courses/${courseCode}/notes`}>Notes</TopLevelNavItem>
{sideNavigation.map((group, groupIndex) => (
<NavigationGroup
key={group.title}
group={group}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type Course = {
coursecode: string
coursename: string
coursedescription: string
}

0 comments on commit b8a13d1

Please sign in to comment.