<script setup>
import EmptyState from '@/Share/Components/EmptyState.vue';

defineProps({
    projects: {
        type: Array,
        required: true,
    }
});
</script>

<template>
    <section class="bg-gray-100 rounded-md p-4">
        <header class="flex justify-between items-center pb-4">
            <h2 class="text-2xl font-roboto font-light">Projekty</h2>
            <InertiaLink
                as="button"
                href="/dashboard/project/create"
                class="bg-blue-400 hover:bg-blue-500 text-white px-2.5 py-1 rounded-full"
                ><FontAwesomeIcon :icon="['fas', 'plus']" /></InertiaLink>
        </header>
        <ul v-if="projects.length" class="flex flex-col gap-2">
            <li
                v-for="(project, key) in projects"
                :key="key"
                class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200"
            >
                <InertiaLink :href="`/dashboard/project/${project.id}`">{{ project.title }}</InertiaLink>
                <div class="flex items-center gap-2">
                    <InertiaLink
                        as="button"
                        class="px-2 py-1 text-lime-600 hover:text-lime-800 border-t-2 border-b-2 border-transparent hover:border-b-lime-600"
                        :href="`/dashboard/project/${project.id}`"
                        title="Edytuj projekt"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
                    <InertiaLink
                        as="button"
                        class="px-2 py-1 text-red-600 hover:text-red-800"
                        :href="`/dashboard/project/${project.id}/delete`"
                        title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
                </div>
            </li>
        </ul>
        <EmptyState v-else :icon="['fas', 'bars-progress']">
            <template #title>Brak projektów</template>
            <template #text>Nie dodano jeszcze żadnego projektu.</template>
        </EmptyState>
    </section>
</template>
