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 a SearchSelectorField to replace the current SelectorField for adding skills #663

Merged
merged 5 commits into from
Aug 30, 2022

Conversation

twilkhoo
Copy link
Contributor

@twilkhoo twilkhoo commented Aug 28, 2022

Ticket link

Closes #502

Implementation description

  • Added a new component, "SearchSelectorField"
  • The component allows users to type and select existing skills, but also allows them to add new skills
  • New user-added skills are first stored in a set, from which if they are deleted (volunteer changes their mind), they are removed from the set
  • Skills are only added to the db when user submits

Steps to test

  1. Login as any user and edit profile
  2. Add skills using the new SearchSelectorField component, which includes selecting existing skills and creating new ones
  3. Save changes, if testing with the firebase hosting link you may get an authentication error since backend changes don't show in the preview
  4. To verify the skills are saved to the db, you can run the contents of this branch locally

What should reviewers focus on?

  • Ensure that the component works as expected
  • Please pay attention to minor details too: if a user types a skill that already exists, the option to add that skill disappears. The user input is formatted to titlecase (and trimmed). Clicking in the dropdown keeps the dropdown open, but clicking outside closes it.
  • Lmk if there's anything that can be made more intuitive

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

@github-actions
Copy link

github-actions bot commented Aug 28, 2022

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

https://sistering-dev--pr663-tejas-update-skills-fgu5cep8.web.app

(expires Mon, 05 Sep 2022 22:18:41 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

currentLanguages.filter((l) => l.id !== language),
);
};

const createAccount = (values: CreateAccountFormValues): void => {
if (onVolunteerCreate && onEmployeeCreate) {
if (isAdmin) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could someone double-check this part? In editAccount, we set branches: [], but that effectively deletes the branches that were assigned to the user. I've verified this with prisma studio, seems like a bug?

Copy link
Member

Choose a reason for hiding this comment

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

hmm I need to look into this. I've don't think I've ever encountered this bug on staging though

Copy link
Member

Choose a reason for hiding this comment

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

wait yea, I think I get the bug. Definitely worth fixing since it's big impact. I'll file a ticket for it.

Copy link
Member

Choose a reason for hiding this comment

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

I think I can quickly take care of this.

Copy link
Member

Choose a reason for hiding this comment

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

#665 PR up

const newSkillsArr: string[] = Array.from(addedSkills);
const newSkillsInDB: SkillResponseDTO[] = [];

for (let i = 0; i < newSkillsArr.length; i += 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

forEach doesn't work with await as intended, and for ... of is restricted.

@twilkhoo twilkhoo marked this pull request as draft August 28, 2022 22:23
@twilkhoo twilkhoo marked this pull request as ready for review August 28, 2022 22:44
Copy link
Member

@MatoPlus MatoPlus left a comment

Choose a reason for hiding this comment

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

Woah, good job with the custom component. It definitely seemed non-trivial as expected. I'll try to take a closer look sometime tmw.

tooltip={<Text>Search and select skills you have.</Text>}
onSelect={(skill) =>
selectSkill(skill, values.skills, setFieldValue)
}
onDeselect={(skill) =>
deselectSkill(skill, values.skills, setFieldValue)
}
onCreateNewOption={(newSkill) => addNewSkill(newSkill)}
onDeleteNewOption={(newSkill) => deleteNewSkill(newSkill)}
/>
)}
<SelectorField
Copy link
Member

Choose a reason for hiding this comment

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

@twilkhoo it would be really nice to have this for languages as well. Do you think it'll be difficult to include that in this PR as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was thinking that too! I'm planning to add the language field changes in a separate PR though after this one gets submitted for organization.

Copy link
Member

@MatoPlus MatoPlus left a comment

Choose a reason for hiding this comment

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

Another edge case:

We can't add any skills that are all caps/acronym. I think this is fine though imo since we don't want to give end users too much freedom to add "unknown" acronyms

image

Copy link
Member

@MatoPlus MatoPlus left a comment

Choose a reason for hiding this comment

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

Made some suggestions, interested in your thoughts. Very impressed with the custom component overall 😤

twilkhoo and others added 2 commits August 29, 2022 18:09
Co-authored-by: Rickson Yang <44826218+MatoPlus@users.noreply.github.com>
@twilkhoo
Copy link
Contributor Author

Regarding the acronyms comment, I suppose that is a limitation with converting everything to title case. If we were to avoid converting to title case however, we would likely have lots of case differences in the db (some users may enter things all lowercase, some all uppercase, etc.). Due to this, I think that keeping the title case conversion outweighs the downsides.

Copy link
Member

@MatoPlus MatoPlus left a comment

Choose a reason for hiding this comment

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

LGTM, awesome work!

@twilkhoo twilkhoo deleted the tejas/update-skills-field branch August 30, 2022 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update skills field to search field that creates new skills if not exist
2 participants