Skip to content

Commit

Permalink
Merge pull request #1323 from Gary-Community-Ventures/refactor/prefer…
Browse files Browse the repository at this point in the history
…red-lang

Refactor/preferred lang
  • Loading branch information
CalebPena authored Oct 3, 2024
2 parents 5733ab8 + e469a29 commit 5ef8bc1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import HouseholdDataBlock from './Components/HouseholdDataBlock/HouseholdDataBlo
import ProgressBar from './Components/ProgressBar/ProgressBar';
import JeffcoLandingPage from './Components/JeffcoComponents/JeffcoLandingPage/JeffcoLandingPage';
import LoadingPage from './Components/LoadingPage/LoadingPage.tsx';
import SelectLanguagePage from './Components/SelectLanguagePage/SelectLanguagePage.tsx';
import SelectLanguagePage from './Components/Steps/SelectLanguagePage.tsx';
import { updateScreen, updateUser } from './Assets/updateScreen.ts';
import { getStepDirectory, STARTING_QUESTION_NUMBER, getStepNumber } from './Assets/stepDirectory';
import Box from '@mui/material/Box';
Expand Down
13 changes: 13 additions & 0 deletions src/Components/ContinueButton/FormContinueButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Button } from '@mui/material';
import { PropsWithChildren } from 'react';
import { FormattedMessage } from 'react-intl';

const FormContinueButton = ({ children }: PropsWithChildren) => {
return (
<Button variant="contained" type="submit">
{children ?? <FormattedMessage id="continueButton" defaultMessage="Continue" />}
</Button>
);
};

export default FormContinueButton;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PreviousButton from '../PreviousButton/PreviousButton';
import { Button } from '@mui/material';
import { FormattedMessage } from 'react-intl';
import FormContinueButton from '../ContinueButton/FormContinueButton';
import { FormattedMessageType } from '../../Types/Questions';

type PrevAndContinueButtonsProps = {
backNavigationFunction: () => void;
Expand All @@ -10,9 +10,7 @@ const PrevAndContinueButtons = ({ backNavigationFunction }: PrevAndContinueButto
return (
<div className="question-buttons">
<PreviousButton navFunction={backNavigationFunction} />
<Button variant="contained" type="submit">
<FormattedMessage id="continueButton" defaultMessage="Continue" />
</Button>
<FormContinueButton />
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useConfig } from '../Config/configHook.tsx';
import { FormControl, Select, InputLabel, MenuItem, SelectChangeEvent, Button, Box } from '@mui/material';
import { FormControl, Select, InputLabel, MenuItem, SelectChangeEvent } from '@mui/material';
import { FormattedMessage } from 'react-intl';
import { Context } from '../Wrapper/Wrapper.tsx';
import { useContext, useEffect } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import QuestionHeader from '../QuestionComponents/QuestionHeader';
import { useQueryString } from '../QuestionComponents/questionHooks';
import QuestionHeader from '../QuestionComponents/QuestionHeader.tsx';
import { useQueryString } from '../QuestionComponents/questionHooks.ts';
import FormContinueButton from '../ContinueButton/FormContinueButton.tsx';

const SelectLanguagePage = () => {
const { locale, selectLanguage } = useContext(Context);
Expand Down Expand Up @@ -46,6 +47,14 @@ const SelectLanguagePage = () => {
};
});

const handleSubmit = () => {
if (uuid !== undefined) {
navigate(`/${uuid}/step-2${queryString}`);
return;
}
navigate(`/step-2${queryString}`);
};

return (
<main className="benefits-form">
<QuestionHeader>
Expand All @@ -54,35 +63,28 @@ const SelectLanguagePage = () => {
<h2 className="sub-header-language-select">
<FormattedMessage id="selectLanguage.subHeader" defaultMessage="What is your preferred language?" />
</h2>
<FormControl sx={{ width: '150px' }}>
<InputLabel id="language-select-label">
<FormattedMessage id="selectLang.text" defaultMessage="Language" />
</InputLabel>
<Select
labelId="language-select-label"
id="language-select"
value={locale}
label={<FormattedMessage id="selectLang.text" defaultMessage="Language" />}
//@ts-ignore
onChange={(event: SelectChangeEvent<string>) => selectLanguage(event)}
>
{createMenuItems(languageOptions, 'selectLang.disabledSelectMenuItemText', 'Select a language')}
</Select>
</FormControl>
<Box sx={{ mt: '1rem' }}>
<Button
variant="contained"
onClick={() => {
if (uuid !== undefined) {
navigate(`/${uuid}/step-2${queryString}`);
return;
}
navigate(`/step-2${queryString}`);
}}
>
<FormattedMessage id="continueButton-getStarted" defaultMessage="Get Started" />
</Button>
</Box>
<form onSubmit={handleSubmit}>
<FormControl sx={{ width: '150px' }}>
<InputLabel id="language-select-label">
<FormattedMessage id="selectLang.text" defaultMessage="Language" />
</InputLabel>
<Select
labelId="language-select-label"
id="language-select"
value={locale}
label={<FormattedMessage id="selectLang.text" defaultMessage="Language" />}
//@ts-ignore
onChange={(event: SelectChangeEvent<string>) => selectLanguage(event)}
>
{createMenuItems(languageOptions, 'selectLang.disabledSelectMenuItemText', 'Select a language')}
</Select>
</FormControl>
<div style={{ marginTop: '1rem' }}>
<FormContinueButton>
<FormattedMessage id="continueButton-getStarted" defaultMessage="Get Started" />
</FormContinueButton>
</div>
</form>
</main>
);
};
Expand Down

0 comments on commit 5ef8bc1

Please sign in to comment.