Kundenportal arbeiten
This commit is contained in:
@@ -50,10 +50,12 @@ const route = useRoute()
|
||||
const dataStore = useDataStore()
|
||||
const modal = useModal()
|
||||
const auth = useAuthStore()
|
||||
const toast = useToast()
|
||||
|
||||
const dataType = dataStore.dataTypes[type]
|
||||
|
||||
const openTab = ref(String(route.query.tabIndex || 0))
|
||||
const portalInviteLoading = ref(false)
|
||||
|
||||
|
||||
|
||||
@@ -152,6 +154,31 @@ const openCustomerInventoryLabelPrint = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const invitePortalUser = async () => {
|
||||
if (type !== "customers" || !props.item?.id) return
|
||||
|
||||
portalInviteLoading.value = true
|
||||
|
||||
try {
|
||||
const response = await useAdmin().invitePortalUser(Number(props.item.id))
|
||||
toast.add({
|
||||
title: "Portal-Einladung versendet",
|
||||
description: `E-Mail: ${response.email}${response.initialPassword ? ` | Initialpasswort: ${response.initialPassword}` : ""}`,
|
||||
timeout: 9000
|
||||
})
|
||||
emit("updateNeeded")
|
||||
} catch (err) {
|
||||
toast.add({
|
||||
title: "Portal-Einladung fehlgeschlagen",
|
||||
description: err?.data?.error || "Die Einladung konnte nicht erstellt werden.",
|
||||
color: "error",
|
||||
timeout: 7000
|
||||
})
|
||||
} finally {
|
||||
portalInviteLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -217,6 +244,15 @@ const openCustomerInventoryLabelPrint = () => {
|
||||
>
|
||||
Label
|
||||
</UButton>
|
||||
<UButton
|
||||
v-if="type === 'customers' && auth.user?.is_admin"
|
||||
icon="i-heroicons-envelope"
|
||||
variant="outline"
|
||||
:loading="portalInviteLoading"
|
||||
@click="invitePortalUser"
|
||||
>
|
||||
Portal einladen
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="router.push(`/standardEntity/${type}/edit/${item.id}`)"
|
||||
>
|
||||
@@ -246,6 +282,15 @@ const openCustomerInventoryLabelPrint = () => {
|
||||
>
|
||||
Label
|
||||
</UButton>
|
||||
<UButton
|
||||
v-if="type === 'customers' && auth.user?.is_admin"
|
||||
icon="i-heroicons-envelope"
|
||||
variant="outline"
|
||||
:loading="portalInviteLoading"
|
||||
@click="invitePortalUser"
|
||||
>
|
||||
Portal einladen
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="router.push(`/standardEntity/${type}/edit/${item.id}`)"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user