import { useEffect, useState, type CSSProperties } from 'react'
import { ListChecks, Plus, Trash2, Tags } from 'lucide-react'
import { api } from './api'
import { Button } from './components/ui/button'
import { Input } from './components/ui/input'
import { Textarea } from './components/ui/textarea'
import { Field } from './App'
export function TagList({ tags = [] }: { tags?: any[] }) {
if (!tags.length) return null
return (
{tags.map((tag) => (
{tag.name}
))}
)
}
export function QueueTagsEditor({ queue, onSave }: any) {
const [tags, setTags] = useState([]),
[busy, setBusy] = useState(false)
useEffect(
() =>
setTags(
(queue.tags || []).map((tag: any) => ({
...tag,
_key: tag.id,
sendersText: tag.senders.join('\n'),
})),
),
[queue.id, queue.tags_revision],
)
const change = (index: number, key: string, value: string) =>
setTags((current) => current.map((tag, i) => (i === index ? { ...tag, [key]: value } : tag)))
return (
)
}
export function TicketChecklist({ ticketId, items, editable, onReload }: any) {
const [text, setText] = useState(''),
[key, setKey] = useState(crypto.randomUUID()),
[busy, setBusy] = useState(false),
[error, setError] = useState('')
const mutate = async (path: string, method: string, data: any) => {
setBusy(true)
setError('')
try {
await api(path, method, data)
await onReload()
return true
} catch (e) {
setError((e as Error).message)
await onReload()
return false
} finally {
setBusy(false)
}
}
return (
Checkliste
{items.filter((item: any) => item.done).length} / {items.length}
{error && (
{error}
)}
{!items.length && Noch keine Punkte vorhanden.
}
{editable && (
)}
)
}