import React, { useState, useEffect } from 'react';
import styles from './index.less';
import { Input ,Menu,Table,Space,Pagination,Tooltip, Radio } from 'antd';

import { Link, useIntl, connect, Dispatch ,getLocale, setLocale} from 'umi';


const locales = ['zh-CN','en-US'];

const Template = () => {

  const languageSelect = (e) => {
      setLocale(locales[e.target.value])
  };

  const [curLang, setCurLang] = useState(0);

  useEffect(() => {
    if (getLocale() == "en-US") {   
      setCurLang(1)
    } else {
      setCurLang(0)
    }
  }, [curLang]);
  
  return (
    <div className={styles.base}>

      <div className={styles.box}>Language Selection</div>
      <Radio.Group onChange={languageSelect} value={curLang} >
        <div className={styles.box}><Radio value={0}>Chinese</Radio></div>
        <div className={styles.box}><Radio value={1}>English</Radio></div>
      </Radio.Group>

    </div>
  );
};


export default Template;
