Kleinanzeigen-Plugin 1.0.0

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 17:06:02 +00:00
commit f05c44733f
50 changed files with 3854 additions and 0 deletions

View file

@ -0,0 +1,43 @@
<script setup>
import { Link, router } from '@inertiajs/vue3';
import { Camera, Heart, ImageOff, MapPin } from '@lucide/vue';
const props = defineProps({
listing: { type: Object, required: true },
compact: { type: Boolean, default: false },
});
function toggleFavorite() {
const l = props.listing;
l.favorite = !l.favorite;
router.visit(`/kleinanzeigen/${l.id}/merken`, { method: l.favorite ? 'post' : 'delete', preserveScroll: true, preserveState: true });
}
</script>
<template>
<article class="ih:group ih:relative ih:flex ih:flex-col ih:overflow-hidden ih:rounded-lg ih:border ih:bg-card ih:shadow-xs ih:transition-shadow ih:hover:shadow-md">
<Link :href="listing.url" class="ih:relative ih:block ih:aspect-[4/3] ih:overflow-hidden ih:bg-muted">
<img v-if="listing.thumb_url" :src="listing.thumb_url" :alt="listing.title" loading="lazy" class="ih:size-full ih:object-cover ih:transition-transform ih:duration-300 ih:group-hover:scale-[1.03]" />
<span v-else class="ih:grid ih:size-full ih:place-items-center ih:text-muted-foreground"><ImageOff class="ih:size-8" :stroke-width="1.5" /></span>
<span class="ih:absolute ih:top-2 ih:left-2 ih:rounded ih:bg-card/95 ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:shadow-xs">{{ listing.type_label }}</span>
<span v-if="listing.reserved" class="ih:absolute ih:bottom-2 ih:left-2 ih:rounded ih:bg-foreground/85 ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:text-background">Reserviert</span>
<span v-if="listing.images > 1" class="ih:absolute ih:right-2 ih:bottom-2 ih:inline-flex ih:items-center ih:gap-1 ih:rounded ih:bg-foreground/70 ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:text-background"><Camera class="ih:size-3" />{{ listing.images }}</span>
</Link>
<button
type="button"
class="ih:absolute ih:top-2 ih:right-2 ih:grid ih:size-8 ih:place-items-center ih:rounded-full ih:bg-card/95 ih:shadow-xs ih:transition-colors ih:hover:text-brand-text"
:class="listing.favorite ? 'ih:text-brand-text' : 'ih:text-muted-foreground'"
:aria-pressed="listing.favorite"
:aria-label="listing.favorite ? 'Von der Merkliste nehmen' : 'Merken'"
@click="toggleFavorite"
><Heart class="ih:size-4" :class="listing.favorite ? 'ih:fill-current' : ''" /></button>
<div class="ih:flex ih:flex-1 ih:flex-col ih:gap-1 ih:p-3">
<p v-if="listing.price" class="ih:text-[15px] ih:font-semibold ih:text-brand-text">{{ listing.price }}</p>
<Link :href="listing.url" class="ih:line-clamp-2 ih:text-sm ih:leading-snug ih:font-medium ih:hover:underline">{{ listing.title }}</Link>
<p v-if="!compact" class="ih:mt-auto ih:flex ih:items-center ih:gap-1 ih:pt-1 ih:text-xs ih:text-muted-foreground">
<MapPin v-if="listing.location" class="ih:size-3 ih:shrink-0" />
<span class="ih:truncate">{{ [listing.location, listing.category_label].filter(Boolean).join(' · ') }}</span>
</p>
</div>
</article>
</template>

View file

@ -0,0 +1,19 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { Panel } from '@inhaus/ui';
defineProps({ pending: { type: Array, required: true } });
</script>
<template>
<Panel title="Kleinanzeigen – Freigabe" action-label="Zur Freigabe" action-href="/kleinanzeigen/moderation">
<ul v-if="pending.length" class="ih:-mx-5 ih:divide-y ih:border-t">
<li v-for="l in pending" :key="l.id" class="ih:flex ih:items-center ih:gap-3 ih:px-5 ih:py-2.5">
<img v-if="l.thumb_url" :src="l.thumb_url" alt="" class="ih:size-10 ih:rounded ih:object-cover" />
<Link :href="l.url" class="ih:min-w-0 ih:flex-1 ih:truncate ih:text-sm ih:font-medium ih:hover:underline">{{ l.title }}</Link>
<span class="ih:shrink-0 ih:text-xs ih:text-muted-foreground">{{ l.type_label }}</span>
</li>
</ul>
<p v-else class="ih:text-sm ih:text-muted-foreground">Keine Anzeigen warten auf Freigabe.</p>
</Panel>
</template>

View file

@ -0,0 +1,145 @@
<script setup>
import { computed, ref } from 'vue';
import { Link, useForm } from '@inertiajs/vue3';
import { ChevronLeft, ImagePlus, LoaderCircle, TriangleAlert, X } from '@lucide/vue';
import { AppLayout, Button, FormField, Input, PageHeader, Panel, Switch, Textarea, toast } from '@inhaus/ui';
const props = defineProps({
listing: { type: Object, default: null },
types: { type: Object, required: true },
categories: { type: Object, required: true },
maxPhotos: { type: Number, default: 8 },
defaultLocation: { type: String, default: null },
});
const l = props.listing;
const form = useForm({
type: l?.type ?? 'sell',
category: l?.category ?? '',
title: l?.title ?? '',
description: l?.description ?? '',
price: l?.price ?? '',
negotiable: l?.negotiable ?? false,
location: l?.location ?? props.defaultLocation ?? '',
phone: l?.phone ?? '',
photos: [],
remove_photos: [],
});
const existing = ref(l?.photos ?? []);
const previews = ref([]);
const fileInput = ref(null);
const withPrice = computed(() => ['sell', 'search'].includes(form.type));
const photoCount = computed(() => existing.value.length + form.photos.length);
function addPhotos(files) {
for (const file of files) {
if (!file.type.startsWith('image/')) continue;
if (photoCount.value >= props.maxPhotos) {
toast.error(`Höchstens ${props.maxPhotos} Fotos.`);
break;
}
form.photos.push(file);
previews.value.push(URL.createObjectURL(file));
}
}
function removeNew(i) {
URL.revokeObjectURL(previews.value[i]);
form.photos.splice(i, 1);
previews.value.splice(i, 1);
}
function removeExisting(photo) {
form.remove_photos.push(photo.id);
existing.value = existing.value.filter((p) => p.id !== photo.id);
}
function submit() {
form.post(l ? `/kleinanzeigen/${l.id}` : '/kleinanzeigen', { forceFormData: true, preserveScroll: true });
}
const willReview = computed(() => l && ['active', 'rejected', 'expired'].includes(l.status));
</script>
<template>
<AppLayout :title="l ? 'Anzeige bearbeiten' : 'Anzeige aufgeben'">
<PageHeader :title="l ? 'Anzeige bearbeiten' : 'Anzeige aufgeben'" :breadcrumbs="[{ label: 'Kleinanzeigen', href: '/kleinanzeigen' }]" />
<p v-if="l?.review_note" class="ih:mb-4 ih:flex ih:items-start ih:gap-2 ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm">
<TriangleAlert class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-destructive" /> Hinweis der Moderation: {{ l.review_note }}
</p>
<form class="ih:grid ih:max-w-3xl ih:gap-6" @submit.prevent="submit">
<Panel>
<div class="ih:grid ih:gap-5">
<fieldset>
<legend class="ih:mb-2 ih:text-sm ih:font-medium">Ich …</legend>
<div class="ih:flex ih:flex-wrap ih:gap-2">
<label v-for="(label, key) in types" :key="key" class="ih:cursor-pointer ih:rounded-full ih:border ih:px-4 ih:py-1.5 ih:text-sm ih:has-[:checked]:border-brand ih:has-[:checked]:bg-brand ih:has-[:checked]:text-brand-foreground ih:has-[:focus-visible]:ring-3 ih:has-[:focus-visible]:ring-ring/30">
<input v-model="form.type" type="radio" name="type" :value="key" class="ih:sr-only" />{{ label.toLowerCase() }}
</label>
</div>
</fieldset>
<FormField id="ka-title" label="Titel" :error="form.errors.title">
<Input id="ka-title" v-model="form.title" maxlength="120" placeholder="z. B. Kinderfahrrad 20 Zoll, blau" />
</FormField>
<FormField id="ka-category" label="Kategorie" :error="form.errors.category">
<select id="ka-category" v-model="form.category" class="ih:h-9 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:px-2 ih:text-sm">
<option value="" disabled>Bitte wählen</option>
<option v-for="(label, key) in categories" :key="key" :value="key">{{ label }}</option>
</select>
</FormField>
<FormField id="ka-description" label="Beschreibung" :error="form.errors.description" hint="Zustand, Maße, Abholung – alles, was Interessierte wissen möchten.">
<Textarea id="ka-description" v-model="form.description" rows="6" maxlength="5000" />
</FormField>
<div v-if="withPrice" class="ih:grid ih:gap-4 ih:sm:grid-cols-2">
<FormField id="ka-price" :label="form.type === 'search' ? 'Budget (optional)' : 'Preis in € (leer = auf Anfrage)'" :error="form.errors.price">
<Input id="ka-price" v-model="form.price" inputmode="decimal" placeholder="z. B. 25 oder 12,50" />
</FormField>
<label v-if="form.type === 'sell'" class="ih:flex ih:items-center ih:gap-3 ih:self-end ih:pb-2 ih:text-sm"><Switch v-model="form.negotiable" /> Verhandlungsbasis (VB)</label>
</div>
<div class="ih:grid ih:gap-4 ih:sm:grid-cols-2">
<FormField id="ka-location" label="Ort bzw. Abholung" :error="form.errors.location">
<Input id="ka-location" v-model="form.location" maxlength="120" placeholder="z. B. Haus A oder Mainz-Gonsenheim" />
</FormField>
<FormField id="ka-phone" label="Telefon (optional)" :error="form.errors.phone" hint="Wird in der Anzeige gezeigt.">
<Input id="ka-phone" v-model="form.phone" type="tel" maxlength="40" />
</FormField>
</div>
</div>
</Panel>
<Panel :title="`Fotos (${photoCount}/${maxPhotos})`">
<div class="ih:grid ih:grid-cols-3 ih:gap-3 ih:sm:grid-cols-4" @dragover.prevent @drop.prevent="addPhotos([...$event.dataTransfer.files])">
<div v-for="photo in existing" :key="photo.id" class="ih:relative ih:aspect-[4/3] ih:overflow-hidden ih:rounded-md ih:border">
<img :src="photo.url" alt="" class="ih:size-full ih:object-cover" />
<button type="button" class="ih:absolute ih:top-1 ih:right-1 ih:grid ih:size-6 ih:place-items-center ih:rounded-full ih:bg-foreground/75 ih:text-background" aria-label="Foto entfernen" @click="removeExisting(photo)"><X class="ih:size-3.5" /></button>
</div>
<div v-for="(url, i) in previews" :key="url" class="ih:relative ih:aspect-[4/3] ih:overflow-hidden ih:rounded-md ih:border">
<img :src="url" alt="" class="ih:size-full ih:object-cover" />
<button type="button" class="ih:absolute ih:top-1 ih:right-1 ih:grid ih:size-6 ih:place-items-center ih:rounded-full ih:bg-foreground/75 ih:text-background" aria-label="Foto entfernen" @click="removeNew(i)"><X class="ih:size-3.5" /></button>
</div>
<button v-if="photoCount < maxPhotos" type="button" class="ih:flex ih:aspect-[4/3] ih:flex-col ih:items-center ih:justify-center ih:gap-1 ih:rounded-md ih:border-2 ih:border-dashed ih:text-sm ih:text-muted-foreground ih:hover:border-brand ih:hover:text-brand-text" @click="fileInput?.click()">
<ImagePlus class="ih:size-6" /> Fotos hinzufügen
</button>
</div>
<input ref="fileInput" type="file" accept="image/*" multiple class="ih:hidden" @change="addPhotos([...$event.target.files]); $event.target.value = ''" />
<p v-if="form.errors.photos || form.errors['photos.0']" class="ih:mt-2 ih:text-[13px] ih:text-destructive">{{ form.errors.photos || form.errors['photos.0'] }}</p>
<p class="ih:mt-3 ih:text-xs ih:text-muted-foreground">Das erste Foto erscheint in der Übersicht. Fotos sind nur für angemeldete Mitarbeitende sichtbar.</p>
</Panel>
<div class="ih:flex ih:flex-wrap ih:items-center ih:gap-3">
<Button type="submit" :disabled="form.processing"><LoaderCircle v-if="form.processing" class="ih:animate-spin" /> {{ l ? 'Speichern' : 'Zur Freigabe einreichen' }}</Button>
<Button variant="ghost" as-child><Link :href="l ? '/kleinanzeigen/meine' : '/kleinanzeigen'"><ChevronLeft /> Abbrechen</Link></Button>
<p class="ih:text-xs ih:text-muted-foreground">{{ l ? (willReview ? 'Änderungen an Inhalt oder Fotos werden erneut geprüft.' : '') : 'Die Moderation prüft Ihre Anzeige; danach ist sie 30 Tage online.' }}</p>
</div>
</form>
</AppLayout>
</template>

View file

@ -0,0 +1,104 @@
<script setup>
import { ref, watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { Heart, ListChecks, Plus, Search, ShieldCheck, ShoppingBag } from '@lucide/vue';
import { AppLayout, Button, EmptyState, PageHeader, toast } from '@inhaus/ui';
import ListingCard from '../components/ListingCard.vue';
const props = defineProps({
listings: { type: Array, required: true },
pagination: { type: Object, required: true },
filters: { type: Object, required: true },
types: { type: Object, required: true },
categories: { type: Object, required: true },
counts: { type: Object, default: () => ({}) },
pending: { type: Number, default: null },
mine: { type: Number, default: 0 },
});
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 }), 350);
});
function apply(changes) {
const params = { ...props.filters, ...changes };
router.get('/kleinanzeigen', Object.fromEntries(Object.entries(params).filter(([key, value]) => value && !(key === 'sortierung' && value === 'neu'))), { preserveState: true, preserveScroll: true });
}
const sorts = { neu: 'Neueste zuerst', preis: 'Preis aufsteigend', 'preis-ab': 'Preis absteigend' };
</script>
<template>
<AppLayout title="Kleinanzeigen">
<PageHeader title="Kleinanzeigen" description="Von Kolleginnen und Kollegen für Kolleginnen und Kollegen – verkaufen, verschenken, suchen, tauschen.">
<template #actions>
<Button v-if="pending !== null" variant="outline" as-child>
<Link href="/kleinanzeigen/moderation"><ShieldCheck /> Freigabe<span v-if="pending" class="ih:rounded-full ih:bg-brand ih:px-1.5 ih:text-[11px] ih:text-brand-foreground">{{ pending }}</span></Link>
</Button>
<Button variant="outline" as-child><Link href="/kleinanzeigen/meine"><ListChecks /> Meine Anzeigen<span v-if="mine" class="ih:text-muted-foreground">({{ mine }})</span></Link></Button>
<Button as-child><Link href="/kleinanzeigen/neu"><Plus /> Anzeige aufgeben</Link></Button>
</template>
</PageHeader>
<div class="ih:grid ih:gap-6 ih:lg:grid-cols-[15rem_minmax(0,1fr)]">
<aside class="ih:grid ih:content-start ih:gap-5">
<div class="ih:relative">
<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="Suchen" aria-label="Anzeigen durchsuchen" class="ih:h-10 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>
<nav aria-label="Art" class="ih:flex ih:flex-wrap ih:gap-1.5">
<button type="button" class="ih:rounded-full ih:border ih:px-3 ih:py-1 ih:text-[13px]" :class="!filters.typ ? 'ih:border-brand ih:bg-brand ih:text-brand-foreground' : 'ih:bg-card ih:hover:bg-accent'" :aria-pressed="!filters.typ" @click="apply({ typ: null })">Alle</button>
<button v-for="(label, key) in types" :key="key" type="button" class="ih:rounded-full ih:border ih:px-3 ih:py-1 ih:text-[13px]" :class="filters.typ === key ? 'ih:border-brand ih:bg-brand ih:text-brand-foreground' : 'ih:bg-card ih:hover:bg-accent'" :aria-pressed="filters.typ === key" @click="apply({ typ: key })">{{ label }}</button>
</nav>
<nav aria-label="Kategorien" class="ih:hidden ih:lg:block">
<h2 class="ih:mb-1.5 ih:text-xs ih:font-semibold ih:tracking-wider ih:text-muted-foreground ih:uppercase">Kategorien</h2>
<ul class="ih:grid ih:gap-0.5 ih:text-sm">
<li><button type="button" class="ih:flex ih:w-full ih:justify-between ih:rounded ih:px-2 ih:py-1.5 ih:text-left" :class="!filters.kategorie ? 'ih:bg-brand-soft ih:font-medium ih:text-brand-text' : 'ih:hover:bg-accent'" @click="apply({ kategorie: null })">Alle Kategorien</button></li>
<li v-for="(label, key) in categories" :key="key">
<button type="button" class="ih:flex ih:w-full ih:justify-between ih:gap-2 ih:rounded ih:px-2 ih:py-1.5 ih:text-left" :class="filters.kategorie === key ? 'ih:bg-brand-soft ih:font-medium ih:text-brand-text' : 'ih:hover:bg-accent'" @click="apply({ kategorie: key })">
<span>{{ label }}</span><span class="ih:text-xs ih:text-muted-foreground ih:tabular-nums">{{ counts[key] ?? 0 }}</span>
</button>
</li>
</ul>
</nav>
<select class="ih:h-10 ih:rounded-md ih:border ih:bg-card ih:px-2 ih:text-sm ih:lg:hidden" aria-label="Kategorie" :value="filters.kategorie ?? ''" @change="apply({ kategorie: $event.target.value || null })">
<option value="">Alle Kategorien</option>
<option v-for="(label, key) in categories" :key="key" :value="key">{{ label }} ({{ counts[key] ?? 0 }})</option>
</select>
</aside>
<section class="ih:min-w-0">
<div class="ih:mb-4 ih:flex ih:flex-wrap ih:items-center ih:gap-3">
<p class="ih:flex-1 ih:text-sm ih:text-muted-foreground">{{ pagination.total }} {{ pagination.total === 1 ? 'Anzeige' : 'Anzeigen' }}</p>
<button type="button" class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-md ih:border ih:px-3 ih:py-1.5 ih:text-sm" :class="filters.merkliste ? 'ih:border-brand ih:bg-brand-soft ih:text-brand-text' : 'ih:bg-card ih:hover:bg-accent'" :aria-pressed="filters.merkliste" @click="apply({ merkliste: filters.merkliste ? null : 1 })">
<Heart class="ih:size-4" :class="filters.merkliste ? 'ih:fill-current' : ''" /> Merkliste
</button>
<select class="ih:h-9 ih:rounded-md ih:border ih:bg-card ih:px-2 ih:text-sm" aria-label="Sortierung" :value="filters.sortierung" @change="apply({ sortierung: $event.target.value })">
<option v-for="(label, key) in sorts" :key="key" :value="key">{{ label }}</option>
</select>
</div>
<div v-if="listings.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">
<ListingCard v-for="listing in listings" :key="listing.id" :listing="listing" />
</div>
<div v-else class="ih:rounded-lg ih:border ih:bg-card">
<EmptyState :icon="ShoppingBag" :title="filters.q || filters.typ || filters.kategorie || filters.merkliste ? 'Keine passenden Anzeigen' : 'Noch keine Anzeigen'" text="Etwas übrig oder auf der Suche? Geben Sie die erste Anzeige auf." />
</div>
<nav v-if="pagination.last > 1" class="ih:mt-6 ih:flex ih:items-center ih:justify-between ih:text-sm" aria-label="Seiten">
<Link v-if="pagination.prev" :href="pagination.prev" preserve-scroll class="ih:font-medium ih:text-brand-text ih:hover:underline">← Zurück</Link><span v-else />
<span class="ih:text-muted-foreground">Seite {{ pagination.current }} von {{ pagination.last }}</span>
<Link v-if="pagination.next" :href="pagination.next" preserve-scroll class="ih:font-medium ih:text-brand-text ih:hover:underline">Weiter →</Link><span v-else />
</nav>
</section>
</div>
</AppLayout>
</template>

View file

@ -0,0 +1,60 @@
<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>

View file

@ -0,0 +1,69 @@
<script setup>
import { ref, watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { Check, Flag, ImageOff, Undo2 } from '@lucide/vue';
import { AppLayout, Button, EmptyState, PageHeader, Panel, Textarea, toast } from '@inhaus/ui';
defineProps({
pending: { type: Array, required: true },
reported: { type: Array, required: true },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const notes = ref({});
const rejecting = ref(null);
const approve = (l) => router.post(`/kleinanzeigen/${l.id}/freigeben`, {}, { preserveScroll: true });
function reject(l) {
router.post(`/kleinanzeigen/${l.id}/zurueckgeben`, { note: notes.value[l.id] ?? '' }, { preserveScroll: true, onSuccess: () => (rejecting.value = null) });
}
const resolve = (l, action) => router.post(`/kleinanzeigen/${l.id}/meldungen`, { action }, { preserveScroll: true });
</script>
<template>
<AppLayout title="Kleinanzeigen – Freigabe">
<PageHeader title="Freigabe" description="Neue und geänderte Anzeigen prüfen. Die anbietende Person bekommt Bescheid." :breadcrumbs="[{ label: 'Kleinanzeigen', href: '/kleinanzeigen' }]" />
<Panel v-if="reported.length" title="Gemeldet" class="ih:mb-6">
<ul class="ih:-mx-5 ih:divide-y ih:border-t">
<li v-for="l in reported" :key="l.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-3 ih:px-5 ih:py-3">
<Flag class="ih:size-4 ih:shrink-0 ih:text-destructive" />
<div class="ih:min-w-0 ih:flex-1">
<Link :href="l.url" class="ih:font-medium ih:hover:underline">{{ l.title }}</Link>
<p class="ih:text-xs ih:text-muted-foreground">{{ l.seller }} · {{ l.reasons.join(' / ') }}</p>
</div>
<Button size="sm" variant="outline" @click="resolve(l, 'keep')">In Ordnung</Button>
<Button size="sm" variant="outline" class="ih:text-destructive ih:hover:text-destructive" @click="resolve(l, 'remove')">Offline nehmen</Button>
</li>
</ul>
</Panel>
<div v-if="pending.length" class="ih:grid ih:gap-4">
<article v-for="l in pending" :key="l.id" class="ih:grid ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-4 ih:shadow-xs ih:md:grid-cols-[12rem_minmax(0,1fr)]">
<div class="ih:grid ih:grid-cols-3 ih:content-start ih:gap-1 ih:md:grid-cols-2">
<img v-for="p in l.photos.slice(0, 4)" :key="p.id" :src="p.thumb_url" alt="" class="ih:aspect-[4/3] ih:w-full ih:rounded ih:object-cover" />
<span v-if="!l.photos.length" class="ih:col-span-2 ih:grid ih:aspect-[4/3] ih:place-items-center ih:rounded ih:bg-muted ih:text-muted-foreground"><ImageOff class="ih:size-6" /></span>
</div>
<div class="ih:min-w-0">
<p class="ih:text-xs ih:text-muted-foreground">{{ l.type_label }} · {{ l.category_label }} · von {{ l.seller?.name }}</p>
<Link :href="l.url" class="ih:text-lg ih:font-semibold ih:hover:underline">{{ l.title }}</Link>
<p v-if="l.price" class="ih:font-medium ih:text-brand-text">{{ l.price }}</p>
<p class="ih:mt-2 ih:line-clamp-4 ih:text-sm ih:whitespace-pre-line">{{ l.description }}</p>
<div v-if="rejecting === l.id" class="ih:mt-3 ih:grid ih:gap-2">
<Textarea v-model="notes[l.id]" rows="2" maxlength="500" placeholder="Begründung für die anbietende Person" aria-label="Begründung" />
<div class="ih:flex ih:gap-2">
<Button size="sm" :disabled="!(notes[l.id] ?? '').trim()" @click="reject(l)">Zurückgeben</Button>
<Button size="sm" variant="ghost" @click="rejecting = null">Abbrechen</Button>
</div>
</div>
<div v-else class="ih:mt-3 ih:flex ih:gap-2">
<Button size="sm" @click="approve(l)"><Check /> Freigeben</Button>
<Button size="sm" variant="outline" @click="rejecting = l.id"><Undo2 /> Zurückgeben …</Button>
</div>
</div>
</article>
</div>
<div v-else class="ih:rounded-lg ih:border ih:bg-card"><EmptyState :icon="Check" title="Alles erledigt" text="Keine Anzeigen warten auf Freigabe." /></div>
</AppLayout>
</template>

151
resources/js/pages/Show.vue Normal file
View file

@ -0,0 +1,151 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { Link, router, useForm, usePage } from '@inertiajs/vue3';
import { CalendarDays, ChevronLeft, ChevronRight, Flag, Heart, ImageOff, LoaderCircle, Mail, MapPin, MessageCircle, PencilLine, Phone, ShieldCheck, Trash2 } from '@lucide/vue';
import { AppLayout, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, PersonAvatar, Textarea, formatDate, toast } from '@inhaus/ui';
import ListingCard from '../components/ListingCard.vue';
const props = defineProps({
listing: { type: Object, required: true },
more: { type: Array, default: () => [] },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const l = computed(() => props.listing);
const current = ref(0);
const photo = computed(() => l.value.photos[current.value]);
const step = (delta) => (current.value = (current.value + delta + l.value.photos.length) % l.value.photos.length);
// Kontakt
const contact = useForm({ message: `Hallo ${l.value.seller?.name?.split(' ')[0] ?? ''}, ist „${l.value.title}“ noch zu haben?` });
const send = () => contact.post(`/kleinanzeigen/${l.value.id}/kontakt`, { preserveScroll: true, onSuccess: () => contact.reset() });
// Melden
const reporting = ref(false);
const report = useForm({ reason: '' });
const sendReport = () => report.post(`/kleinanzeigen/${l.value.id}/melden`, { preserveScroll: true, onSuccess: () => { reporting.value = false; report.reset(); } });
function toggleFavorite() {
router.visit(`/kleinanzeigen/${l.value.id}/merken`, { method: l.value.favorite ? 'delete' : 'post', preserveScroll: true });
}
function remove() {
window.confirm('Anzeige löschen?') && router.delete(`/kleinanzeigen/${l.value.id}`);
}
const statusNote = computed(() => ({
pending: 'Diese Anzeige wartet auf Freigabe und ist noch nicht öffentlich.',
rejected: 'Diese Anzeige wurde nicht freigegeben.',
done: 'Diese Anzeige ist erledigt.',
expired: 'Diese Anzeige ist abgelaufen.',
})[l.value.status]);
</script>
<template>
<AppLayout :title="l.title">
<div class="ih:mb-4 ih:flex ih:items-center ih:justify-between ih:gap-3">
<Link href="/kleinanzeigen" class="ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground"><ChevronLeft class="ih:size-4" /> Alle Kleinanzeigen</Link>
<div class="ih:flex ih:gap-2">
<Button v-if="l.own" variant="outline" size="sm" as-child><Link :href="`/kleinanzeigen/${l.id}/bearbeiten`"><PencilLine /> Bearbeiten</Link></Button>
<Button v-if="l.own || l.can_moderate" variant="ghost" size="sm" class="ih:text-destructive ih:hover:text-destructive" @click="remove"><Trash2 /> Löschen</Button>
</div>
</div>
<p v-if="statusNote" class="ih:mb-4 ih:rounded-md ih:border ih:bg-muted ih:px-4 ih:py-3 ih:text-sm">
{{ statusNote }}<template v-if="l.review_note"> Hinweis: {{ l.review_note }}</template>
</p>
<div class="ih:grid ih:gap-6 ih:lg:grid-cols-[minmax(0,1fr)_22rem]">
<div class="ih:grid ih:min-w-0 ih:content-start ih:gap-6">
<!-- Galerie -->
<section class="ih:overflow-hidden ih:rounded-xl ih:border ih:bg-card" aria-label="Fotos">
<div class="ih:relative ih:flex ih:aspect-[4/3] ih:items-center ih:justify-center ih:bg-muted ih:sm:aspect-[16/10]">
<img v-if="photo" :src="photo.url" :alt="`${l.title} – Foto ${current + 1}`" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<ImageOff v-else class="ih:size-10 ih:text-muted-foreground" :stroke-width="1.5" />
<template v-if="l.photos.length > 1">
<button type="button" class="ih:absolute ih:left-3 ih:grid ih:size-10 ih:place-items-center ih:rounded-full ih:bg-card/90 ih:shadow" aria-label="Vorheriges Foto" @click="step(-1)"><ChevronLeft class="ih:size-5" /></button>
<button type="button" class="ih:absolute ih:right-3 ih:grid ih:size-10 ih:place-items-center ih:rounded-full ih:bg-card/90 ih:shadow" aria-label="Nächstes Foto" @click="step(1)"><ChevronRight class="ih:size-5" /></button>
<span class="ih:absolute ih:right-3 ih:bottom-3 ih:rounded ih:bg-foreground/70 ih:px-2 ih:py-0.5 ih:text-xs ih:text-background ih:tabular-nums">{{ current + 1 }} / {{ l.photos.length }}</span>
</template>
</div>
<div v-if="l.photos.length > 1" class="ih:flex ih:gap-2 ih:overflow-x-auto ih:p-3">
<button v-for="(p, i) in l.photos" :key="p.id" type="button" class="ih:size-16 ih:shrink-0 ih:overflow-hidden ih:rounded-md ih:border-2" :class="i === current ? 'ih:border-brand' : 'ih:border-transparent ih:opacity-70 ih:hover:opacity-100'" :aria-label="`Foto ${i + 1}`" :aria-current="i === current" @click="current = i">
<img :src="p.thumb_url" alt="" class="ih:size-full ih:object-cover" />
</button>
</div>
</section>
<section class="ih:rounded-xl ih:border ih:bg-card ih:p-5 ih:sm:p-6">
<div class="ih:flex ih:flex-wrap ih:items-center ih:gap-2 ih:text-xs">
<span class="ih:rounded ih:bg-brand-soft ih:px-2 ih:py-0.5 ih:font-semibold ih:text-brand-text">{{ l.type_label }}</span>
<span class="ih:text-muted-foreground">{{ l.category_label }}</span>
<span v-if="l.reserved" class="ih:rounded ih:bg-foreground ih:px-2 ih:py-0.5 ih:font-semibold ih:text-background">Reserviert</span>
</div>
<h1 class="ih:mt-2 ih:text-2xl ih:font-semibold ih:tracking-tight ih:text-balance">{{ l.title }}</h1>
<p v-if="l.price" class="ih:mt-1 ih:text-xl ih:font-semibold ih:text-brand-text">{{ l.price }}</p>
<dl class="ih:mt-4 ih:flex ih:flex-wrap ih:gap-x-6 ih:gap-y-2 ih:text-sm ih:text-muted-foreground">
<div v-if="l.location" class="ih:flex ih:items-center ih:gap-1.5"><dt class="ih:sr-only">Ort</dt><MapPin class="ih:size-4" aria-hidden="true" /><dd>{{ l.location }}</dd></div>
<div v-if="l.published_at" class="ih:flex ih:items-center ih:gap-1.5"><dt class="ih:sr-only">Eingestellt</dt><CalendarDays class="ih:size-4" aria-hidden="true" /><dd>seit {{ formatDate(l.published_at) }}</dd></div>
</dl>
<h2 class="ih:mt-6 ih:mb-2 ih:text-sm ih:font-semibold">Beschreibung</h2>
<p class="ih:text-[15px] ih:leading-relaxed ih:whitespace-pre-line">{{ l.description }}</p>
</section>
</div>
<aside class="ih:grid ih:content-start ih:gap-4">
<section v-if="l.seller" class="ih:rounded-xl ih:border ih:bg-card ih:p-5">
<Link :href="`/personen/${l.seller.id}`" class="ih:flex ih:items-center ih:gap-3 ih:rounded-md ih:hover:bg-accent/50">
<PersonAvatar :person="l.seller" class="ih:size-12" />
<span class="ih:min-w-0">
<span class="ih:block ih:font-semibold">{{ l.seller.name }}</span>
<span class="ih:block ih:truncate ih:text-[13px] ih:text-muted-foreground">{{ [l.seller.department, l.seller.location].filter(Boolean).join(' · ') }}</span>
</span>
</Link>
<p v-if="l.seller.listings > 1" class="ih:mt-2 ih:text-xs ih:text-muted-foreground">{{ l.seller.listings }} Anzeigen online</p>
<form v-if="l.contact" class="ih:mt-4 ih:grid ih:gap-2 ih:border-t ih:pt-4" @submit.prevent="send">
<label for="kontakt" class="ih:text-sm ih:font-medium">Nachricht an {{ l.seller.name.split(' ')[0] }}</label>
<Textarea id="kontakt" v-model="contact.message" rows="4" maxlength="2000" />
<p v-if="contact.errors.message" class="ih:text-[13px] ih:text-destructive">{{ contact.errors.message }}</p>
<Button type="submit" :disabled="contact.processing || !contact.message.trim()">
<LoaderCircle v-if="contact.processing" class="ih:animate-spin" />
<component :is="l.contact === 'chat' ? MessageCircle : Mail" v-else />
{{ l.contact === 'chat' ? 'Im Chat schreiben' : 'Per E-Mail schreiben' }}
</Button>
<p class="ih:text-xs ih:text-muted-foreground">{{ l.contact === 'chat' ? 'Öffnet ein Gespräch unter „Nachrichten“.' : 'Die Antwort kommt per E-Mail; die Adresse der anbietenden Person bleibt verborgen.' }}</p>
</form>
<a v-if="l.phone" :href="`tel:${l.phone.replace(/[^0-9+]/g, '')}`" class="ih:mt-3 ih:flex ih:items-center ih:gap-2 ih:text-sm ih:font-medium ih:text-brand-text ih:hover:underline"><Phone class="ih:size-4" /> {{ l.phone }}</a>
</section>
<div v-if="!l.own" class="ih:flex ih:gap-2">
<Button variant="outline" class="ih:flex-1" :aria-pressed="l.favorite" @click="toggleFavorite"><Heart :class="l.favorite ? 'ih:fill-current ih:text-brand-text' : ''" /> {{ l.favorite ? 'Gemerkt' : 'Merken' }}</Button>
<Button variant="ghost" class="ih:text-muted-foreground" @click="reporting = true"><Flag /> Melden</Button>
</div>
<p v-if="l.can_moderate && l.status === 'pending'" class="ih:flex ih:items-center ih:gap-2 ih:text-sm"><ShieldCheck class="ih:size-4 ih:text-brand-text" /> <Link href="/kleinanzeigen/moderation" class="ih:font-medium ih:text-brand-text ih:hover:underline">Zur Freigabe</Link></p>
</aside>
</div>
<section v-if="more.length" class="ih:mt-10">
<h2 class="ih:mb-4 ih:text-lg ih:font-semibold">Das könnte Sie auch interessieren</h2>
<div class="ih:grid ih:grid-cols-2 ih:gap-3 ih:md:grid-cols-4">
<ListingCard v-for="item in more" :key="item.id" :listing="item" />
</div>
</section>
<Dialog v-model:open="reporting">
<DialogContent class="ih:sm:max-w-md">
<DialogHeader>
<DialogTitle>Anzeige melden</DialogTitle>
<DialogDescription>Was stimmt nicht? Die Moderation sieht sich die Anzeige an.</DialogDescription>
</DialogHeader>
<Textarea v-model="report.reason" rows="3" maxlength="500" placeholder="z. B. unpassend, doppelt, kein Mitarbeiterangebot …" aria-label="Grund" />
<DialogFooter>
<Button variant="ghost" @click="reporting = false">Abbrechen</Button>
<Button :disabled="report.processing || !report.reason.trim()" @click="sendReport">Melden</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</AppLayout>
</template>

View file

@ -0,0 +1,14 @@
<script setup>
import { Panel } from '@inhaus/ui';
import ListingCard from '../components/ListingCard.vue';
defineProps({ listings: { type: Array, required: true } });
</script>
<template>
<Panel title="Kleinanzeigen" action-label="Alle Anzeigen" action-href="/kleinanzeigen">
<div class="ih:grid ih:grid-cols-2 ih:gap-2">
<ListingCard v-for="l in listings" :key="l.id" :listing="l" compact />
</div>
</Panel>
</template>