<script lang="ts" setup>
import { useRoute, useRouter } from 'vue-router';

// @ts-ignore
import { Page } from '@vben/common-ui';

import { CircleCheckFilled } from '@element-plus/icons-vue';

const router = useRouter();
const route = useRoute();
const handleClick = () => {
  const userType = localStorage.getItem('exam:usertype') || '';
  if (userType === 'exam') {
    router.replace({
      name: 'Viewexamin',
      params: {
        id: route.params.id,
      },
      query: {
        pid: route.query.pid,
      },
    });
  } else {
    router.replace({
      name: 'ViewExamResult',
      params: {
        id: route.params.id,
      },
      query: {
        pid: route.query.pid,
      },
    });
  }
  // if (route.path === '/examcompleted') {
  //   router.replace({
  //     name: 'ViewExamResult',
  //     params: { id: route.params.id },
  //   });
  // } else {
  //   router.replace({
  //     name: 'ViewExamResult',
  //     params: {
  //       id: route.params.id,
  //     },
  //     query: {
  //       pid: route.query.pid,
  //     },
  //   });
  // }
};
</script>
<template>
  <Page
    style="height: 100%"
    title="考试完成"
    :auto-content-height="true"
    class="h-screen"
  >
    <div class="exam-completed-container w-full rounded-md bg-white p-4">
      <el-icon class="exam-completed-icon"><CircleCheckFilled /></el-icon>
      <div class="exam-completed-title">考试完成</div>
      <div class="exam-completed-desc">
        请稍后在【我的考试-已考试】中查看成绩。
      </div>
      <el-button class="exam-completed-btn" @click="handleClick">
        查看结果
      </el-button>
    </div>
  </Page>
</template>
<style lang="scss" scoped>
.exam-completed-container {
  // margin-top: 120px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  // justify-content: center;
  gap: 24px;
  .exam-completed-icon {
    margin-top: 80px;
    font-size: 88px;
    color: #52c41a;
  }
  .exam-completed-title {
    font-size: 18px;
    font-weight: 500;
    color: #31373d;
  }
  .exam-completed-desc {
    font-size: 14px;
    font-weight: 400;
    color: #31373d;
  }
  .exam-completed-btn {
    width: 160px;
    height: 40px;
  }
}
</style>
