<template>
  <section class="space-y-6 p-4 md:p-8">
    <ModuleHeader eyebrow="Task Management" title="Assignment and deadline tracking" subtitle="Employee task dashboard, deadline monitoring, and HR/finance operational workflows." action="Assign Task" />
    <div class="grid gap-4 md:grid-cols-3">
      <MetricCard label="Open" :value="summary.open" helper="Active tasks" tone="live" />
      <MetricCard label="Overdue" :value="summary.overdue" helper="Needs escalation" tone="risk" />
      <MetricCard label="Completed Today" :value="summary.completed_today" helper="Closed tasks" tone="ok" />
    </div>
    <DataPanel title="Task Queue" :items="tasks" />
  </section>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import DataPanel from '../components/DataPanel.vue';
import MetricCard from '../components/MetricCard.vue';
import ModuleHeader from '../components/ModuleHeader.vue';
import { getJson } from '../services/api.js';

const summary = ref({});
const tasks = ref([]);

onMounted(async () => {
  const data = await getJson('/tasks');
  summary.value = data.summary;
  tasks.value = data.tasks;
});
</script>
