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 CloudLogin from './template/cloud';
import { initGlobalConfig } from '../../../initConfig';
const LoginTemplate = {
  '新春 - 智联.html': NewYear,
  'Dark - IOTMultiLogin.html': BaseLogin,
  'Dark.html': BaseLogin,
  'DarkCloud.html': window.location.origin.replace(/^(http|https):\/\//, '') === 'panda-water.cn' ? CloudLogin : 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();
  }, []);
  const template = window.globalConfig && window.globalConfig.loginTemplate;
  const RenderComponent = LoginTemplate[template] ? LoginTemplate[template]: LoginTemplate['default'];
  return <RenderComponent {...props}/>
};

