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

Update email when linking respondent #2426

Merged
merged 7 commits into from
Dec 20, 2024
Merged

Conversation

rebecarubio
Copy link
Contributor

Description

This PR adds a dialog to allow the user to add the respondent email to the person that is going to be link as a new respondent.
It also introduces a new extra reducer in the Survey store that updates de submission list when a person is updated.

Screenshots

Video.sin.titulo.Hecho.con.Clipchamp.1.mp4

Changes

  • Adds an if statement in SurveySubmissionsList when a person to be linked as a respondent doesn't have an email
  • Adds a SurveyDialogLink component to display a Dialog when the if statement is triggered
  • Adds an extra reducer in Survey store to update the submissions list when personUpdated action is triggered.

Notes to reviewer

None

Related issues

Resolves #2269

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

Nice work! I've seen this work on your screen and I thought it looked great. But then at first I couldn't get it to work for me. Here's what I tried:

  1. With the preview build, I went to "Simon Zetterlund" and removed his email. Note that this sets the email to an empty string, which is probably the cause of this bug.
  2. I then went to this survey submissions list where there is a submission made using my email address.
  3. I tried linking the submission to Simon Zetterlund, which works, but the modal does not open.

I then tried creating a new person instead of using an existing one, and not setting an email to begin with, which does work. It probably works because the email will be null.

I also think that it would be nice to get a designer to look at the modal. Maybe you can just pair up with someone in the office?

Finally, I left a bunch of comments below. The code looks mostly great, but there are some minor things that I think can be improved, and also some that I identified as a learning opportunity – hopefully appreciated. 😊

src/features/surveys/store.ts Show resolved Hide resolved
src/features/surveys/components/SurveySubmissionsList.tsx Outdated Show resolved Hide resolved
src/features/surveys/components/SurveySubmissionsList.tsx Outdated Show resolved Hide resolved
src/features/surveys/components/SurveyDialogLink.tsx Outdated Show resolved Hide resolved
src/features/surveys/components/SurveySubmissionsList.tsx Outdated Show resolved Hide resolved
src/features/surveys/components/SurveySubmissionsList.tsx Outdated Show resolved Hide resolved
src/features/surveys/components/SurveySubmissionsList.tsx Outdated Show resolved Hide resolved
…se to check person object, change strict operators for non strict, use setDialogPerson for onClose function
Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

Nice work! Let's get this merged. 💯

Comment on lines +207 to +209
if (person) {
const personHasNoEmail = person.email == null || person.email == '';
if (personHasNoEmail && respondentEmail != undefined) {
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 this is much nicer! I believe it could have been made even simpler, by relying on the fact that null and undefined are falsy, like so:

Suggested change
if (person) {
const personHasNoEmail = person.email == null || person.email == '';
if (personHasNoEmail && respondentEmail != undefined) {
if (person) {
const personHasNoEmail = !person.email || person.email == '';
if (personHasNoEmail && respondentEmail) {

But that's not worth changing the code over!

@richardolsson richardolsson merged commit 9511c8d into main Dec 20, 2024
6 checks passed
@richardolsson richardolsson deleted the issue-2269/add-email-address branch December 20, 2024 07:52
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.

Add missing email address when linking survey response
3 participants