import React from 'react';
import { useEffect } from 'react';
import { message, Result } from 'antd';
import styles from './index.less';
import { getPageQuery } from '../../../utils/utils';
// @ts-ignore

const ResultPage: React.FC = () => {
  const type = getPageQuery().type;
  useEffect(() => {
    const codeName = localStorage.getItem('taskcode');
    if (codeName) {
      message.info('温馨提示: 3秒后自动跳转至我的评价');
      localStorage.removeItem('taskcode');
      setTimeout(() => {
        window.location.href = '/taskList?code=' + codeName;
      }, 3000);
    }
  }, []);

  return (
    <div className={styles.container}>
      <div className={styles.content}>
        {type === 'success' && (
          <Result status="success" title="已完成作答" subTitle="感谢您的参与" extra={[]} />
        )}
        {type === 'noAccess' && <Result status="error" title="您没有权限" extra={[]} />}
        {type === 'notExist' && (
          <Result status="error" title="该问卷不存在或者已经停用" extra={[]} />
        )}
      </div>
    </div>
  );
};

export default ResultPage;
