feat(frontend): Add ogranization invitation
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user