Initial commit: CI Agent competitive-intelligence monitoring app
FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
/** A countdown in whole seconds, started on demand via `start(seconds)` -
|
||||
* drives the "Resend in Ns" button state after a 429 throttle response. */
|
||||
export function useCountdown() {
|
||||
const [remaining, setRemaining] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (remaining <= 0) return;
|
||||
const timer = setTimeout(() => setRemaining((s) => Math.max(0, s - 1)), 1000);
|
||||
return () => clearTimeout(timer);
|
||||
}, [remaining]);
|
||||
|
||||
return { remaining, start: (seconds: number) => setRemaining(seconds) };
|
||||
}
|
||||
Reference in New Issue
Block a user