Skip to content

Commit

Permalink
Refactor FormContinueButton to use Continue text if children are not …
Browse files Browse the repository at this point in the history
…passed
  • Loading branch information
ivonne-hernandez committed Oct 2, 2024
1 parent 7e126cf commit e469a29
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/Components/ContinueButton/FormContinueButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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}
{children ?? <FormattedMessage id="continueButton" defaultMessage="Continue" />}
</Button>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { FormattedMessageType } from '../../Types/Questions';

type PrevAndContinueButtonsProps = {
backNavigationFunction: () => void;
formContinueButtonFM: FormattedMessageType;
};

const PrevAndContinueButtons = ({ backNavigationFunction, formContinueButtonFM }: PrevAndContinueButtonsProps) => {
const PrevAndContinueButtons = ({ backNavigationFunction }: PrevAndContinueButtonsProps) => {
return (
<div className="question-buttons">
<PreviousButton navFunction={backNavigationFunction} />
<FormContinueButton formattedMessage={formContinueButtonFM} />
<FormContinueButton />
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Steps/SelectLanguagePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const SelectLanguagePage = () => {
{createMenuItems(languageOptions, 'selectLang.disabledSelectMenuItemText', 'Select a language')}
</Select>
</FormControl>
<div style={{marginTop: '1rem'}}>
<div style={{ marginTop: '1rem' }}>
<FormContinueButton>
<FormattedMessage id="continueButton-getStarted" defaultMessage="Get Started" />
</FormContinueButton>
Expand Down
5 changes: 1 addition & 4 deletions src/Components/Steps/ZipcodeStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ export const ZipcodeStep = () => {
</FormControl>
</div>
)}
<PrevAndContinueButtons
backNavigationFunction={backNavigationFunction}
formContinueButtonFM={<FormattedMessage id="continueButton" defaultMessage="Continue" />}
/>
<PrevAndContinueButtons backNavigationFunction={backNavigationFunction} />
</form>
</div>
);
Expand Down

0 comments on commit e469a29

Please sign in to comment.