import type { BoardLabel } from "@vtit-agent-coding/shared"; import { Pencil, Trash2 } from "lucide-react"; import { useState } from "react"; import { useParams } from "react-router-dom"; import { DeleteLabelDialog, LabelFormDialog, type LabelFormMode } from "../components/BoardLabelDialogs"; import { BoardSettingsNav } from "../components/BoardSettingsNav"; import { LabelChip } from "../components/LabelChip"; import { Button } from "../components/ui/button"; import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "../components/ui/card"; import { Skeleton } from "../components/ui/skeleton"; import { useBoard, useCreateBoardLabel, useDeleteBoardLabel, useUpdateBoardLabel } from "../hooks/useBoard"; export function BoardLabelsPage() { const { boardId } = useParams<{ boardId: string }>(); const { board, loading } = useBoard(boardId); const [formMode, setFormMode] = useState("create"); const [formOpen, setFormOpen] = useState(false); const [editingLabel, setEditingLabel] = useState(null); const [deleteName, setDeleteName] = useState(null); const [error, setError] = useState(null); const createLabel = useCreateBoardLabel(); const updateLabel = useUpdateBoardLabel(); const deleteLabel = useDeleteBoardLabel(); if (loading) return ; if (!board || !boardId) return ; const currentBoardId = boardId; function openCreateDialog() { setError(null); setFormMode("create"); setEditingLabel(null); setFormOpen(true); } function openEditDialog(label: BoardLabel) { setError(null); setFormMode("edit"); setEditingLabel(label); setFormOpen(true); } async function submitLabel(input: BoardLabel) { setError(null); try { if (formMode === "create") { await createLabel.mutateAsync({ boardId: currentBoardId, ...input }); } else { await updateLabel.mutateAsync({ boardId: currentBoardId, name: editingLabel!.name, nextName: input.name, color: input.color, description: input.description, }); } setFormOpen(false); } catch (err) { setError(err instanceof Error ? err.message : "Unable to save label"); } } async function confirmDeleteLabel() { setError(null); try { await deleteLabel.mutateAsync({ boardId: currentBoardId, name: deleteName! }); setDeleteName(null); } catch (err) { setError(err instanceof Error ? err.message : "Unable to delete label"); } } return (

{board.name}

Labels

Board labels

Labels are available to tasks on this board.
{board.labels?.length ? (
    {board.labels.map((label: BoardLabel) => (
  • {label.description || "No description"}

  • ))}
) : (

No labels yet.

)}
setFormOpen(false)} onSubmit={submitLabel} /> setDeleteName(null)} onConfirm={confirmDeleteLabel} />
); } function BoardLabelsLoading() { return (
); } function BoardLabelsNotFound() { return (
Board not found
); }