Skip to content

Commit

Permalink
feat: fix prerequisites data
Browse files Browse the repository at this point in the history
  • Loading branch information
jinh0 committed Dec 1, 2022
1 parent fc2a572 commit 3b658c8
Show file tree
Hide file tree
Showing 9 changed files with 56,723 additions and 16,096 deletions.
19 changes: 10 additions & 9 deletions components/course/Notes.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import { Note } from '@typing'
import Link from 'next/link'

const NotesLink = ({ href, text }: { href: string; text: string }) => {
return (
<Link href={href}>
<span className='underline'>{text}</span>
</Link>
)
}

const Notes = ({ notes }: { notes: Note[] }) => {
// TODO: Add comments
// Adds links to a bullet point
const withLinks = (point: Note) => {
return point.links.reduce(
(acc, link) =>
Expand Down Expand Up @@ -39,6 +31,7 @@ const Notes = ({ notes }: { notes: Note[] }) => {
)
}

// Add bold to "Prerequisites:" in the bullet point
const format = (words: Array<string | JSX.Element>) => {
if (words.length === 0) return []

Expand All @@ -65,4 +58,12 @@ const Notes = ({ notes }: { notes: Note[] }) => {
)
}

const NotesLink = ({ href, text }: { href: string; text: string }) => {
return (
<Link href={href}>
<span className='underline'>{text}</span>
</Link>
)
}

export default Notes
61 changes: 42 additions & 19 deletions pages/courses/[code].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ import GoBack from '@components/GoBack'
import Main from '@components/Main'
import Title from '@components/Title'
import { useRouter } from 'next/router'
import { CourseType, UserType, VSBCourse } from '@typing'
import { useContext } from 'react'
import UserContext from '@contexts/UserContext'
import { CourseType, VSBCourse } from '@typing'
import Actions from '@components/course/Actions'

import courses from 'utils/courses'
import VSBData from '@components/course/VSBData'
import vsbCourses from '@utils/vsb'
import Semesters from '@components/course/Semesters'
import Extra from '@components/course/Extra'
import useUser from '@hooks/useUser'
import ShareButton from '@components/course/ShareButton'
import Notes from '@components/course/Notes'
import { Tab } from '@headlessui/react'

const Course = ({ course }: { course: CourseType & { vsb: VSBCourse } }) => {
const router = useRouter()
Expand All @@ -29,26 +27,51 @@ const Course = ({ course }: { course: CourseType & { vsb: VSBCourse } }) => {

return (
<Main title={`${format(code)} | Cloudberry`} content={course.description}>
<GoBack />
<Title>
{format(code)}: {course.name}
<ShareButton />
</Title>
<div className='flex flex-row'>
<div className='lg:w-3/5 text-base lg:text-lg mt-4'>
<GoBack />
<Title>
{format(code)}: {course.name}
<ShareButton />
</Title>

<div className='lg:w-3/5 text-base lg:text-lg mt-4'>
<Semesters terms={course.terms} />
<Semesters terms={course.terms} />

{user && <Actions code={code} />}
{user && <Actions code={code} />}

<div className='mt-10'>
<p className='text-2xl mb-4'>Overview</p>
<p>{course.description}</p>
</div>
<div className='mt-10'>
<p className='text-2xl mb-4'>Overview</p>
<p>{course.description}</p>
</div>

<Notes notes={course.notes} />

{/* <Extra course={course} /> */}
<Notes notes={course.notes} />
<VSBData data={course.vsb} />

<VSBData data={course.vsb} />
{/* <div className='mt-10 outline-none outline-0'>
<Tab.Group>
<Tab.List>
<Tab className='outline-none text-xl mr-8'>Overview</Tab>
<Tab className='outline-none text-xl mr-8'>
Winter 2023 Schedule
</Tab>
</Tab.List>
<Tab.Panels>
<Tab.Panel className='outline-none'>
<div className='mt-10'>
<p className='text-2xl mb-4'>Overview</p>
<p>{course.description}</p>
</div>
<Notes notes={course.notes} />
</Tab.Panel>
<Tab.Panel className='outline-none'>
<VSBData data={course.vsb} />
</Tab.Panel>
</Tab.Panels>
</Tab.Group>
</div> */}
</div>
</div>
</Main>
)
Expand Down
Loading

1 comment on commit 3b658c8

@vercel
Copy link

@vercel vercel bot commented on 3b658c8 Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.