import { useId, useState } from "react" import { useParams } from "react-router-dom" import { AlertTriangle, Loader2, Play, RefreshCw, TriangleAlert } from "lucide-react" import { DiffView } from "@/components/DiffView" import { DomainHistory } from "@/components/DomainHistory" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { Label } from "@/components/ui/label" import { useApplyDomain, useCheckDomain } from "@/hooks/useApi" import { cn } from "@/lib/utils" export function DomainDiffPage() { const { id = "" } = useParams() const check = useCheckDomain(id) const apply = useApplyDomain(id) const [applyPrunes, setApplyPrunes] = useState(false) const pruneCheckboxId = useId() const changeset = check.data const hasPrunes = (changeset?.prunes.length ?? 0) > 0 const hasUpdates = (changeset?.updates.length ?? 0) > 0 const pruneWarning = applyPrunes && hasPrunes function onApply() { apply.mutate({ applyUpdates: true, applyPrunes }) } return (
domain / check

{id}

{check.isPending && (
Вычисляю дифф…
)} {check.isError && (
Не удалось получить дифф {check.error.message}
)} {changeset && ( <>
{pruneWarning && (
Будет безвозвратно удалено записей:{" "} {changeset.prunes.length}. Действие необратимо.
)}
{apply.isError ? ( {apply.error.message} ) : apply.isSuccess ? ( Применено ✓ ) : ( {hasUpdates || (applyPrunes && hasPrunes) ? "Готово к применению" : "Изменений для применения нет"} )}
)}
) }