<template>
  <AppLayout title="Academic Year Details">
    <div class="space-y-6">
      <!-- Header -->
      <div class="flex items-center justify-between">
        <div>
          <h1 class="text-3xl font-bold tracking-tight">{{ academicYear.name }}</h1>
          <p class="text-muted-foreground">Academic Year Details</p>
        </div>
        <div class="flex space-x-3">
          <Button variant="outline" as-child>
            <Link :href="route('academic-years.edit', academicYear.id)">
              <Edit class="mr-2 h-4 w-4" />
              Edit Academic Year
            </Link>
          </Button>
          <Button variant="outline" as-child>
            <Link :href="route('academic-years.index')">
              <ArrowLeft class="mr-2 h-4 w-4" />
              Back to Academic Years
            </Link>
          </Button>
        </div>
      </div>

      <Card>
        <CardHeader>
          <CardTitle>Academic Year Information</CardTitle>
        </CardHeader>
        <CardContent class="space-y-4">
          <div class="grid grid-cols-2 gap-4">
            <div>
              <Label class="text-sm font-medium text-muted-foreground">Name</Label>
              <p class="text-sm">{{ academicYear.name }}</p>
            </div>
            <div>
              <Label class="text-sm font-medium text-muted-foreground">Status</Label>
              <Badge :variant="academicYear.is_active ? 'default' : 'secondary'">
                {{ academicYear.is_active ? 'Active' : 'Inactive' }}
              </Badge>
            </div>
            <div>
              <Label class="text-sm font-medium text-muted-foreground">Start Date</Label>
              <p class="text-sm">{{ formatDate(academicYear.start_date) }}</p>
            </div>
            <div>
              <Label class="text-sm font-medium text-muted-foreground">End Date</Label>
              <p class="text-sm">{{ formatDate(academicYear.end_date) }}</p>
            </div>
          </div>
        </CardContent>
      </Card>
    </div>
  </AppLayout>
</template>

<script setup lang="ts">
import { Link } from '@inertiajs/vue3'
import AppLayout from '@/layouts/AppLayout.vue'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { Label } from '@/components/ui/label'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Edit, ArrowLeft } from 'lucide-vue-next'

const props = defineProps<{
  academicYear: any
}>()

const formatDate = (dateString: string) => {
  return new Date(dateString).toLocaleDateString()
}
</script>
