import { Button } from "@repo/shadcn-ui/components/button"; import { EntityAction, EntityListHeader, EntityRowActions, EntityStatus, EntityTable, } from "@repo/shadcn-ui/components/entity-list"; import { useQuery } from "@tanstack/react-query"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import type { SupportToolDTO } from "../common/support"; import { supportApi, supportKeys } from "./support-api"; import { SupportToolEditorDialog } from "./support-tool-editor-dialog"; export function SupportTools({ csrfToken }: { csrfToken: string }) { const { t, i18n } = useTranslation("assets"); const query = useQuery({ queryKey: supportKeys.tools, queryFn: () => supportApi.tools() }); const [edit, setEdit] = useState(); const [open, setOpen] = useState(false); return (
{" "} {" "} } locale={i18n.language} title={t("support.tools")} /> {query.isPending &&

{t("support.loading")}

} {query.isError && (

{t("support.loadError")}

)} tool.name, hideable: false, render: (tool) => {tool.name}, }, { id: "state", label: t("status"), value: (tool) => tool.active, render: (tool) => ( {t(tool.active ? "support.active" : "inactive")} ), }, { id: "origin", label: t("origin"), value: (tool) => tool.builtin, render: (tool) => <>{t(tool.builtin ? "support.builtin" : "custom")}, }, { id: "actions", label: t("actions"), hideable: false, render: (tool) => ( { setEdit(tool); setOpen(true); }} > {t("edit")} ), }, ]} items={query.data?.tools ?? []} loading={query.isPending} locale={i18n.language} title={t("support.tools")} unavailable={query.isError} /> setOpen(false)} open={open} />
); }