import React, { useEffect } from 'react';

import { getParams } from '@wisdom-utils/utils/lib/helpers/params';
import BaseLogin from './template/baseLogin';
import NewYear from './template/newYear';
import InfoLogin from './template/infoLogin';
import Yulin from './template/yulin';
// import { useParams } from '@wisdom-utils/runtime';
import EnergyQuota from './template/energy_quota/index';
import { initGlobalConfig } from '../../../initConfig';
const LoginTemplate = {
  '新春 - 智联.html': NewYear,
  'Dark - IOTMultiLogin.html': BaseLogin,
  'Dark.html': BaseLogin,
  'DarkCloud.html': BaseLogin,
  '信息化.html': InfoLogin,
  '项目 - 榆林.html': Yulin,
  '能源-定额平台.html': EnergyQuota,
  default: BaseLogin,
};
/* eslint-disable */
export default (props) => {
  const redirect = getParams('redirect');
  useEffect(() => {
    if(getParams('loginName') && getParams('password')) return
    initGlobalConfig();
  }, [redirect]);
  const template = window.globalConfig && window.globalConfig.loginTemplate;
  const RenderComponent = LoginTemplate[template] ? LoginTemplate[template]: LoginTemplate['default'];
  return <RenderComponent {...props}/>
};

