35 lines
1.9 KiB
Vue
35 lines
1.9 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import Link from '../components/Link.vue';
|
|
import { t } from '../i18n';
|
|
import { state } from '../state';
|
|
|
|
// Pages and reviews are still plain lists (a paginated answer), so one read-only screen shows both.
|
|
const props = defineProps<{ data: Record<string, any>[]; current_page: number; last_page: number; path: string }>();
|
|
|
|
const kind = computed(() => (state.path.includes('/reviews') ? 'reviews' : 'pages'));
|
|
const heading = computed(() => (kind.value === 'reviews' ? 'Reviews' : 'Pages'));
|
|
const title = (row: Record<string, any>) => (kind.value === 'reviews' ? row.author : row.title);
|
|
const detail = (row: Record<string, any>) => (kind.value === 'reviews' ? (row.rating ? '★'.repeat(row.rating) : '') : row.slug);
|
|
const live = (row: Record<string, any>) => (kind.value === 'reviews' ? row.is_visible : row.is_published);
|
|
const page = (n: number) => `${state.path.split('?')[0]}?page=${n}`;
|
|
</script>
|
|
|
|
<template>
|
|
<h1 class="font-display mb-6 text-2xl font-bold">{{ t(heading) }}</h1>
|
|
<p v-if="!props.data.length" class="m-card p-5 text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
|
<ul v-else class="m-card divide-y divide-line">
|
|
<li v-for="row in props.data" :key="row.id" class="flex items-center justify-between gap-3 p-4">
|
|
<div class="min-w-0">
|
|
<p class="truncate font-semibold">{{ title(row) }}</p>
|
|
<p class="truncate text-xs text-muted">{{ detail(row) }}</p>
|
|
</div>
|
|
<span class="m-badge">{{ live(row) ? t('Published') : t('Draft') }}</span>
|
|
</li>
|
|
</ul>
|
|
<nav v-if="props.last_page > 1" class="mt-4 flex gap-2">
|
|
<Link v-if="props.current_page > 1" :href="page(props.current_page - 1)" class="m-btn m-btn-secondary">{{ t('Previous') }}</Link>
|
|
<Link v-if="props.current_page < props.last_page" :href="page(props.current_page + 1)" class="m-btn m-btn-secondary">{{ t('Next') }}</Link>
|
|
</nav>
|
|
</template>
|