diff --git a/src/App.vue b/src/App.vue index 1cabf7f..ba1cb51 100644 --- a/src/App.vue +++ b/src/App.vue @@ -191,6 +191,9 @@ const isEventEditorOpen = ref(false) const notificationStats = ref({ configured: false, subscriberCount: 0 }) const notificationMessage = ref('') const notificationError = ref('') +const signupNotificationMessage = ref('') +const signupNotificationError = ref('') +const isSignupNotificationLoading = ref(false) const payments = ref([]) const cards = ref([]) const accessLogs = ref([]) @@ -361,6 +364,7 @@ const canContinue = computed(() => { if (signupStep.value === 4) return DATA_IMAGE_PATTERN.test(form.signature) return true }) +const signupNotificationSupport = computed(() => notificationSupport()) const pwaInstallTitle = computed(() => { if (isPwaStandalone.value) return 'PWA installed' if (installPlatform.value === 'ios') return 'Install L484 on iPhone' @@ -772,11 +776,14 @@ const openSignup = () => { loadBitcoinPrice() refreshPwaStandalone() installPlatform.value = detectInstallPlatform() - signupStep.value = currentMember.value ? 5 : 0 + signupStep.value = currentMember.value ? 6 : 0 createdMember.value = currentMember.value isCardRevealing.value = false generatedCredentials.value = null formError.value = '' + signupNotificationMessage.value = '' + signupNotificationError.value = '' + isSignupNotificationLoading.value = false } const openMemberSignin = () => { @@ -839,6 +846,7 @@ const resetForm = () => { const nextStep = () => { formError.value = '' + signupNotificationError.value = '' sanitizeForm() if (signupStep.value === 2 && !validateApplicant()) { @@ -960,6 +968,7 @@ const handleSignerCompletion = async () => { } const createMembership = async () => { + formError.value = '' sanitizeForm() if (!validateApplicant()) { return @@ -1011,7 +1020,7 @@ const createMembership = async () => { saveMembers() resetForm() isCardRevealing.value = true - signupStep.value = 5 + signupStep.value = 6 window.setTimeout(() => { isCardRevealing.value = false @@ -1021,6 +1030,21 @@ const createMembership = async () => { } } +const enableSignupNotificationsAndCreate = async () => { + signupNotificationMessage.value = '' + signupNotificationError.value = '' + isSignupNotificationLoading.value = true + try { + const result = await subscribeToNotifications() + signupNotificationMessage.value = `Notifications enabled. ${result.subscriberCount || 1} device subscribed.` + await createMembership() + } catch (error) { + signupNotificationError.value = error instanceof Error ? error.message : 'Could not enable notifications.' + } finally { + isSignupNotificationLoading.value = false + } +} + const syncSignatureCanvas = () => { const canvas = signatureCanvas.value if (!canvas) return @@ -3229,23 +3253,25 @@ watch(mobileMenuOpen, (open) => {