712e02db16
* Use locale/get response to suggest homepage and language switch * Fix language modal condition * Fixes from review * Fixes from review * Fix gdpr * string * Fix multiple options behavior * Fix gdpr and use only one fetch * Only show if no languages set or loaded * pt-br * Fix ad * Fix homepage select * Fix zh langs
42 lines
1,019 B
JavaScript
42 lines
1,019 B
JavaScript
// @flow
|
|
import React from 'react';
|
|
// $FlowFixMe
|
|
import homepages from 'homepages';
|
|
import { getLanguageEngName } from 'constants/languages';
|
|
import { FormField } from 'component/common/form';
|
|
import { getDefaultHomepageKey } from 'util/default-languages';
|
|
|
|
type Props = {
|
|
homepage: string,
|
|
setHomepage: (string) => void,
|
|
};
|
|
|
|
function SelectHomepage(props: Props) {
|
|
const { homepage, setHomepage } = props;
|
|
|
|
function handleSetHomepage(e) {
|
|
const { value } = e.target;
|
|
setHomepage(value);
|
|
}
|
|
if (Object.keys(homepages).length <= 1) {
|
|
return null;
|
|
}
|
|
return (
|
|
<React.Fragment>
|
|
<FormField
|
|
name="homepage_select"
|
|
type="select"
|
|
onChange={handleSetHomepage}
|
|
value={homepage || getDefaultHomepageKey()}
|
|
>
|
|
{Object.keys(homepages).map((hp) => (
|
|
<option key={'hp' + hp} value={hp}>
|
|
{`${getLanguageEngName(hp)}`}
|
|
</option>
|
|
))}
|
|
</FormField>
|
|
</React.Fragment>
|
|
);
|
|
}
|
|
|
|
export default SelectHomepage;
|