inhaus-plugin-kleinanzeigen/resources/js/pages/Mine.vue
Friederich Loheide f05c44733f Kleinanzeigen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 17:06:02 +00:00

60 lines
4.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup>
import { watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { CalendarClock, CheckCheck, Heart, ImageOff, PencilLine, Plus, RefreshCw, Tag, Trash2 } from '@lucide/vue';
import { AppLayout, Button, EmptyState, PageHeader, formatDate, toast } from '@inhaus/ui';
defineProps({ listings: { type: Array, required: true } });
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const post = (listing, action) => router.post(`/kleinanzeigen/${listing.id}/${action}`, {}, { preserveScroll: true });
const remove = (listing) => window.confirm(`„${listing.title}“ löschen?`) && router.delete(`/kleinanzeigen/${listing.id}`, { preserveScroll: true });
const badge = {
pending: 'ih:bg-accent ih:text-accent-foreground',
active: 'ih:bg-brand-soft ih:text-brand-text',
rejected: 'ih:bg-destructive/10 ih:text-destructive',
done: 'ih:bg-muted ih:text-muted-foreground',
expired: 'ih:bg-muted ih:text-muted-foreground',
};
</script>
<template>
<AppLayout title="Meine Anzeigen">
<PageHeader title="Meine Anzeigen" :breadcrumbs="[{ label: 'Kleinanzeigen', href: '/kleinanzeigen' }]">
<template #actions><Button as-child><Link href="/kleinanzeigen/neu"><Plus /> Anzeige aufgeben</Link></Button></template>
</PageHeader>
<ul v-if="listings.length" class="ih:grid ih:gap-3">
<li v-for="l in listings" :key="l.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-3 ih:shadow-xs ih:sm:flex-nowrap">
<Link :href="l.url" class="ih:block ih:size-20 ih:shrink-0 ih:overflow-hidden ih:rounded-md ih:bg-muted">
<img v-if="l.thumb_url" :src="l.thumb_url" alt="" class="ih:size-full ih:object-cover" />
<span v-else class="ih:grid ih:size-full ih:place-items-center ih:text-muted-foreground"><ImageOff class="ih:size-6" /></span>
</Link>
<div class="ih:min-w-0 ih:flex-1">
<div class="ih:flex ih:flex-wrap ih:items-center ih:gap-2">
<Link :href="l.url" class="ih:font-medium ih:hover:underline">{{ l.title }}</Link>
<span class="ih:rounded ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-medium" :class="badge[l.status]">{{ l.status_label }}</span>
<span v-if="l.reserved" class="ih:rounded ih:bg-foreground ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-medium ih:text-background">Reserviert</span>
</div>
<p class="ih:mt-0.5 ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:text-xs ih:text-muted-foreground">
<span>{{ [l.type_label, l.price].filter(Boolean).join(' · ') }}</span>
<span v-if="l.status === 'active' && l.expires_at" class="ih:inline-flex ih:items-center ih:gap-1"><CalendarClock class="ih:size-3" /> bis {{ formatDate(l.expires_at) }}</span>
<span v-if="l.favorites" class="ih:inline-flex ih:items-center ih:gap-1"><Heart class="ih:size-3" /> {{ l.favorites }}× gemerkt</span>
</p>
<p v-if="l.status === 'rejected' && l.review_note" class="ih:mt-1 ih:text-xs ih:text-destructive">Hinweis: {{ l.review_note }}</p>
</div>
<div class="ih:flex ih:shrink-0 ih:flex-wrap ih:gap-1">
<Button v-if="['active', 'expired'].includes(l.status)" variant="outline" size="sm" @click="post(l, 'verlaengern')"><RefreshCw /> Verlängern</Button>
<Button v-if="l.status === 'active'" variant="ghost" size="sm" @click="post(l, 'reserviert')"><Tag /> {{ l.reserved ? 'Nicht reserviert' : 'Reserviert' }}</Button>
<Button v-if="l.status === 'active'" variant="ghost" size="sm" @click="post(l, 'erledigt')"><CheckCheck /> Erledigt</Button>
<Button v-if="l.status !== 'done'" variant="ghost" size="icon" :aria-label="`${l.title} bearbeiten`" as-child><Link :href="l.edit_url"><PencilLine /></Link></Button>
<Button variant="ghost" size="icon" class="ih:text-muted-foreground ih:hover:text-destructive" :aria-label="`${l.title} löschen`" @click="remove(l)"><Trash2 /></Button>
</div>
</li>
</ul>
<div v-else class="ih:rounded-lg ih:border ih:bg-card"><EmptyState :icon="Tag" title="Sie haben noch keine Anzeigen" text="Etwas übrig oder auf der Suche? Geben Sie Ihre erste Anzeige auf." /></div>
</AppLayout>
</template>