import React, { useEffect, useState } from "react"; import { useBoolean } from "usehooks-ts"; import { Button } from "@/components/ui/button/button"; import { useLocale } from "@/hooks/useLocale"; interface CountdownTimerProps { onResendButton: () => void; } const CountdownTimer: React.FC = ({ onResendButton }) => { const initialTime = 180; const showResendButton = useBoolean(false); const [time, setTime] = useState(initialTime); const { t } = useLocale(); useEffect(() => { const timer = setTimeout(() => { if (time > 0) { setTime(time - 1); } else { showResendButton.setTrue(); } }, 1000); return () => clearTimeout(timer); }, [time, showResendButton]); const minutes = Math.floor(time / 60); const seconds = time % 60; return (

{t("Time Remaining:")}

{String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}

{showResendButton.value && ( )}
); }; export default CountdownTimer;