Skip to content
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

Catalog dashboard page updates #760

Merged
merged 11 commits into from
Jan 26, 2025
Merged

Catalog dashboard page updates #760

merged 11 commits into from
Jan 26, 2025

Conversation

ARtheboss
Copy link

Need help checking two things:

  • Switch terms on the catalog dashboard page and bookmark on class page in catalog are disabled. For some reason, react disable={false} causes the disabled attribute to still be there on my local machine (with value "false"), when it should be removed.
  • Sign in to add bookmark, verify it appears on Dashboard

Will integrate "View all" bookmark button with profile once both these branches are merged

@ARtheboss ARtheboss requested a review from mathhulk January 15, 2025 15:36
) : (
<div
className={styles.root}
onClick={() => onSelect(subject, courseNumber, number)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using an onClick event, you can just use a link:

<Link to={`/catalog/${year}/${semester}/${subject}/${courseNumber}/${number}`}>
  ...
</Link>

You could also instead use a ClassDialog for minimal impact on navigation:

<ClassDialog
  year={year}
  semester={semester}
  subject={subject}
  courseNumber={courseNumber}
  number={number}
>
  ...
</ClassDialog>

Copy link
Author

Choose a reason for hiding this comment

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

I couldn't find a ClassDialog component, so using Link instead

</p>
{term.startDate && term.endDate ? (
<p className={styles.paragraph}>
{formatDate(new Date(term.startDate))} through{" "}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using a custom formatDate function, I've already installed and imported Moment.js elsewhere that you can use:

{moment(term.startDate).format("MMMM Do")}

</Carousel>
{recents.length == 0 ? (
<></>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove unnecessary fragments by using a logical AND:

{recents.length > 0 && (...)}

@@ -232,6 +234,14 @@ export default function Class({
// TODO: Error state
if (!course || !_class || !pin) {
return <></>;
} else {
addToRecent({
Copy link
Contributor

Choose a reason for hiding this comment

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

Right now, addToRecent will be called on every render. You should instead use a useEffect for this:

useEffect(() => {
    if (!course || !_class) return;

    addToRecent({
      subject: _class.subject,
      year: _class.year,
      semester: _class.semester,
      courseNumber: _class.courseNumber,
      number: _class.number,
    });
}, [course, _class]);

@@ -254,7 +264,7 @@ export default function Class({
[styles.active]: bookmarked,
})}
onClick={() => bookmark()}
disabled={userLoading}
disabled={userLoading} // setting disabled to false still appears on my version
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bug I will address!

Copy link
Author

Choose a reason for hiding this comment

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

There's a similar bug with the switch term select on the Dashboard component. It sets data-disabed="false" which disables the select

newRcd.number == rcd.number),
false
);
if (alreadyExists) return;
Copy link
Contributor

@mathhulk mathhulk Jan 20, 2025

Choose a reason for hiding this comment

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

It might be nice to move the class to the back of the array if it already exists and limit the recently viewed list to n number of classes.

@mathhulk mathhulk marked this pull request as draft January 20, 2025 02:36
@mathhulk mathhulk marked this pull request as ready for review January 26, 2025 19:39
@mathhulk mathhulk merged commit 31ae68f into gql Jan 26, 2025
1 check passed
@mathhulk mathhulk deleted the gql-catalog branch January 26, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants