From fac5e2ea5e47218b8c26baf0ba951085af476f3c Mon Sep 17 00:00:00 2001 From: rassadin11 Date: Fri, 22 May 2026 22:14:15 +0300 Subject: [PATCH] F --- src/shared/api/csrf.ts | 27 +++++++++++++++++++-------- src/shared/config/constants.ts | 2 +- src/widgets/header/ui/Header.tsx | 5 +---- src/widgets/hero/lib/useCountdown.ts | 12 +----------- src/widgets/hero/ui/Countdown.tsx | 6 +++--- src/widgets/hero/ui/Hero.tsx | 4 ++-- tsconfig.tsbuildinfo | 2 +- 7 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/shared/api/csrf.ts b/src/shared/api/csrf.ts index e21e6b1..897e50d 100644 --- a/src/shared/api/csrf.ts +++ b/src/shared/api/csrf.ts @@ -6,17 +6,28 @@ interface CsrfResponse { } let cachedToken: string | null = null +let inflight: Promise | null = null export function clearCsrfCache(): void { cachedToken = null + inflight = null } -export async function getCsrfToken(): Promise { - if (cachedToken) return cachedToken - const res = await fetch(`${API_URL}/csrf/token`, { - credentials: 'include', - }) - const data: CsrfResponse = await res.json() - cachedToken = data.token - return cachedToken +export function getCsrfToken(): Promise { + if (cachedToken) return Promise.resolve(cachedToken) + if (inflight) return inflight + + inflight = fetch(`${API_URL}/csrf/token`, { credentials: 'include' }) + .then((res) => res.json() as Promise) + .then((data) => { + cachedToken = data.token + inflight = null + return cachedToken + }) + .catch((err) => { + inflight = null + throw err + }) + + return inflight } diff --git a/src/shared/config/constants.ts b/src/shared/config/constants.ts index 10a4332..85aafd5 100644 --- a/src/shared/config/constants.ts +++ b/src/shared/config/constants.ts @@ -1,3 +1,3 @@ -export const COUNTDOWN_DAYS = 3 +export const COUNTDOWN_TARGET = new Date('2026-05-21T00:00:00').getTime() export const USDT_RATE = 80.00 export const GAS_PRICE = 21.00 diff --git a/src/widgets/header/ui/Header.tsx b/src/widgets/header/ui/Header.tsx index b12a609..783b240 100644 --- a/src/widgets/header/ui/Header.tsx +++ b/src/widgets/header/ui/Header.tsx @@ -2,11 +2,8 @@ import logo from '@shared/assets/logo-full-white.png' import styles from './Header.module.css' import { Link } from 'react-router-dom' import { ROUTES } from '@shared/config/routes' -import { useIsAuthenticated } from '@features/auth' export function Header() { - const isAuthenticated = useIsAuthenticated() - return (