feat(activities): status badge + buy-disabled on own pending events

Show a "Pending review" (or "Rejected") badge on the user's own
non-approved events, and disable the Buy Ticket button on any
non-approved event with a "Not yet available" label. Probe
auto_approve via the public endpoint with inkey, not adminkey, so the
warning copy works for non-admin owners.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-05-21 15:55:19 +02:00
commit 9b1b56e05d

View file

@ -48,11 +48,13 @@ function canEdit(event: TicketedEvent): boolean {
onMounted(async () => {
if (!isAuthenticated.value) return
const adminKey = currentUser.value?.wallets?.[0]?.adminkey
if (!adminKey) return
const wallet = currentUser.value?.wallets?.[0]
if (!wallet?.inkey) return
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
isAdmin.value = await ticketApi.isAdmin(adminKey)
autoApprove.value = await ticketApi.getAutoApprove(adminKey)
autoApprove.value = await ticketApi.getAutoApprove(wallet.inkey)
if (wallet.adminkey) {
isAdmin.value = await ticketApi.isAdmin(wallet.adminkey)
}
})
function formatDate(dateStr: string | null | undefined) {
@ -159,7 +161,16 @@ function handleEventChanged() {
<div class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
<Card v-for="event in upcomingEvents" :key="event.id" class="flex flex-col">
<CardHeader>
<CardTitle class="text-foreground">{{ event.name }}</CardTitle>
<div class="flex items-start justify-between gap-2">
<CardTitle class="text-foreground">{{ event.name }}</CardTitle>
<Badge
v-if="canEdit(event) && event.status !== 'approved'"
:variant="event.status === 'rejected' ? 'destructive' : 'secondary'"
class="shrink-0 capitalize"
>
{{ event.status === 'rejected' ? 'Rejected' : 'Pending review' }}
</Badge>
</div>
<CardDescription>{{ event.info }}</CardDescription>
</CardHeader>
<CardContent class="flex-grow">
@ -186,13 +197,18 @@ function handleEventChanged() {
<Button
class="flex-1"
variant="default"
:disabled="event.amount_tickets <= event.sold || !isAuthenticated"
:disabled="
event.status !== 'approved' ||
event.amount_tickets <= event.sold ||
!isAuthenticated
"
@click="handlePurchaseClick(event)"
>
<span v-if="!isAuthenticated" class="flex items-center gap-2">
<LogIn class="w-4 h-4" />
Login to Purchase
</span>
<span v-else-if="event.status !== 'approved'">Not yet available</span>
<span v-else>Buy Ticket</span>
</Button>
<Button