Übersicht mit Status und Standort, Anfragen im Portal (Benachrichtigung + E-Mail ans Team), Zusagen/Absagen mit automatischem Eintrag, Zurücknehmen, Recht „Verleih verwalten“, einstellbare Bezeichnungen und Übernahme aus dem WordPress-Plugin „FL-Verleihsystem“ (WXR mit Bildern). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
114 lines
6.4 KiB
Vue
114 lines
6.4 KiB
Vue
<script setup>
|
||
import { ref, watch } from 'vue';
|
||
import { Link, router, usePage } from '@inertiajs/vue3';
|
||
import { Images, Inbox, Plus, Search, Settings2 } from '@lucide/vue';
|
||
import { AppLayout, Button, EmptyState, PageHeader, formatDate, toast } from '@inhaus/ui';
|
||
import ItemCard from '../components/ItemCard.vue';
|
||
|
||
const props = defineProps({
|
||
items: { type: Array, required: true },
|
||
filters: { type: Object, required: true },
|
||
counts: { type: Object, required: true },
|
||
labels: { type: Object, required: true },
|
||
canManage: { type: Boolean, default: false },
|
||
pendingRequests: { type: Number, default: null },
|
||
myRequests: { type: Array, default: () => [] },
|
||
});
|
||
|
||
const page = usePage();
|
||
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
|
||
|
||
const query = ref(props.filters.q);
|
||
let timer;
|
||
watch(query, (value) => {
|
||
clearTimeout(timer);
|
||
timer = setTimeout(() => apply({ q: value }), 300);
|
||
});
|
||
|
||
function apply(changes) {
|
||
const params = { ...props.filters, ...changes };
|
||
router.get('/verleih', Object.fromEntries(Object.entries(params).filter(([, v]) => v)), { preserveState: true, preserveScroll: true, replace: true });
|
||
}
|
||
|
||
const tabs = [
|
||
{ value: null, label: 'Alle', count: 'all' },
|
||
{ value: 'verfuegbar', label: 'Verfügbar', count: 'available' },
|
||
{ value: 'verliehen', label: 'Verliehen', count: 'lent' },
|
||
];
|
||
|
||
const cancel = (request) => window.confirm('Anfrage zurückziehen?') && router.delete(`/verleih/anfragen/${request.id}`, { preserveScroll: true });
|
||
</script>
|
||
|
||
<template>
|
||
<AppLayout :title="labels.title">
|
||
<PageHeader :title="labels.title" :description="`Alle ${labels.plural} auf einen Blick – verfügbar oder verliehen, und wo sie gerade sind.`">
|
||
<template #actions>
|
||
<template v-if="canManage">
|
||
<Button variant="outline" as-child>
|
||
<Link href="/verleih/anfragen"><Inbox /> Anfragen<span v-if="pendingRequests" class="ih:rounded-full ih:bg-brand ih:px-1.5 ih:text-[11px] ih:text-brand-foreground">{{ pendingRequests }}</span></Link>
|
||
</Button>
|
||
<Button as-child><Link href="/verleih/neu"><Plus /> {{ labels.singular }} erfassen</Link></Button>
|
||
</template>
|
||
</template>
|
||
</PageHeader>
|
||
|
||
<!-- Eigene Anfragen -->
|
||
<section v-if="myRequests.length" class="ih:mb-6 ih:rounded-lg ih:border ih:bg-card ih:p-4" aria-labelledby="meine-anfragen">
|
||
<h2 id="meine-anfragen" class="ih:mb-2 ih:text-sm ih:font-semibold">Ihre Anfragen</h2>
|
||
<ul class="ih:divide-y">
|
||
<li v-for="request in myRequests" :key="request.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:py-2 ih:text-sm">
|
||
<Link :href="request.item.url" class="ih:font-medium ih:hover:underline">{{ request.item.title }}</Link>
|
||
<span class="ih:text-muted-foreground">nach {{ request.location }}</span>
|
||
<span
|
||
class="ih:rounded-full ih:px-2 ih:py-0.5 ih:text-xs ih:font-medium"
|
||
:class="request.status === 'accepted' ? 'ih:bg-brand ih:text-brand-foreground' : request.status === 'pending' ? 'ih:bg-brand-soft ih:text-brand-text' : 'ih:bg-muted ih:text-muted-foreground'"
|
||
>{{ request.status_label }}</span>
|
||
<span v-if="request.note" class="ih:text-muted-foreground">„{{ request.note }}“</span>
|
||
<span class="ih:ml-auto ih:text-xs ih:text-muted-foreground">{{ formatDate(request.created_at) }}</span>
|
||
<button v-if="request.status === 'pending'" type="button" class="ih:text-xs ih:font-medium ih:text-muted-foreground ih:hover:text-destructive" @click="cancel(request)">Zurückziehen</button>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
|
||
<div class="ih:mb-5 ih:flex ih:flex-wrap ih:items-center ih:gap-3">
|
||
<nav class="ih:flex ih:flex-wrap ih:gap-1.5" aria-label="Status">
|
||
<button
|
||
v-for="tab in tabs"
|
||
:key="tab.label"
|
||
type="button"
|
||
class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:border ih:px-3 ih:py-1 ih:text-[13px]"
|
||
:class="filters.status === tab.value ? 'ih:border-brand ih:bg-brand ih:text-brand-foreground' : 'ih:bg-card ih:hover:bg-accent'"
|
||
:aria-pressed="filters.status === tab.value"
|
||
@click="apply({ status: tab.value })"
|
||
>
|
||
{{ tab.label }} <span class="ih:tabular-nums ih:opacity-75">{{ counts[tab.count] }}</span>
|
||
</button>
|
||
</nav>
|
||
<div class="ih:relative ih:ml-auto ih:w-full ih:sm:w-64">
|
||
<Search class="ih:pointer-events-none ih:absolute ih:top-1/2 ih:left-2.5 ih:size-4 ih:-translate-y-1/2 ih:text-muted-foreground" />
|
||
<input
|
||
v-model="query"
|
||
type="search"
|
||
:placeholder="`${labels.plural} oder Orte suchen`"
|
||
:aria-label="`${labels.plural} durchsuchen`"
|
||
class="ih:h-9 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:pr-3 ih:pl-8 ih:text-sm ih:shadow-xs ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="items.length" class="ih:grid ih:grid-cols-2 ih:gap-3 ih:sm:gap-4 ih:md:grid-cols-3 ih:xl:grid-cols-4">
|
||
<ItemCard v-for="item in items" :key="item.id" :item="item" />
|
||
</div>
|
||
<div v-else class="ih:rounded-lg ih:border ih:bg-card">
|
||
<EmptyState
|
||
:icon="Images"
|
||
:title="filters.q || filters.status ? `Keine passenden ${labels.plural}` : `Noch keine ${labels.plural}`"
|
||
:text="canManage && !filters.q && !filters.status ? `Legen Sie mit „${labels.singular} erfassen“ los – oder übernehmen Sie den Bestand aus WordPress (Administration → Portal → Verleih).` : ''"
|
||
/>
|
||
</div>
|
||
|
||
<p v-if="canManage" class="ih:mt-6 ih:flex ih:items-center ih:gap-1.5 ih:text-xs ih:text-muted-foreground">
|
||
<Settings2 class="ih:size-3.5" /> Bezeichnungen und Übernahme aus WordPress: Administration → Portal → Verleih
|
||
</p>
|
||
</AppLayout>
|
||
</template>
|