69 lines
4.5 KiB
Vue
69 lines
4.5 KiB
Vue
<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>
|