"use client"; import { useEffect, useState } from "react"; interface Props { cadNum: string; etaSeconds: number; onCancel: () => void; } /** * #93 — loading state когда backend на 202 Accepted делает on-demand NSPD fetch. * * Показывает animated progress bar + текущий elapsed time + cancel button. */ export function FetchingState({ cadNum, etaSeconds, onCancel }: Props) { const [elapsed, setElapsed] = useState(0); useEffect(() => { const interval = setInterval(() => { setElapsed((e) => e + 1); }, 1000); return () => clearInterval(interval); }, []); // Progress: linear до etaSeconds, потом замедляемся (asymptote 95%) const progressPct = elapsed <= etaSeconds ? (elapsed / etaSeconds) * 80 : 80 + Math.min(15, (elapsed - etaSeconds) * 0.5); return (
Кадастровый номер{" "} {cadNum} {" "} не был ранее загружен в нашу базу. Обращаемся к НСПД (Национальной системе пространственных данных). Обычно занимает 15-30 секунд.
{/* Progress bar */}
{elapsed} сек ~{etaSeconds} сек ожидаемо
); }