<script setup>
import AppLayout from '@/Layouts/AppLayout.vue';
import { Link } from '@inertiajs/vue3';

const props = defineProps({
  settings: Array,
});
</script>

<template>
  <AppLayout title="Field Job Settings">
    <template #header></template>
    <div class="pt-12">
      <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
          <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg p-6">
            <h3 class="text-lg font-semibold mb-2">Segments</h3>
            <p class="text-sm text-gray-600 mb-4">Manage segments used across the app.</p>
            <Link :href="route('settings.segments')" class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white rounded hover:bg-indigo-700">Open Segments</Link>
          </div>
        </div>
        <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg p-6">
          <h2 class="text-xl font-semibold mb-4">Field Job Settings</h2>
          <table class="min-w-full text-left text-sm">
            <thead>
              <tr class="border-b">
                <th class="py-2 pr-4">ID</th>
                <th class="py-2 pr-4">Segment</th>
                <th class="py-2 pr-4">Assign Decision</th>
                <th class="py-2 pr-4">Complete Decision</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="row in settings" :key="row.id" class="border-b last:border-0">
                <td class="py-2 pr-4">{{ row.id }}</td>
                <td class="py-2 pr-4">{{ row.segment?.name }}</td>
                <td class="py-2 pr-4">{{ row.asign_decision?.name || row.asignDecision?.name }}</td>
                <td class="py-2 pr-4">{{ row.complete_decision?.name || row.completeDecision?.name }}</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </AppLayout>
</template>
