2020-11-10 17:07:00 +01:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
// $FlowFixMe
|
|
|
|
import homepages from 'homepages';
|
|
|
|
import LANGUAGES from 'constants/languages';
|
|
|
|
import { FormField } from 'component/common/form';
|
2021-01-06 19:13:56 +01:00
|
|
|
import { getDefaultHomepageKey } from 'util/default-languages';
|
2020-11-10 17:07:00 +01:00
|
|
|
|
|
|
|
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"
|
|
|
|
label={__('Homepage')}
|
|
|
|
onChange={handleSetHomepage}
|
2021-01-06 19:13:56 +01:00
|
|
|
value={homepage || getDefaultHomepageKey()}
|
2020-11-10 19:21:19 +01:00
|
|
|
helper={__('Tailor your experience.')}
|
2020-11-10 17:07:00 +01:00
|
|
|
>
|
|
|
|
{Object.keys(homepages).map(hp => (
|
|
|
|
<option key={'hp' + hp} value={hp}>
|
|
|
|
{`${LANGUAGES[hp][1]}`}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</FormField>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SelectHomepage;
|