Skip to content

Add major selection to profile#501

Open
mjaydenkim wants to merge 7 commits intomainfrom
matt/add-major-to-profile
Open

Add major selection to profile#501
mjaydenkim wants to merge 7 commits intomainfrom
matt/add-major-to-profile

Conversation

@mjaydenkim
Copy link
Copy Markdown
Contributor

Summary

This PR works on a major update... haha i'm so funny...... anyway it allows users to set their major as a part of their account rather than each review individually (although reviews stay attached to the major selected at the time of publication).

New users are prompted to select their major on the review page with the same UI as before, but their selection will then attach to their account. Users shouldn't be shown the major selection dropdown otherwise as long as they continue to have a selected major and are logged in. Existing users can update their major on the profile page, where there's a dropdown menu to do so.

PR Type

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Mobile + Desktop Screenshots & Recordings

https://github.com/user-attachments/assets/88ed0c9b-105f-4a37-a8fc-bf0b5bad2a08
https://github.com/user-attachments/assets/8c0ca687-3eb0-4a21-aa40-6be17db0dfa1
majorupdate_ss1

QA - Test Plan

Tested in a variety of different account scenarios, including with accounts that have no major, accounts with many majors, etc. Tested new UIs on mobile, but there isn't a ton that's different. Couldn't test with a new account (b/c I don't have other NetIDs) but I simulated that performance essentially. Also tested to ensure that majors are still correctly tied to reviews.

Breaking Changes & Notes

  • All logged-out users are shown the major dropdown, and selecting a new major for an existing user notifies that user (via toast) and changes the major to the more recent selection.

Added to documentation?

  • 📜 README.md
  • 📓 notion
  • 🍕 ...
  • 📕 ...
  • 🙅 no documentation needed

What GIF represents this PR?

gif

Need to style, test. Also if major is being overwritten b/c a user was logged out, add a confirmation modal
Also got rid of a console log lol
@mjaydenkim mjaydenkim requested a review from a team as a code owner January 17, 2025 08:29
@dti-github-bot
Copy link
Copy Markdown
Member

dti-github-bot commented Jan 17, 2025

[diff-counting] Significant lines: 293.

Copy link
Copy Markdown
Contributor

@leihelen leihelen left a comment

Choose a reason for hiding this comment

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

This looks really good and will be a really important feature since a lot of people are turned away from posting reviews because there are so many steps to complete so this will help simplify the process! I tested the same scenarios you went through and it works well on my end as well. Maybe you could add some try catch statements when you call the api and make post requests in case of unexpected errors as well.

Copy link
Copy Markdown
Collaborator

@qiandrewj qiandrewj left a comment

Choose a reason for hiding this comment

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

Hi Matt, thank you for taking the initiative to do this (much-needed) quality of life update. The backend functions well for me, the only areas where I have some concerns are in the front-end, so let's speak to some designers so that this can become an official feature for CUReviews!

submitReview,
professorOptions
}: Modal) => {
open,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is there so much space here lol

const oldMajors = getMajorsReq.data.majors
if (oldMajors && review &&
JSON.stringify(oldMajors) !== JSON.stringify(review.major)) {
toast.info('Your major has been changed ' +
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm receiving some errors with the toast message, where it says "Your major has been changed false ..."

setValidMajor(JSON.stringify(newSelectedMajors) !== JSON.stringify(userMajors));
}

const getUserMajors = async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similarly to how the other information in UserInfo is passed in as props (so this is almost entirely a frontend/styled component), I think it would be best to retrieve the information upstream, so that all the backend calls are together

}
}

const updateMajors = async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This still makes sense to stay in the UserInfo component. However, I do think it needs a redesign because it looks clunky right now as-is

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The toast and frontend update looks smooth tho, the main thing is the button is really large and possibly in an awkward place


const updateMajors = async () => {
const response = await axios.post('/api/profiles/set-majors', { netId, majors: selectedMajors })
console.log(response)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this is user-facing, we don't want to have console.logs. In the admin page, we're a bit more lax with it because it's only for our team anyway.

<div className={styles.netid}>{netId}</div>
<div>
<div className={styles.netid}>
<span className={styles.bold}>{netId}</span>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I really like this new feature - looks clean too!

updateStudentReviews,
updateReviewLikes,
hideReportedReview
hideReportedReview, updateStudentMajors
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add a line break

getStudentMajors,
getStudentReviewDocs,
getTotalLikesByNetId
getTotalLikesByNetId, setStudentMajors
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add a line break

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.

4 participants