feat(fullstack): Add contact form

This commit is contained in:
2026-02-08 18:21:07 +01:00
parent 43aef3b5b1
commit 36132a3bef
12 changed files with 420 additions and 11 deletions

View File

@@ -0,0 +1,13 @@
import { useContactApi } from './useContactApi'
export function useContact() {
const { sendContactMessage: sendContactMessageApi } = useContactApi()
async function sendContactMessage(subject: string, message: string): Promise<void> {
return sendContactMessageApi({ subject, message })
}
return {
sendContactMessage
}
}

View File

@@ -0,0 +1,24 @@
import { ContactApi, Configuration, type ContactMessageDto } from '~~/.api-client'
import { cleanDoubleSlashes, withoutTrailingSlash } from 'ufo'
import { wrappedFetchWrap } from '~/utils/wrappedFetch'
export function useContactApi() {
const appBaseUrl = useRuntimeConfig().app.baseURL
const { serverApiBasePath, clientProxyBasePath } = useRuntimeConfig().public
const basePath = withoutTrailingSlash(
cleanDoubleSlashes(import.meta.client ? appBaseUrl + clientProxyBasePath : clientProxyBasePath + serverApiBasePath)
)
const contactApiClient = new ContactApi(
new Configuration({ basePath, fetchApi: wrappedFetchWrap(useRequestFetch()) })
)
async function sendContactMessage(contactMessageDto: ContactMessageDto): Promise<void> {
return contactApiClient.sendContactMessage({ contactMessageDto })
}
return {
sendContactMessage
}
}

View File

@@ -5,3 +5,5 @@ export { useApplicationFormVersionApi } from './applicationFormVersion/useApplic
export { useNotificationApi } from './notification/useNotificationApi'
export { useUser } from './user/useUser'
export { useUserApi } from './user/useUserApi'
export { useContact } from './contact/useContact'
export { useContactApi } from './contact/useContactApi'