-
Notifications
You must be signed in to change notification settings - Fork 25
Course details components (professors) #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lyangji1011
wants to merge
15
commits into
bog-f25-sprint4
Choose a base branch
from
lauren/course-details-profs
base: bog-f25-sprint4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cf1f412
Daniel/superior seat display mechanism (#359)
DanielChee 539cd59
Fix seating info style inconsistencies (#361)
afazio1 887e936
in progress breadcrumb
lyangji1011 e345299
metrics card
lyangji1011 595c6c5
complete info card
lyangji1011 04b3dec
linting
lyangji1011 5d93518
fixes
lyangji1011 7808b85
light/dark mode fixes
lyangji1011 473ac07
unselected courses added as desired
lyangji1011 d448ec6
Merge remote-tracking branch 'origin/bog-f25-sprint4' into lauren/cou…
lyangji1011 686c54f
function for seat data
lyangji1011 a8e002f
responsive rows + clean up css
lyangji1011 27a2c62
fix
lyangji1011 15929a4
responsive metrics card
lyangji1011 d11dc31
remove sandbox page
lyangji1011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| padding: 4px; | ||
|
|
||
| .action-row-header { | ||
| padding: 4px; | ||
| padding: 5px; | ||
| display: flex; | ||
| align-items: center; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import React from 'react'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
| import { faChevronRight } from '@fortawesome/free-solid-svg-icons'; | ||
|
|
||
| import { classes } from '../../utils/misc'; | ||
|
|
||
| import './stylesheet.scss'; | ||
|
|
||
| export type BreadcrumbItem = { | ||
| label: string; | ||
| link?: string; | ||
| }; | ||
|
|
||
| export type BreadcrumbProps = { | ||
| items: BreadcrumbItem[]; | ||
| }; | ||
|
|
||
| export default function Breadcrumb({ | ||
| items, | ||
| }: BreadcrumbProps): React.ReactElement { | ||
| return ( | ||
| <nav className={classes('Breadcrumb')}> | ||
| <ul className="list"> | ||
| {items.map((item, index) => ( | ||
| <li key={index} className="item"> | ||
| {item.link ? ( | ||
| <a href={item.link} className="link"> | ||
| {item.label} | ||
| </a> | ||
| ) : ( | ||
| <span className="label">{item.label}</span> | ||
| )} | ||
| {index < items.length - 1 && ( | ||
| <FontAwesomeIcon icon={faChevronRight} className="separator" /> | ||
| )} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </nav> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| .Breadcrumb { | ||
| display: flex; | ||
| align-items: center; | ||
| font-size: 16px; | ||
| padding: 8px 12px; | ||
| font-family: 'Roboto'; | ||
lyangji1011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .list { | ||
| display: flex; | ||
| list-style: none; | ||
| margin: 0; | ||
| padding: 0; | ||
|
|
||
| .item { | ||
| display: flex; | ||
| align-items: center; | ||
|
|
||
| .link { | ||
| color: #8bd6fb; | ||
lyangji1011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| text-decoration: none; | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .label { | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .separator { | ||
| margin: 0 6px; | ||
| font-size: 12px; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { classes } from '../../utils/misc'; | ||
|
|
||
| import './stylesheet.scss'; | ||
|
|
||
| export type Metric = { | ||
| label: string; | ||
| value: string; | ||
| unit?: string; | ||
| }; | ||
|
|
||
| export type MetricsCardProps = { | ||
| metrics: Metric[]; | ||
| }; | ||
|
|
||
| export default function MetricsCard({ | ||
| metrics, | ||
| }: MetricsCardProps): React.ReactElement { | ||
| return ( | ||
| <div className={classes('MetricsCard')}> | ||
| <ul className="metrics-list"> | ||
| {metrics.map((metric, index) => ( | ||
| <li key={index} className="metric-item"> | ||
| <div className="metric-value"> | ||
| {metric.value} | ||
| {metric.unit && ( | ||
| <span className="metric-unit"> {metric.unit}</span> | ||
| )} | ||
| </div> | ||
| <div className="metric-label">{metric.label}</div> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| @import '../../variables.scss'; | ||
|
|
||
| .MetricsCard { | ||
| display: flex; | ||
| padding: 16px; | ||
| border-radius: 8px; | ||
| font-family: 'Roboto', sans-serif; | ||
|
|
||
| .metrics-list { | ||
| display: flex; | ||
| list-style: none; | ||
| padding: 0; | ||
| margin: 0; | ||
|
|
||
| .metric-item { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| margin-left: 40px; | ||
| padding-right: 40px; | ||
| border-right: 1px solid $color-border; | ||
|
|
||
| &:last-child { | ||
| border-right: none; | ||
| } | ||
|
|
||
| .metric-value { | ||
| font-size: 20px; | ||
| } | ||
|
|
||
| .metric-unit { | ||
| font-size: 14px; | ||
| font-weight: normal; | ||
| } | ||
|
|
||
| .metric-label { | ||
| font-size: 14px; | ||
| margin-top: 4px; | ||
| @include dark(color, $seat-info-dark-label); | ||
| @include light(color, $seat-info-light-label); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| import React, { useContext } from 'react'; | ||
| import { faPlus, faCheck } from '@fortawesome/free-solid-svg-icons'; | ||
| import useSWR from 'swr'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
|
||
| import { ScheduleContext } from '../../contexts'; | ||
| import { Course, Section } from '../../data/beans'; | ||
| import ActionRow from '../ActionRow'; | ||
| import { OccupiedInfo } from '../SeatInfo'; | ||
|
|
||
| import './stylesheet.scss'; | ||
|
|
||
| export type ProfessorInfoCardProps = { | ||
| professorName: string; | ||
| course: Course; | ||
| }; | ||
|
|
||
| type SeatData = { | ||
| inClass: OccupiedInfo | null; | ||
| waitlist: OccupiedInfo | null; | ||
| }; | ||
|
|
||
| const fetchSeating = async ( | ||
lyangji1011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| section: Section, | ||
| term: string | ||
| ): Promise<SeatData> => { | ||
| try { | ||
| const raw = await section.fetchSeating(term); | ||
|
|
||
| // Handle missing or bad data, assuming less than 4 return values is invalid | ||
| if (!raw[0] || raw[0].length < 4) { | ||
| return { inClass: null, waitlist: null }; | ||
| } | ||
|
|
||
| const [inClassTotal, inClassOccupied, waitlistTotal, waitlistOccupied] = | ||
| raw[0]; | ||
|
|
||
| const toOccupiedInfo = ( | ||
| total: unknown, | ||
| occupied: unknown | ||
| ): OccupiedInfo => ({ | ||
| occupied: Number(occupied ?? 0), | ||
| total: Number(total ?? 0), | ||
| }); | ||
|
|
||
| return { | ||
| inClass: toOccupiedInfo(inClassTotal, inClassOccupied), | ||
| waitlist: toOccupiedInfo(waitlistTotal, waitlistOccupied), | ||
| }; | ||
| } catch (err) { | ||
| return { inClass: null, waitlist: null }; | ||
| } | ||
| }; | ||
|
|
||
| function SectionRow({ | ||
| section, | ||
| term, | ||
| isPinned, | ||
| onAdd, | ||
| }: { | ||
| section: Section; | ||
| term: string; | ||
| isPinned: boolean; | ||
| onAdd: () => void; | ||
| }): React.ReactElement { | ||
| const meeting = section.meetings[0]; | ||
|
|
||
| const { data: seatData, isLoading } = useSWR<SeatData>( | ||
| ['seating', section.crn, term], | ||
| () => fetchSeating(section, term) | ||
| ); | ||
|
|
||
| const formatSeatData = (info: OccupiedInfo | null): string => { | ||
| if (isLoading) return 'Loading...'; | ||
| if (!info) return 'N/A'; | ||
| return `${info.occupied} / ${info.total}`; | ||
| }; | ||
|
|
||
| return ( | ||
| <ActionRow key={section.crn} className="section-row" label="" actions={[]}> | ||
| <div className="section-content"> | ||
| <div className="section-cell action-cell"> | ||
| <button | ||
| type="button" | ||
| className="action-button" | ||
| onClick={(): void => (isPinned ? undefined : onAdd())} | ||
| > | ||
| <FontAwesomeIcon | ||
| icon={isPinned ? faCheck : faPlus} | ||
| style={{ | ||
| color: '#8BD6FB', | ||
lyangji1011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }} | ||
| /> | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className="section-cell">{section.crn}</div> | ||
| <div className="section-cell">{section.id}</div> | ||
| <div className="section-cell">{meeting?.days.join('') || 'TBA'}</div> | ||
| <div className="section-cell"> | ||
| {meeting?.period | ||
| ? `${formatTime(meeting.period.start)}-${formatTime( | ||
| meeting.period.end | ||
| )}` | ||
| : 'TBA'} | ||
| </div> | ||
| <div className="section-cell"> | ||
| {formatSeatData(seatData?.inClass ?? null)} | ||
| </div> | ||
| <div className="section-cell"> | ||
| {formatSeatData(seatData?.waitlist ?? null)} | ||
| </div> | ||
| <div className="section-cell">{meeting?.where || 'TBA'}</div> | ||
| </div> | ||
| </ActionRow> | ||
| ); | ||
| } | ||
|
|
||
| export default function ProfessorInfoCard({ | ||
| professorName, | ||
| course, | ||
| }: ProfessorInfoCardProps): React.ReactElement { | ||
| const sections: Section[] = course.sections.filter((section: Section) => { | ||
| return section.instructors[0] === professorName; | ||
| }); | ||
| const [{ pinnedCrns }, { patchSchedule }] = useContext(ScheduleContext); | ||
|
|
||
| const handleAddSection = (section: Section): void => { | ||
| patchSchedule({ pinnedCrns: [...pinnedCrns, section.crn] }); | ||
lyangji1011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| return ( | ||
| <div className="ProfessorInfo"> | ||
| <div className="professor-header"> | ||
| <p className="professor-name">{professorName}</p> | ||
| </div> | ||
|
|
||
| <div className="sections-container"> | ||
| <div className="sections-header"> | ||
| <div className="header-cell" /> | ||
| <div className="header-cell">CRN</div> | ||
| <div className="header-cell">Sect.</div> | ||
| <div className="header-cell">Day</div> | ||
| <div className="header-cell">Time</div> | ||
| <div className="header-cell">Seats Filled</div> | ||
| <div className="header-cell">Waitlist</div> | ||
| <div className="header-cell">Location</div> | ||
| </div> | ||
|
|
||
| {sections.map((section) => { | ||
| return ( | ||
| <SectionRow | ||
| key={section.crn} | ||
| section={section} | ||
| term={course.term} | ||
| isPinned={pinnedCrns.includes(section.crn)} | ||
| onAdd={(): void => handleAddSection(section)} | ||
| /> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function formatTime(minutes: number): string { | ||
lyangji1011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const hours = Math.floor(minutes / 60); | ||
| const mins = minutes % 60; | ||
| const period = hours >= 12 ? 'pm' : 'am'; | ||
| const displayHours = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours; | ||
| return `${displayHours}:${mins.toString().padStart(2, '0')} ${period}`; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.