Change for Agrar
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 32s
Build and Push Docker Images / build-frontend (push) Successful in 1m10s

This commit is contained in:
2026-01-26 22:04:27 +01:00
parent c56fcfbd14
commit 2aed851224
3 changed files with 72 additions and 124 deletions

View File

@@ -1,22 +1,21 @@
<script setup>
definePageMeta({
layout: 'blank', // Kein Menü, keine Sidebar
middleware: [], // Keine Auth-Checks durch Nuxt
auth: false // Falls du das nuxt-auth Modul nutzt
layout: 'blank',
middleware: [],
auth: false
})
const config = useRuntimeConfig()
const route = useRoute()
const token = route.params.token
const { $api } = useNuxtApp() // Dein Fetch-Wrapper
const toast = useToast()
// States
const status = ref('loading') // loading, pin_required, ready, error, success
const pin = ref('')
const context = ref(null)
const errorMsg = ref('')
// Daten laden
// Hilfs-Key um die Form-Komponente bei Reset komplett neu zu initialisieren
const formKey = ref(0)
const loadContext = async () => {
status.value = 'loading'
errorMsg.value = ''
@@ -25,19 +24,16 @@ const loadContext = async () => {
const headers = {}
if (pin.value) headers['x-public-pin'] = pin.value
// Abruf an dein Fastify Backend
// Pfad evtl. anpassen, wenn du Proxy nutzt
const res = await $fetch(`${config.public.apiBase}/workflows/context/${token}`, { headers })
context.value = res
status.value = 'ready'
} catch (err) {
if (err.statusCode === 401) {
status.value = 'pin_required' // PIN nötig (aber noch keine eingegeben)
} else if (err.statusCode === 403) {
if (err.statusCode === 401 || err.statusCode === 403) {
status.value = 'pin_required'
errorMsg.value = 'Falsche PIN'
pin.value = ''
if (err.statusCode === 403) {
errorMsg.value = 'Falsche PIN'
pin.value = ''
}
} else {
status.value = 'error'
errorMsg.value = 'Link ungültig oder abgelaufen.'
@@ -45,7 +41,6 @@ const loadContext = async () => {
}
}
// Initialer Aufruf
onMounted(() => {
loadContext()
})
@@ -57,6 +52,13 @@ const handlePinSubmit = () => {
const handleFormSuccess = () => {
status.value = 'success'
}
const resetForm = () => {
// PIN wird NICHT geleert
errorMsg.value = ''
formKey.value++ // Erzwingt Neu-Initialisierung der Kind-Komponente
loadContext() // Lädt Daten neu (Status geht auf loading -> ready)
}
</script>
<template>
@@ -83,7 +85,6 @@ const handleFormSuccess = () => {
<h2 class="text-xl font-bold text-gray-900">Geschützter Bereich</h2>
<p class="text-sm text-gray-500">Bitte PIN eingeben</p>
</div>
<form @submit.prevent="handlePinSubmit" class="space-y-4">
<UInput
v-model="pin"
@@ -104,12 +105,13 @@ const handleFormSuccess = () => {
</div>
<h2 class="text-2xl font-bold text-gray-900 mb-2">Gespeichert!</h2>
<p class="text-gray-500 mb-6">Die Daten wurden erfolgreich übertragen.</p>
<UButton variant="outline" @click="() => window.location.reload()">Neuen Eintrag erfassen</UButton>
<UButton variant="outline" @click="resetForm">Neuen Eintrag erfassen</UButton>
</UCard>
<div v-else-if="status === 'ready'" class="w-full max-w-lg">
<PublicDynamicForm
v-if="context && token"
:key="formKey"
:context="context"
:token="token"
:pin="pin"