Skip to content
Permalink
Browse files

[DDW-588] Adds preselectedLanguage prop to LanguageSelectionForm

  • Loading branch information...
MarcusHurney committed Mar 15, 2019
1 parent c010e43 commit ef72131ceddf24e2782ab8652bdeb2d7f38f5df9
@@ -29,6 +29,7 @@ type Props = {
languages: Array<{ value: string, label: ReactIntlMessage }>,
onSubmit: Function,
isSubmitting: boolean,
preselectedLanguage: string,
error?: ?LocalizableError,
};

@@ -57,7 +58,7 @@ export default class LanguageSelectionForm extends Component<Props> {
fields: {
languageId: {
label: this.context.intl.formatMessage(messages.languageSelectLabel),
value: this.props.languages[0].value,
value: this.props.preselectedLanguage,
},
},
},
@@ -22,8 +22,13 @@ export default class LanguageSelectionPage extends Component<InjectedProps> {
const {
setProfileLocaleRequest,
LANGUAGE_OPTIONS,
systemLocale,
} = this.props.stores.profile;
const isSubmitting = setProfileLocaleRequest.isExecuting;
const preselectedIndex = LANGUAGE_OPTIONS.findIndex(
({ value }) => value === systemLocale
);
const preselectedLanguage = LANGUAGE_OPTIONS[preselectedIndex].value;
const topbar = (
<TopBar currentRoute={currentRoute} showSubMenuToggle={false} />
);
@@ -33,6 +38,7 @@ export default class LanguageSelectionPage extends Component<InjectedProps> {
onSubmit={this.onSubmit}
isSubmitting={isSubmitting}
languages={LANGUAGE_OPTIONS}
preselectedLanguage={preselectedLanguage}
error={setProfileLocaleRequest.error}
/>
</TopBarLayout>

0 comments on commit ef72131

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.