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:
parent
01b871e7fa
commit
9b1b56e05d
1 changed files with 22 additions and 6 deletions
|
|
@ -48,11 +48,13 @@ function canEdit(event: TicketedEvent): boolean {
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!isAuthenticated.value) return
|
if (!isAuthenticated.value) return
|
||||||
const adminKey = currentUser.value?.wallets?.[0]?.adminkey
|
const wallet = currentUser.value?.wallets?.[0]
|
||||||
if (!adminKey) return
|
if (!wallet?.inkey) return
|
||||||
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
|
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
|
||||||
isAdmin.value = await ticketApi.isAdmin(adminKey)
|
autoApprove.value = await ticketApi.getAutoApprove(wallet.inkey)
|
||||||
autoApprove.value = await ticketApi.getAutoApprove(adminKey)
|
if (wallet.adminkey) {
|
||||||
|
isAdmin.value = await ticketApi.isAdmin(wallet.adminkey)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function formatDate(dateStr: string | null | undefined) {
|
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">
|
<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">
|
<Card v-for="event in upcomingEvents" :key="event.id" class="flex flex-col">
|
||||||
<CardHeader>
|
<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>
|
<CardDescription>{{ event.info }}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent class="flex-grow">
|
<CardContent class="flex-grow">
|
||||||
|
|
@ -186,13 +197,18 @@ function handleEventChanged() {
|
||||||
<Button
|
<Button
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
variant="default"
|
variant="default"
|
||||||
:disabled="event.amount_tickets <= event.sold || !isAuthenticated"
|
:disabled="
|
||||||
|
event.status !== 'approved' ||
|
||||||
|
event.amount_tickets <= event.sold ||
|
||||||
|
!isAuthenticated
|
||||||
|
"
|
||||||
@click="handlePurchaseClick(event)"
|
@click="handlePurchaseClick(event)"
|
||||||
>
|
>
|
||||||
<span v-if="!isAuthenticated" class="flex items-center gap-2">
|
<span v-if="!isAuthenticated" class="flex items-center gap-2">
|
||||||
<LogIn class="w-4 h-4" />
|
<LogIn class="w-4 h-4" />
|
||||||
Login to Purchase
|
Login to Purchase
|
||||||
</span>
|
</span>
|
||||||
|
<span v-else-if="event.status !== 'approved'">Not yet available</span>
|
||||||
<span v-else>Buy Ticket</span>
|
<span v-else>Buy Ticket</span>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue