<template>
  <section class="space-y-6 p-4 md:p-8">
    <ModuleHeader eyebrow="Employee Transfer" title="Branch, department and shift movement" subtitle="Transfer employees across branches, departments, managers, designations, and shifts with approval history." action="Create Transfer" />
    <div class="grid gap-4 md:grid-cols-4">
      <MetricCard label="Pending" :value="summary.pending" helper="Approval queue" tone="warn" />
      <MetricCard label="Approved" :value="summary.approved_this_month" helper="This month" tone="ok" />
      <MetricCard label="Branch Transfers" :value="summary.branch_transfers" helper="Location changes" tone="live" />
      <MetricCard label="Shift Transfers" :value="summary.shift_transfers" helper="Roster changes" tone="live" />
    </div>
    <DataPanel title="Transfer Requests" :items="requests" />
  </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 requests = ref([]);

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