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

                    <div
                        v-if="dynamics.length > 0"
                        class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3"
                    >
                        <div
                            v-for="dynamic in dynamics"
                            :key="dynamic.id"
                            class="border-b border-gray-200 bg-white p-6 dark:border-gray-600 dark:bg-gray-700"
                        >
                            <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>
