feat(frontend): Add ogranization invitation

This commit is contained in:
2025-04-18 18:58:06 +02:00
parent 068dc1305f
commit 9c1cefd4ed
8 changed files with 325 additions and 26 deletions

View File

@@ -29,11 +29,11 @@
</template>
<script setup lang="ts">
const props = defineProps<{
defineProps<{
organization: ActiveOrganization
}>()
const emit = defineEmits(['update'])
const { inviteMember } = useBetterAuth()
const open = ref(false)
const loading = ref(false)
@@ -56,27 +56,9 @@ watch(open, (val) => {
async function handleSubmit() {
loading.value = true
await organization.inviteMember({
email: form.value.email,
role: form.value.role as 'member' | 'admin',
fetchOptions: {
throw: true,
onSuccess: (ctx) => {
const updatedOrg = {
...props.organization,
invitations: [...(props.organization.invitations || []), ctx.data]
}
emit('update', updatedOrg)
open.value = false
},
onError: (error) => {
useToast().add({ title: 'Fehler beim Einladen', description: error.error.message, color: 'error' })
},
onResponse: () => {
loading.value = false
}
}
})
await inviteMember(form.value.email, form.value.role as 'member' | 'admin')
loading.value = false
open.value = false
useToast().add({ title: 'Invitation sent', color: 'success' })
}
</script>