feat(frontend): Add organization creation, deletion, add better-auth organization plugin

This commit is contained in:
2025-04-06 09:35:15 +02:00
parent 99d3b28381
commit eed4b673c0
11 changed files with 496 additions and 14 deletions

View File

@@ -0,0 +1,39 @@
import type { FormSubmitEvent } from '@nuxt/ui'
export const useUserStore = defineStore('User', () => {
const name = ref('')
async function signUp(payload: FormSubmitEvent<Schema>) {
await authClient.signUp.email(
{
email: payload.data.email,
password: payload.data.password,
name: payload.data.name
},
{
onRequest: (ctx) => {
// TODO: Show loading spinner
console.log('Sending register request')
},
onResponse: () => {
// TODO: Hide loading spinner
console.log('Receiving register response')
},
onSuccess: async (ctx) => {
console.log('Successfully registered!')
await navigateTo('/')
},
onError: (ctx) => {
console.log(ctx.error.message)
useToast().add({
title: 'Fehler bei der Registrierung',
description: ctx.error.message,
color: 'success'
})
}
}
)
}
return { name, signUp }
})