feat(activities-app): wire shell dialog for edit + approval probes
Probe isAdmin / autoApprove once at auth-ready (re-probe on login) and feed them plus the store's editingEvent into the shell-mounted CreateEventDialog. Add handleUpdateEvent that picks the right wallet admin key from the editing event's wallet id. Without this the Activities standalone app could only Create — the existing dialog was create-only at shell level even though the dialog component itself already supported edit mode. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a77bf7ff6c
commit
345ca073af
1 changed files with 46 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { CalendarDays, Map, Heart, Search, Plus } from 'lucide-vue-next'
|
import { CalendarDays, Map, Heart, Search, Plus } from 'lucide-vue-next'
|
||||||
|
|
@ -17,6 +17,26 @@ const { t } = useI18n()
|
||||||
const { isAuthenticated, currentUser } = useAuth()
|
const { isAuthenticated, currentUser } = useAuth()
|
||||||
const activitiesStore = useActivitiesStore()
|
const activitiesStore = useActivitiesStore()
|
||||||
|
|
||||||
|
// Probe LNbits admin status + extension auto_approve once at auth-ready
|
||||||
|
// so the shell-mounted dialog renders the right warning copy when an
|
||||||
|
// owner edits their own event.
|
||||||
|
const isAdmin = ref(false)
|
||||||
|
const autoApprove = ref(false)
|
||||||
|
async function probeApprovalState() {
|
||||||
|
if (!isAuthenticated.value) return
|
||||||
|
const wallet = currentUser.value?.wallets?.[0]
|
||||||
|
if (!wallet?.inkey) return
|
||||||
|
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
|
||||||
|
autoApprove.value = await ticketApi.getAutoApprove(wallet.inkey)
|
||||||
|
if (wallet.adminkey) {
|
||||||
|
isAdmin.value = await ticketApi.isAdmin(wallet.adminkey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onMounted(probeApprovalState)
|
||||||
|
watch(isAuthenticated, (yes) => {
|
||||||
|
if (yes) probeApprovalState()
|
||||||
|
})
|
||||||
|
|
||||||
// Settings dropped — theme/lang/currency now live in the shared profile sheet.
|
// Settings dropped — theme/lang/currency now live in the shared profile sheet.
|
||||||
// Create lives in the bottom nav (auth-gated): activity creation is a deliberate
|
// Create lives in the bottom nav (auth-gated): activity creation is a deliberate
|
||||||
// act, surfacing it as a tab keeps it one tap away when authed and out of the
|
// act, surfacing it as a tab keeps it one tap away when authed and out of the
|
||||||
|
|
@ -57,14 +77,38 @@ async function handleCreateEvent(eventData: CreateEventRequest) {
|
||||||
if (!invoiceKey) throw new Error('No wallet available. Please log in first.')
|
if (!invoiceKey) throw new Error('No wallet available. Please log in first.')
|
||||||
await ticketApi.createEvent(eventData, invoiceKey)
|
await ticketApi.createEvent(eventData, invoiceKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleUpdateEvent(eventId: string, eventData: CreateEventRequest) {
|
||||||
|
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
|
||||||
|
// PUT /events/{id} requires the event's wallet admin key.
|
||||||
|
const wallet = (currentUser.value?.wallets ?? []).find(
|
||||||
|
(w) => w.id === activitiesStore.editingEvent?.wallet,
|
||||||
|
)
|
||||||
|
const adminKey = wallet?.adminkey
|
||||||
|
if (!adminKey) {
|
||||||
|
throw new Error("Can't find the admin key for this event's wallet.")
|
||||||
|
}
|
||||||
|
await ticketApi.updateEvent(eventId, eventData, adminKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDialogOpenChange(open: boolean) {
|
||||||
|
activitiesStore.showCreateDialog = open
|
||||||
|
// Closing always clears the edit selection so the next "+ Create"
|
||||||
|
// opens clean instead of inheriting the last-edited event.
|
||||||
|
if (!open) activitiesStore.editingEvent = null
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppShell :tabs="tabs" :is-active="isActive">
|
<AppShell :tabs="tabs" :is-active="isActive">
|
||||||
<CreateEventDialog
|
<CreateEventDialog
|
||||||
:open="activitiesStore.showCreateDialog"
|
:open="activitiesStore.showCreateDialog"
|
||||||
@update:open="activitiesStore.showCreateDialog = $event"
|
:event="activitiesStore.editingEvent"
|
||||||
|
:is-admin="isAdmin"
|
||||||
|
:auto-approve="autoApprove"
|
||||||
:on-create-event="handleCreateEvent"
|
:on-create-event="handleCreateEvent"
|
||||||
|
:on-update-event="handleUpdateEvent"
|
||||||
|
@update:open="handleDialogOpenChange"
|
||||||
/>
|
/>
|
||||||
</AppShell>
|
</AppShell>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue