add delete team to frontend
CI/CD / test_and_check_app (push) Successful in 1m47s
CI/CD / Publish immutable image (push) Successful in 1m11s

This commit is contained in:
2026-09-29 22:38:14 +02:00
parent 7fcab70d16
commit bdd8487c34
3 changed files with 58 additions and 19 deletions
+51 -12
View File
@@ -15,6 +15,14 @@ import {
} from '@/components/ui/table';
import { Button } from '@/components/ui/button';
import { Eye, Pencil, Plus, Trash } from '@lucide/vue';
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
import { ref } from 'vue';
defineOptions({
layout: {
@@ -32,6 +40,7 @@ defineProps<{
}>();
const user = usePage().props.auth.user;
const deleteTeam = ref<Team | null>(null);
const openTeam = (team: Team) =>
router.visit(teamRoutes.show({ team: team.slug }).url);
@@ -41,9 +50,43 @@ const canManageTeam = (team: Team) =>
const canDeleteTeam = (team: Team) =>
team.members.find((member) => member.email === user.email)?.role === 'owner';
const deleteTeamAction = (team: Team) => {
router.delete(teamRoutes.destroy({ team: team.slug }).url);
deleteTeam.value = null;
};
</script>
<template>
<Dialog
v-if="deleteTeam != null"
:open="true"
@update:open="deleteTeam = null"
>
<DialogContent class="sm:max-w-md">
<DialogHeader class="flex items-start justify-start">
<DialogTitle>{{ deleteTeam.name }} unwiderruflich löschen?</DialogTitle>
<DialogDescription>
Bist du sicher, dass du das Team, {{ deleteTeam.name }}, mit
{{ deleteTeam.members.length }} Mitgliedern, löschen möchtest?
</DialogDescription>
<div class="flex w-full items-end justify-end gap-4">
<Button
class="cursor-pointer"
variant="outline"
@click="deleteTeam = null"
>Abbrechen</Button
>
<Button
class="cursor-pointer"
variant="destructive"
@click="deleteTeamAction(deleteTeam)"
>Löschen</Button
>
</div>
</DialogHeader>
</DialogContent>
</Dialog>
<div class="flex flex-col justify-center p-16">
<Head title="Teams" />
<div class="flex w-full justify-end py-4">
@@ -79,9 +122,9 @@ const canDeleteTeam = (team: Team) =>
<TableCell>{{ team.name }}</TableCell>
<TableCell>{{ team.slug }}</TableCell>
<TableCell>{{ team.members.length }}</TableCell>
<TableCell>{{
team.multi_factor_required ? 'Ja' : 'Nein'
}}</TableCell>
<TableCell
>{{ team.multi_factor_required ? 'Ja' : 'Nein' }}
</TableCell>
<TableCell class="flex justify-end gap-4">
<Link
:href="
@@ -97,18 +140,14 @@ const canDeleteTeam = (team: Team) =>
size="18"
/>
</Link>
<Link
<component
:is="Trash"
v-if="canDeleteTeam(team)"
:href="
teamRoutes.destroy({
team: team.slug,
})
"
class="cursor-pointer text-red-500"
size="18"
@click="deleteTeam = team"
@click.stop
>
<component :is="Trash" size="18" />
</Link>
/>
</TableCell>
</TableRow>
</TableBody>