<script setup>
import { Head, Link } from '@inertiajs/vue3';
import { route } from 'ziggy-js';

defineProps({
    dynamics: Array,
});

const breadcrumbs = [
    {
        name: 'Dynamics',
        href: route('dynamics.index'),
    },
];
</script>

<template>
    <Head title="Dynamics" />

        <div class="py-12">
            <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6 text-gray-900 dark:text-gray-100">
                        <div class="flex justify-between items-center mb-6">
                            <h3 class="text-lg font-medium">Your Dynamics</h3>
                            <Link :href="route('dynamics.create')" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
                                Create Dynamic
                            </Link>
                        </div>

                        <div v-if="dynamics.length > 0" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                            <div v-for="dynamic in dynamics" :key="dynamic.id" class="p-6 bg-white dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600">
                                <Link :href="route('dynamics.show', dynamic.id)">
                                    <h4 class="text-lg font-semibold">{{ dynamic.name }}</h4>
                                </Link>
                                <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">{{ dynamic.rules }}</p>
                            </div>
                        </div>
                        <div v-else>
                            <p>You don't have any dynamics yet.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</template>
