-
Notifications
You must be signed in to change notification settings - Fork 59
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4bc9d31
add check to trigger handleUpdateEmail()
rebecarubio 007e246
add surveySubmissionsList component and implement it
rebecarubio c247300
add a new extraReducer to update the submissionsList when person is u…
rebecarubio 0bb1c95
rename component to SurveyLinkDialog
rebecarubio c9cf87c
remove handleUpdateEmail function, remove dialogOpen state, add if ca…
rebecarubio 5a564c7
polish style and fix sentence
rebecarubio 1c76b73
fix sentence after designer feedback
rebecarubio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { ArrowForward } from '@mui/icons-material'; | ||
import { | ||
Box, | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogTitle, | ||
Divider, | ||
Typography, | ||
} from '@mui/material'; | ||
|
||
import messageIds from '../l10n/messageIds'; | ||
import { useNumericRouteParams } from 'core/hooks'; | ||
import { useMessages } from 'core/i18n'; | ||
import usePersonMutations from 'features/profile/hooks/usePersonMutations'; | ||
import { ZetkinPerson } from 'utils/types/zetkin'; | ||
import ZUIPersonAvatar from 'zui/ZUIPersonAvatar'; | ||
|
||
const SurveyLinkDialog = ({ | ||
email, | ||
onClose, | ||
open, | ||
person, | ||
}: { | ||
email: string; | ||
onClose: () => void; | ||
open: boolean; | ||
person: ZetkinPerson; | ||
}) => { | ||
const messages = useMessages(messageIds); | ||
const { orgId } = useNumericRouteParams(); | ||
const { updatePerson } = usePersonMutations(orgId, person.id); | ||
|
||
return ( | ||
<Dialog open={open}> | ||
<DialogTitle>{messages.surveyDialog.title()}</DialogTitle> | ||
<Divider /> | ||
<DialogContent> | ||
<Box alignItems="center" display="flex" mb={2}> | ||
{email} | ||
<Box alignItems="center" display="flex" ml={2} mr={2}> | ||
<ArrowForward | ||
color="secondary" | ||
sx={{ | ||
opacity: '50%', | ||
}} | ||
/> | ||
</Box> | ||
<ZUIPersonAvatar orgId={orgId} personId={person?.id ?? 0} size="sm" /> | ||
<Typography ml={2} variant="h6"> | ||
{person?.first_name} {person?.last_name} | ||
</Typography> | ||
</Box> | ||
{messages.surveyDialog.description()} | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={onClose} variant="outlined"> | ||
{messages.surveyDialog.cancel()} | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
updatePerson({ email }); | ||
onClose(); | ||
}} | ||
variant="contained" | ||
> | ||
{messages.surveyDialog.add()} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default SurveyLinkDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
andundefined
are falsy, like so:But that's not worth changing the code over!