v1.33: Eintraege in allen Listen loeschbar
This commit is contained in:
+19
-2
@@ -1,6 +1,6 @@
|
||||
import { useMemo, useState } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { Plus, Wrench, CalendarDays, MapPin, MessagesSquare } from 'lucide-react'
|
||||
import { Plus, Wrench, CalendarDays, MapPin, MessagesSquare, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import {
|
||||
@@ -143,9 +143,15 @@ function NewTicketDialog() {
|
||||
}
|
||||
|
||||
export default function Tickets() {
|
||||
const { tickets, units, role, setTicketStatus, meineEinheit, threads } = useStore()
|
||||
const { tickets, units, role, setTicketStatus, meineEinheit, threads, deleteTicket } = useStore()
|
||||
const [filter, setFilter] = useState<'alle' | TicketStatus>('alle')
|
||||
|
||||
const loescheTicket = async (id: string, titel: string) => {
|
||||
if (!window.confirm(`Schadensmeldung „${titel}" wirklich löschen? Die zugehörige Kommunikation wird mitgelöscht.`)) return
|
||||
const fehler = await deleteTicket(id)
|
||||
if (fehler) window.alert(fehler)
|
||||
}
|
||||
|
||||
const threadFuerTicket = (ticketId: string) => threads.find((th) => th.ticketId === ticketId)
|
||||
|
||||
const visible = useMemo(
|
||||
@@ -242,6 +248,17 @@ export default function Tickets() {
|
||||
) : (
|
||||
<Badge className={statusStyle[t.status]} variant="secondary">{t.status}</Badge>
|
||||
)}
|
||||
{role === 'admin' && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => loescheTicket(t.id, t.title)}
|
||||
title="Schadensmeldung löschen"
|
||||
aria-label={`Schadensmeldung ${t.title} löschen`}
|
||||
className="text-slate-400 transition-colors hover:text-red-600 dark:text-slate-500 dark:hover:text-red-400"
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user