import React from 'react';
import { Result, Button } from 'antd';
import { sessionStore } from '../../utils/store';
import { pathHolder } from '../../utils/route';

const NoFound: React.FC = () => {
  return (
    <div
      style={{
        position: 'fixed',
        left: '50%',
        top: '200px',
        transform: 'translate(-50%)',
      }}
    >
      <Result
        status={404}
        subTitle="未找到页面，或者没有权限访问"
        extra={
          <Button
            onClick={() => {
              const userInfo = sessionStore.get('user-info');
              const [role] = userInfo?.user?.roles || [];
              const { defaultPage = '' } = role || {};
              location.replace(pathHolder(defaultPage));
            }}
          >
            返回首页
          </Button>
        }
      ></Result>
    </div>
  );
};
export default NoFound;
