import { useState } from "react"; import { useTranslation } from "react-i18next"; import type { components } from "../api/schema"; import { useUpdateAuthority, useDeleteAuthority } 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 AuthorityView = components["schemas"]["AuthorityView"]; type LabelInput = components["schemas"]["LabelInput"]; export function AuthorityRow({ authority, kind, lang }: { authority: AuthorityView; kind: string; lang: string }) { const { t } = useTranslation(); const updateAuthority = useUpdateAuthority(); const deleteAuthority = useDeleteAuthority(); const [editing, setEditing] = useState(false); const [labels, setLabels] = useState(authority.labels as LabelInput[]); const [uri, setUri] = useState(authority.external_uri ?? ""); if (editing) { return (
  • setUri(e.target.value)} />
  • ); } return (
  • {labelText(authority.labels, lang)} deleteAuthority.mutateAsync({ id: authority.id, kind })} />
  • ); }