import React from 'react';

import {
  Helmet,
  HelmetProvider,
} from 'react-helmet-async';
import { renderRoutes } from 'react-router-config';

import {
  DefaultFooter,
  getMenuData,
  getPageTitle,
} from '@ant-design/pro-layout';

import logo from '../assets/logo.svg';
import styles from './UserLayout.less';

const UserLayout = props => {
  const {
    route = {
      routes: [],
    },
  } = props;
  // const { formatMessage } = useIntl();
  const { breadcrumb } = getMenuData(route.routes);
  const title = getPageTitle({
    pathname: location.pathname,
    // formatMessage,
    breadcrumb,
    ...props,
  });

  return (
    <HelmetProvider>
      <Helmet>
        <title>{title}</title>
        <meta name="description" content={title} />
      </Helmet>

      <div className={styles.container}>
        <div className={styles.lang}>
          {/* <SelectLang /> */}
        </div>
        <div className={styles.content}>
          <div className={styles.top}>
            <div className={styles.header}>
                <img alt="logo" className={styles.logo} src={logo} />
                <span className={styles.title}>Ant Design</span>
            </div>
            <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
          </div>
          {renderRoutes(route.routes)}
        </div>
        <DefaultFooter />
      </div>
    </HelmetProvider>
  );
};

export default UserLayout;
