import { useState } from "react"; import { useTranslation } from "react-i18next"; import type { components } from "../api/schema"; import { useUpdateTerm, useDeleteTerm } from "../api/queries"; import { LabelEditor } from "../components/label-editor"; import { DeleteConfirmDialog } from "../components/delete-confirm-dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { labelText } from "../lib/labels"; type TermView = components["schemas"]["TermView"]; type LabelInput = components["schemas"]["LabelInput"]; export function TermRow({ vocabularyId, term, lang }: { vocabularyId: string; term: TermView; lang: string }) { const { t } = useTranslation(); const updateTerm = useUpdateTerm(); const deleteTerm = useDeleteTerm(); const [editing, setEditing] = useState(false); const [labels, setLabels] = useState(term.labels as LabelInput[]); const [uri, setUri] = useState(term.external_uri ?? ""); if (editing) { return (
  • setUri(e.target.value)} />
  • ); } return (
  • {labelText(term.labels, lang)} deleteTerm.mutateAsync({ vocabularyId, termId: term.id })} />
  • ); }