<script setup lang="ts">
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog'
</script>
<template>
<TableCell>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button variant="ghost" class="h-8 w-8 p-0">
<span class="sr-only">{{ t('table.openMenu') }}</span>
<MoreHorizontal class="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem @click="handleEdit(item)">
<Edit class="mr-2 h-4 w-4" />
{{ t('table.actions.edit') }}
</DropdownMenuItem>
<!-- Destructive actions with confirmation -->
<AlertDialog>
<AlertDialogTrigger as-child>
<DropdownMenuItem @click.prevent class="text-destructive focus:text-destructive">
<Trash2 class="mr-2 h-4 w-4" />
{{ t('table.actions.delete') }}
</DropdownMenuItem>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{{ t('deleteDialog.title') }}</AlertDialogTitle>
<AlertDialogDescription>
{{ t('deleteDialog.description', { itemName: item.name }) }}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{{ t('deleteDialog.cancel') }}</AlertDialogCancel>
<AlertDialogAction
@click="handleDelete(item.id)"
class="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{{ t('deleteDialog.confirm') }}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</template>