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

Refactor some user invite code #514

Merged
merged 8 commits into from
Sep 4, 2024

Conversation

alex-yau-ttd
Copy link
Contributor

@alex-yau-ttd alex-yau-ttd commented Sep 2, 2024

Why?

#516 will be changing the functionality to allow user invitations to still work when the user already belongs to another participant. I'm doing this refactoring to make it easier for me to add that functionality as well as make it easier to be reviewed.

What?

  • There are no functional changes.
  • Rename a function to avoid confusion with an upcoming function to send an invite to an existing user
  • Split out the handler for inviting a new participant/user to participantsUsers.ts
  • Extract a method out of the handler for creating a new participant. This started as more of an exercise but figured it was still worth merging.
  • Wrapper method to assign keycloak user role. It's the only role we use today anyway.
  • Remove an unused file

## Why?
I'm about to change the functionality to allow user invitations to still work when the user already belongs to another participant. I'm doing this refactoring to make it easier for me to add that functionality as well as make it easier to be reviewed.

## What?
- Rename a function to avoid confusion with an upcoming function to send an invite to an existing user
- Split out the handler for inviting a new participant/user to participantsUsers
- Break down the handler for creating a new participant
@@ -210,7 +202,7 @@ export function createParticipantsRouter() {
}
);

participantsRouter.put('/', createParticipant);
participantsRouter.put('/', handleCreateParticipant);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed because I split the handler into two functions, one of which is called createParticipant

}
}
);
participantsRouter.post('/:participantId/invite', handleInviteUserToParticipant);
Copy link
Contributor Author

@alex-yau-ttd alex-yau-ttd Sep 2, 2024

Choose a reason for hiding this comment

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

extracted this out - functionality is the same (will be changed in a subsequent PR)

We only have the one keycloak user role, so extracted into it's own method and constant, so we have less magic strings.
My alt+shift+O command removed them. Saving the file added them back
@alex-yau-ttd alex-yau-ttd merged commit 131a9f3 into main Sep 4, 2024
3 checks passed
@alex-yau-ttd alex-yau-ttd deleted the ajy-UID2-3878-Refactor-some-user-invite-code branch September 4, 2024 03:29
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