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

Add new Button on Course Page to Add Course to Planner #3731

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

EssWhyy
Copy link
Contributor

@EssWhyy EssWhyy commented May 31, 2024

Context

Implementation for #3399

Implementation

Added a button to each module page to allow a user to save the module to the planner in the Plan to Take section, acting like a save button of sorts.

If it is already added to Plan To Take, the button will remove the module from there instead.

Test Run:

31.05.2024_16.53.21_REC.mp4

Other Information

Copy link

vercel bot commented May 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nusmods-export ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2024 4:05pm
nusmods-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2024 4:05pm

Copy link

vercel bot commented May 31, 2024

@EssWhyy is attempting to deploy a commit to the modsbot's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 51.21951% with 20 lines in your changes missing coverage. Please review.

Project coverage is 53.62%. Comparing base (7334b07) to head (884b76b).
Report is 16 commits behind head on master.

Files Patch % Lines
.../views/components/module-info/SaveModuleButton.tsx 48.71% 20 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3731   +/-   ##
=======================================
  Coverage   53.62%   53.62%           
=======================================
  Files         272      273    +1     
  Lines        5979     6020   +41     
  Branches     1428     1437    +9     
=======================================
+ Hits         3206     3228   +22     
- Misses       2773     2792   +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ravern ravern left a comment

Choose a reason for hiding this comment

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

Have verified that this works! Thanks for your contribution.

The code looks good, full props (pun intended) for following the current style of the surrounding components.

This is completely optional, but it would be a nice-to-have if we could create new components in the functional style instead of class style — I would like to slowly move the codebase towards this pattern.

The specific code comments are just nits, and I would still merge them in if you don't touch the code referenced in those comments.

I'm requesting changes only because of the component name, which I believe could be more specific than SaveModuleButton. Something that references the planner / plan-to-take action might be better.

Comment on lines +31 to +35
for (let i = 0; i < planToTakeModules.length; i++) {
if (planToTakeModules[i].moduleCode === module.moduleCode) {
return true;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use a .some call here instead?

e.g. planToTakeModules.some(m => m.moduleCode === module.moduleCode)

Comment on lines +42 to +46
for (let i = 0; i < planToTakeModules.length; i++) {
if (planToTakeModules[i].moduleCode === module.moduleCode) {
return planToTakeModules[i].id;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use a .find call here instead?

e.g. planToTakeModules.find(m => m.moduleCode === module.moduleCode)?.id ?? '0'

Comment on lines +68 to +69
const PLAN_TO_TAKE_YEAR = '3000';
const PLAN_TO_TAKE_SEMESTER = -2;
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for us to import these constants from `src/utils/planner.ts' instead?

Or better yet, create a new function that more accurately represents what this code is trying to do, i.e., add a module so far into the future that it will definitely be in the "plan to take" section (correct me if this not what the code is trying to do)?

Comment on lines +23 to +34
.dropdownItem {
text-align: center;
white-space: normal;

br {
display: none;
}

strong {
font-size: 1em;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems to be unused?

Comment on lines +12 to +20
:global(.dropdown-toggle.dropdown-toggle-split) {
width: 2rem;
border-left: none;

@include media-breakpoint-down(sm) {
// Long selector for specificity
width: 3rem;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Global seems like quite a large scope, do you know if this styling is actually applied on the button?

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.

3 participants