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

Create password page #95

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Create password page #95

wants to merge 13 commits into from

Conversation

AbeerDas
Copy link
Collaborator

@AbeerDas AbeerDas commented Feb 4, 2025

Notion Ticket Link

Create Password Design Implementation

Figma File


Implementation Description

  • Confirmed with Carolyn that the backend logic is already handled, so this PR focuses solely on design implementation.
  • Implemented the designs for the Create Password page and the Confirmation page.
    • These are the pages respectively:

image
image

  • Added the Help Modal specifically for the "Learner" role.
    • This is the button:

image

  • These are the modals:

image
image

  • Added new requirements and checks since the creation of the ticket:
    • An eye icon to toggle password visibility.
    • An additional condition to ensure the Confirm Password matches the initial password.
  • Updated button hover colors used to be lighter colours, now it should be the darker

Steps to Test

  1. Log in as a Learner (You can confirm you are a learner because the new homepage navbar changes based on your user type)
  2. Navigate to /create-password.
  3. Test the password conditions:
    • Ensure the cross icon changes to a checkmark as each condition is met (e.g., 8 characters, one uppercase letter, etc.).
  4. Verify that button colors match the role (e.g., blue for Learners).
  5. Open the Help Modal and compare it to the Figma designs.
  6. Double-check button colors on the modal.
  7. Click Next to proceed to the Confirmation Page.
  8. Go back and create a password that meets all conditions.
  9. Confirm that the Confirmation Page appears after successful password creation.
  10. Log in as an Admin (check if homepage navbar colour is orange)
  11. Verify that the button color is dark orange.
  12. Ensure the Help Button does not appear for Admins.
  13. Test all functionality as an Admin (since the code is shared, it should behave the same as for Learners).
  14. If everything works as expected, then we are chilling

What should reviewers focus on?

  • The coded designs were reviewed by Gaurav very quickly so more than that we are mainly focused on the code
    *** * Is the code formatted proeprly? Let us know where additional changes could be made

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

Copy link

github-actions bot commented Feb 4, 2025

Visit the preview URL for this PR (updated for commit c85b5c2):

https://extendafamily-7613e--pr95-create-password-page-wlip7tb8.web.app

(expires Sun, 16 Feb 2025 04:23:09 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f8bb7b5cd838ab636347dc54fd0ab08ab3715d31

@carolynzhang18
Copy link
Collaborator

image
image

changing the colours for Hover in theme.ts breaks the Hover colours used elsewhere (which match the specs in the figma file) :O

from what I see in our colour palette, the ordering from lightest to darkest is Light < Hover < Default < Pressed... I'm thinking we'll want to use Pressed to achieve a darker colour for the hover effect.

we should confirm the palette with Gaurav again :D

Copy link
Collaborator

@carolynzhang18 carolynzhang18 left a comment

Choose a reason for hiding this comment

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

SUPER AMAZING WORK EVERYTHING WORKS WELL!!! 🧑‍🍳🧑‍🍳

I left a few minor comments :D A summary of the more important ones:

  • If a user is on the Create Password Page, this means they are a newly invited Admin or Learner that just logged in for the first time. So, after creating their password, they can be sent directly to the HOME_PAGE.
  • The original functionality in the onSubmitNewPasswordClick event handler of the Create Password Page needs to be kept! This ensures the user's new password actually makes it to our backend, etc. Could the previous logic be restored?

We can discuss more at the work session if needed :)

frontend/package-lock.json Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's a similar image frontend/src/assets/logoColoured.png already! would it be possible to use that instead?
image

Comment on lines 10 to 13
Light: "#F5FDFF",
Hover: "#CCF5FF",
Hover: "#005566",
Default: "#006877",
Pressed: "#00363F",
Copy link
Collaborator

Choose a reason for hiding this comment

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

we probably want to keep these colours as is and just use the Pressed variant as the darker shade? this might be a Gaurav question :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing this file is for testing? 😃
I should have mentioned in the ticket there are /inviteLearner and /inviteAdmin routes available for you to invite new users - my bad!
what you have here works too, just remember to remove it before merging :))

Comment on lines +51 to +72
useEffect(() => {
validatePassword(newPassword);
}, [newPassword]);

useEffect(() => {
const passwordsMatch =
newPassword === confirmPassword && newPassword.trim() !== "";

setPasswordCriteria((prev) => ({
...prev,
passwordsMatch,
}));

const isValid =
passwordCriteria.minLength &&
passwordCriteria.uppercase &&
passwordCriteria.lowercase &&
passwordCriteria.specialChar &&
passwordsMatch;

onValidationChange(isValid);
}, [newPassword, confirmPassword, passwordCriteria, onValidationChange]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: instead of having these as useEffects, you can move the logic in each into its own event handler:
function handleNewPasswordChange(newPassword) { ... }
function handleConfirmPasswordChange(confirmPassword) { ... }

and fire these in the onChange event of the respective input fields
(I can show you what I mean at the next work session if this doesn't make sense!)

functionality-wise shouldn't make a difference, but I believe it's better practice to use event handlers instead of useEffects when possible - https://react.dev/learn/keeping-components-pure#recap

Comment on lines -17 to -45
const onSubmitNewPasswordClick = async () => {
const changePasswordSuccess = await AuthAPIClient.updateTemporaryPassword(
authenticatedUser.email,
newPassword,
authenticatedUser.role,
);
if (!changePasswordSuccess) {
setAuthenticatedUser(null);
localStorage.removeItem(AUTHENTICATED_USER_KEY);
await AuthAPIClient.logout(authenticatedUser.id);
const theme = useTheme();

// change this later to not use an alert
const onSubmitNewPasswordClick = () => {
if (isFormValid) {
setIsPasswordConfirmed(true);
} else {
// eslint-disable-next-line no-alert
alert("Error occurred when changing your password. Please log in again.");
return;
alert("Passwords do not match or do not meet the criteria.");
}
};

const updateStatusSuccess = await AuthAPIClient.updateUserStatus("Active");
if (!updateStatusSuccess) {
// change this later to not use an alert
// eslint-disable-next-line no-alert
alert('Failed to update user status to "Active"');
return;
}
const handleOpenHelpModal = () => setIsHelpModalOpen(true);
const handleCloseHelpModal = () => setIsHelpModalOpen(false);

setAuthenticatedUser({
...authenticatedUser,
status: "Active",
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should keep the existing logic in onSubmitNewPasswordClick (the red stuff above that was deleted) - this includes the API calls to update the user's password + to update the user's status + to update the authenticatedUser that we need to make the update work :)

variant="headlineLarge"
gutterBottom
sx={{
fontWeight: theme.typography.headlineLarge?.fontWeight,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this line is likely redundant - variant="headlineLarge" should plop the entire style definition, including the fontWeight, of headlineLarge

Comment on lines +70 to +73
fontSize: theme.typography.headlineMedium.fontSize,
fontStyle: "normal",
fontWeight: theme.typography.headlineMedium.fontWeight,
lineHeight: theme.typography.headlineMedium.lineHeight,
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can do <Typography variant="headlineMedium" ... and you won't need to write out each of these as styles separately :)

const history = useHistory();
const theme = useTheme();
const handleBackToHome = () => {
user.status = "Active";
Copy link
Collaborator

Choose a reason for hiding this comment

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

need to change the user's status on the database itself to active because it'll just stay as invited :(

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