<script setup>
import {getMazeTasksInterface, addMazeTaskInterface} from "@/api/maze.js";
import {ElMessage} from 'element-plus'
import {useRolesStore} from "@/stores/modules/roles.js";
import {useMazeStore} from "@/stores/modules/maze.js";

const rolesStore = useRolesStore()
const mazeStore = useMazeStore()

const getMazeTasks = async () => {
  await mazeStore.getMazeTasks()
}

const addMazeTasks = async () => {
  if (rolesStore.currentRole) {
    await addMazeTaskInterface(rolesStore.currentRole)
    await getMazeTasks()
  } else {
    ElMessage({
      message: '请先选择一个角色',
      type: 'warning',
    })
  }
}

</script>

<template>
  <el-button @click="addMazeTasks">添加任务</el-button>
  <el-button @click="getMazeTasks">获取任务</el-button>
  <el-table :data="mazeStore.task" style="width: 600px">
    <el-table-column prop="Nick" label="角色" width="180"/>
    <el-table-column prop="Count" label="剩余次数" width="180"/>
    <el-table-column prop="IsDone" label="是否完成"/>
  </el-table>
</template>

<style scoped>

</style>
