<template>
  <section class="space-y-6 p-4 md:p-8">
    <ModuleHeader eyebrow="Contract Management" title="Employee contracts and renewal reminders" subtitle="Contract expiry reminders, renewals, document upload tracking, and employee contract history." action="Upload Contract" />
    <div class="grid gap-4 md:grid-cols-3">
      <MetricCard label="Active" :value="summary.active" helper="Signed contracts" tone="ok" />
      <MetricCard label="Expiring 30 Days" :value="summary.expiring_30_days" helper="Renewal reminders" tone="warn" />
      <MetricCard label="Renewal Pending" :value="summary.renewal_pending" helper="Needs HR action" tone="risk" />
    </div>
    <DataPanel title="Contract Register" :items="contracts" />
  </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 contracts = ref([]);

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