-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9919 Add geographic location to account preferences #1978
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
base: main
Are you sure you want to change the base?
Changes from all commits
e0232dc
0bced31
f8938cc
4748de1
8eb2f44
76d8433
d656d99
1f893a0
15f131a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |||||
| import { Alert, Box, Divider, Link, Stack, Typography } from '@mui/material'; | ||||||
| import { useSnackbar } from 'notistack'; | ||||||
| import { useTranslation } from 'react-i18next'; | ||||||
| import { useGetAccountPreferencesQuery } from 'src/components/Settings/preferences/GetAccountPreferences.generated'; | ||||||
| import { useUpdateAccountPreferencesMutation } from 'src/components/Settings/preferences/accordions/UpdateAccountPreferences.generated'; | ||||||
| import { Confirmation } from 'src/components/Shared/Modal/Confirmation/Confirmation'; | ||||||
| import { useAccountListId } from 'src/hooks/useAccountListId'; | ||||||
| import { BackButton } from '../Shared/BackButton'; | ||||||
|
|
@@ -30,74 +32,116 @@ | |||||
| incompleteSteps.includes(section.step), | ||||||
| ); | ||||||
|
|
||||||
| const { data } = useGetAccountPreferencesQuery({ | ||||||
| variables: { | ||||||
| accountListId, | ||||||
| }, | ||||||
| }); | ||||||
| const [updateAccountPreferences] = useUpdateAccountPreferencesMutation(); | ||||||
|
|
||||||
| const updateGeographicLocation = | ||||||
| data?.accountList?.settings?.geographicLocation !== | ||||||
| questionnaire?.geographicLocation; | ||||||
|
|
||||||
| // Complete the questionnaire, then redirect to the dashboard on success. | ||||||
| const handleSubmit = async () => { | ||||||
| await completeQuestionnaire(); | ||||||
|
|
||||||
| if (updateGeographicLocation) { | ||||||
| updateAccountPreferences({ | ||||||
| variables: { | ||||||
| input: { | ||||||
| id: accountListId, | ||||||
| attributes: { | ||||||
| id: accountListId, | ||||||
| settings: { | ||||||
| geographicLocation: questionnaire?.geographicLocation, | ||||||
| }, | ||||||
| }, | ||||||
| }, | ||||||
| }, | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| enqueueSnackbar(t('Questionnaire submitted successfully.'), { | ||||||
| variant: 'success', | ||||||
| }); | ||||||
| await router.push(`/accountLists/${accountListId}`); | ||||||
| }; | ||||||
|
|
||||||
| const message = ( | ||||||
| <> | ||||||
| {t( | ||||||
| "Once you submit, you won't be able to make any more changes. Do you want to continue?", | ||||||
| )} | ||||||
| {updateGeographicLocation && ( | ||||||
| <Alert severity="info" sx={{ mt: 2 }}> | ||||||
| {t( | ||||||
| 'Your geographic location will be updated as {{geographicLocation}} in your account settings.', | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about "updated to"?
Suggested change
|
||||||
| { geographicLocation: questionnaire?.geographicLocation }, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know you're still working out how to handle the None option, but I assume you'll want a fallback value here and in the other alerts and notifications.
Suggested change
|
||||||
| )} | ||||||
| </Alert> | ||||||
| )} | ||||||
| </> | ||||||
| ); | ||||||
|
|
||||||
| return ( | ||||||
| <NsoMpdQuestionnaireLayout> | ||||||
| <Box mx={4} my={2}> | ||||||
| <Stack spacing={2}> | ||||||
| <Typography variant="h5">{t('Summary')}</Typography> | ||||||
| <Typography variant="body1"> | ||||||
| {t( | ||||||
| 'Please review your information below, then select Submit to finish. Once submitted, you will be redirected to the dashboard and will not be able to make any further changes.', | ||||||
| )} | ||||||
| </Typography> | ||||||
| </Stack> | ||||||
| <Divider sx={{ mx: -4, my: 4 }} /> | ||||||
| <Stack spacing={4}> | ||||||
| {sections.map((section) => ( | ||||||
| <SummarySection | ||||||
| key={section.title} | ||||||
| title={section.title} | ||||||
| rows={section.rows} | ||||||
| onEdit={() => handleStepChange(section.step)} | ||||||
| /> | ||||||
| ))} | ||||||
| </Stack> | ||||||
| </Box> | ||||||
|
|
||||||
| {!canSubmit && ( | ||||||
| <Alert severity="error" sx={{ mx: 4, '& ul': { m: 0, pl: 3 } }}> | ||||||
| {t('Your form is missing information.')} | ||||||
| <ul> | ||||||
| {incompleteSections.map((section) => ( | ||||||
| <li key={section.step}> | ||||||
| <Link | ||||||
| component="button" | ||||||
| type="button" | ||||||
| onClick={() => handleStepChange(section.step)} | ||||||
| > | ||||||
| {section.title} | ||||||
| </Link> | ||||||
| </li> | ||||||
| ))} | ||||||
| </ul> | ||||||
| </Alert> | ||||||
| )} | ||||||
|
|
||||||
| <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} mx={4}> | ||||||
| <BackButton onClick={handleBack} /> | ||||||
| <QuestionnaireActionButton | ||||||
| onClick={() => setConfirmOpen(true)} | ||||||
| disabled={!canSubmit} | ||||||
| > | ||||||
| {t('Submit')} | ||||||
| </QuestionnaireActionButton> | ||||||
| </Stack> | ||||||
|
|
||||||
| <Confirmation | ||||||
| isOpen={confirmOpen} | ||||||
| title={t('Submit Questionnaire')} | ||||||
| message={t( | ||||||
| "Once you submit, you won't be able to make any more changes. Do you want to continue?", | ||||||
| )} | ||||||
| message={message} | ||||||
|
Check warning on line 144 in src/components/HrTools/NsoMpdQuestionnaire/Summary/Summary.tsx
|
||||||
| confirmLabel={t('Submit')} | ||||||
| cancelLabel={t('Cancel')} | ||||||
| mutation={handleSubmit} | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.