feat(fullstack): Add application form status, add submissions of forms, update DB schema
This commit is contained in:
@@ -15,7 +15,15 @@
|
||||
|
||||
<UDashboardToolbar>
|
||||
<template #right>
|
||||
<UButton icon="i-lucide-file-text" size="md" color="primary" variant="solid" target="_blank" :to="`/api/application-forms/${applicationForm.id}/pdf`">PDF Vorschau</UButton>
|
||||
<UButton
|
||||
icon="i-lucide-file-text"
|
||||
size="md"
|
||||
color="primary"
|
||||
variant="solid"
|
||||
target="_blank"
|
||||
:to="`/api/application-forms/${applicationForm.id}/pdf`"
|
||||
>PDF Vorschau</UButton
|
||||
>
|
||||
</template>
|
||||
</UDashboardToolbar>
|
||||
</template>
|
||||
@@ -51,14 +59,15 @@
|
||||
>
|
||||
Next
|
||||
</UButton>
|
||||
<UButton
|
||||
v-if="!stepper?.hasNext"
|
||||
trailing-icon="i-lucide-send-horizontal"
|
||||
:disabled="isReadOnly"
|
||||
@click="onSubmit"
|
||||
>
|
||||
Submit
|
||||
</UButton>
|
||||
|
||||
<div v-if="!stepper?.hasNext" class="flex flex-wrap items-center gap-1.5">
|
||||
<UButton trailing-icon="i-lucide-save" :disabled="isReadOnly" variant="outline" @click="onSave">
|
||||
Save
|
||||
</UButton>
|
||||
<UButton trailing-icon="i-lucide-send-horizontal" :disabled="isReadOnly" @click="onSubmit">
|
||||
Submit
|
||||
</UButton>
|
||||
</div>
|
||||
</div>
|
||||
</UCard>
|
||||
</div>
|
||||
@@ -70,13 +79,14 @@
|
||||
import type { ApplicationFormDto, FormElementSectionDto } from '~/.api-client'
|
||||
import type { StepperItem } from '@nuxt/ui'
|
||||
|
||||
const { getApplicationFormById, updateApplicationForm } = useApplicationForm()
|
||||
const { getApplicationFormById, updateApplicationForm, submitApplicationForm } = useApplicationForm()
|
||||
const route = useRoute()
|
||||
const { user } = useAuth()
|
||||
const toast = useToast()
|
||||
|
||||
definePageMeta({
|
||||
// Prevent whole page from re-rendering when navigating between sections to keep state
|
||||
key: (route) => `${route.params.id}`,
|
||||
key: (route) => `${route.params.id}`
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@@ -136,10 +146,18 @@ async function navigateStepper(direction: 'forward' | 'backward') {
|
||||
await navigateTo(`/application-forms/${route.params.id}/${activeStepperItemIndex.value}`)
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
async function onSave() {
|
||||
if (data?.value) {
|
||||
await updateApplicationForm(data.value.id, data.value)
|
||||
toast.add({ title: 'Success', description: 'Application form saved', color: 'success' })
|
||||
}
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
if (data?.value) {
|
||||
await submitApplicationForm(data.value.id)
|
||||
await navigateTo('/')
|
||||
toast.add({ title: 'Success', description: 'Application form submitted', color: 'success' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user