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

defineProps({
    notes: {
        type: Object,
        required: true,
    }
});
</script>

<template>
    <InertiaHead title="Lista notatek" />
    <div class="p-4">
        <header class="flex justify-between items-center pb-4">
            <div class="flex items-center gap-2">
                <InertiaLink
                    as="button"
                    href="/dashboard"
                    class="px-2 text-xl text-gray-700 hover:text-black"
                    title="Wróc do dashboard"><FontAwesomeIcon :icon="['fas', 'caret-left']" /></InertiaLink>
                <h1 class="text-3xl font-roboto font-light">Lista notatek</h1>
            </div>
            <InertiaLink
                as="button"
                href="/dashboard/note/create"
                class="bg-blue-400 hover:bg-blue-500 text-white px-2.5 py-1 rounded-full"
                title="Dodaj nowe dane dla CV"
                ><FontAwesomeIcon :icon="['fas', 'plus']" /></InertiaLink>
        </header>
        <ul v-if="notes.data.length" class="flex flex-col gap-2">
            <li
                v-for="(note, key) in notes.data"
                :key="key"
                class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200"
            >
                <InertiaLink :href="`/dashboard/note/${note.id}`">{{ note.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/note/${note.id}/edit`"
                        title="Edytuj notatkę"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
                    <InertiaLink
                        as="button"
                        class="px-2 py-1 text-red-600 hover:text-red-800"
                        :href="`/dashboard/note/${note.id}/delete`"
                        title="Usuń notatkę z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
                </div>
            </li>
        </ul>
        <EmptyState v-else>
            <template #title>Nie znaleziono notatek</template>
            <template #text>Nie dodano jeszcze notatek do listy.</template>
        </EmptyState>
    </div>
</template>
