47 lines
2.6 KiB
Vue
47 lines
2.6 KiB
Vue
<script setup>
|
|
import { ref, watch } from 'vue';
|
|
import { Link, router, usePage } from '@inertiajs/vue3';
|
|
import { Compass, Plus, Search } from '@lucide/vue';
|
|
import { AppLayout, Button, EmptyState, PageHeader, toast } from '@inhaus/ui';
|
|
import GroupCard from '../components/GroupCard.vue';
|
|
import GroupDialog from '../components/GroupDialog.vue';
|
|
|
|
const props = defineProps({
|
|
groups: { type: Array, required: true },
|
|
pagination: { type: Object, required: true },
|
|
q: { type: String, default: '' },
|
|
privacy: { type: Object, required: true },
|
|
privacyHints: { type: Object, required: true },
|
|
});
|
|
|
|
const page = usePage();
|
|
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
|
|
const query = ref(props.q);
|
|
const creating = ref(false);
|
|
let timer;
|
|
watch(query, (value) => {
|
|
clearTimeout(timer);
|
|
timer = setTimeout(() => router.get('/gruppen/entdecken', value ? { q: value } : {}, { preserveState: true }), 300);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<AppLayout title="Gruppen entdecken">
|
|
<PageHeader title="Gruppen entdecken" :breadcrumbs="[{ label: 'Gruppen', href: '/gruppen' }]">
|
|
<template #actions><Button @click="creating = true"><Plus /> Gruppe gründen</Button></template>
|
|
</PageHeader>
|
|
<div class="ih:relative ih:mb-5 ih:max-w-md">
|
|
<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="Gruppen suchen" aria-label="Gruppen suchen" 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" />
|
|
</div>
|
|
<div v-if="groups.length" class="ih:grid ih:gap-4 ih:sm:grid-cols-2 ih:lg:grid-cols-3 ih:xl:grid-cols-4">
|
|
<GroupCard v-for="g in groups" :key="g.id" :group="g" />
|
|
</div>
|
|
<div v-else class="ih:rounded-xl ih:border ih:bg-card"><EmptyState :icon="Compass" :title="q ? 'Keine passenden Gruppen' : 'Noch keine Gruppen'" text="Gründen Sie die erste!" /></div>
|
|
<nav v-if="pagination.prev || pagination.next" class="ih:mt-6 ih:flex ih:justify-between ih:text-sm">
|
|
<Link v-if="pagination.prev" :href="pagination.prev" class="ih:text-brand-text ih:hover:underline">← Zurück</Link><span v-else />
|
|
<Link v-if="pagination.next" :href="pagination.next" class="ih:text-brand-text ih:hover:underline">Weiter →</Link>
|
|
</nav>
|
|
<GroupDialog v-model:open="creating" :privacy="privacy" :privacy-hints="privacyHints" />
|
|
</AppLayout>
|
|
</template>
|