main
import { useCountdown } from '@/shared/lib'
const deadlines = new Map<string, { resendAt: number; expiresAt: number }>()
export function markCode(key: string, expiresIn: number) {
deadlines.set(key, { resendAt: Date.now() + 60_000, expiresAt: Date.now() + expiresIn * 1000 })
}
export function useCodeTimer(key: string) {
const entry = deadlines.get(key)
const resend = useCountdown(entry?.resendAt || 0)
const expiry = useCountdown(entry?.expiresAt || 0)
return { resend, expiry, sent: !!entry }
}