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

EHPR-230 Added delete functionality to each specialty row #165

Merged
merged 3 commits into from
Mar 18, 2022

Conversation

dbayly-freshworks
Copy link
Collaborator

See post on slack for video on functionality

@@ -124,6 +124,8 @@ export const Credential: React.FC = () => {
index={index}
specialties={specialtyOptions}
subspecialties={subspecialties?.[index]}
deleteFunction={() => arrayHelpers.remove(index)}
enableDelete={specialties.length > 1}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The delete function handles the removal of the specialty.
The enable delete determines whether of not the delete button is shown.

I put them at a higher level and pass them down into the component to keep the SpecialtySelector component generic and because otherwise I would need to pass the specialties array and arrayHelper function into the component.

<button
type='button'
className='text-bcRedError'
aria-label='delete the last specialty'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now should it be n-th specialty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! i will update this

@@ -221,6 +212,16 @@ const SpecialtySelector: React.FC<SpecialtySelectorProps> = ({
/>
))}
</Select>
{enableDelete ? (
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we want disallow deleting the last specialty, can we just check if index is 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We want to make sure that you can delete any specialty selection, unless there is only one left.

@sonarcloud
Copy link

sonarcloud bot commented Mar 18, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dbayly-freshworks dbayly-freshworks merged commit 7004c88 into main Mar 18, 2022
@dbayly-freshworks dbayly-freshworks deleted the EHPR-230_specialty_deletion_bug branch March 18, 2022 17:00
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