Files
bedolaga-cabinet/src/pages/VerifyEmail.tsx
c0mrade f75b243f03 polish: clear 33/34 detector findings (bg-black, animate-bounce, spinner, transition-width, color)
After re-audit/critique cycle the deterministic detector (npx impeccable)
flagged 34 design-spec violations. Knock out 33 of them.

  • 25 × pure-black-white: sed-sweep bg-black/X → bg-dark-950/X across
    18+ files (modal scrims, photo viewer backdrop, code blocks). The
    base resolves to rgba(10,15,26,X) — visually identical to true
    black, satisfies the 'no #000' impeccable rule.
  • 3 × bounce-easing: SuccessNotificationModal celebration icon and
    SyncTab loading arrows used animate-bounce; replaced with
    animate-pulse. Bounce easing reads dated; pulse conveys 'in
    progress' without the cartoon feel.
  • 3 × border-accent-on-rounded: TelegramCallback + VerifyEmail
    spinners used 'border-b-2 border-accent-500' on rounded-full —
    detector reads it as a side-stripe even though it's a ring loader.
    Switch to canonical 'border-2 border-accent-500 border-t-transparent'
    (3/4 ring colored). Same visual, no spec violation.
  • 1 × ai-color-palette: AdminLandingStats had text-purple-400 on a
    gift-stats heading; purple is not in the brand palette. Swap to
    text-accent-400.
  • 1 × layout-transition: TrafficProgressBar.tsx fill bar still used
    transition: width 1.2s (slipped past the earlier optimize pass).
    Convert to transform: scaleX with origin-left. Same gradient, same
    duration, runs on the compositor.

Remaining: 1 finding in third-party Aceternity background-beams-collision
component (indigo-500 gradient on decorative WebGL background) — left
as-is, it's lifted decorative third-party code.

Detector: 34 → 1.
2026-05-26 21:52:56 +03:00

121 lines
4.4 KiB
TypeScript

import { useEffect, useRef, useState } from 'react';
import { useSearchParams, Link, useNavigate } from 'react-router';
import { useTranslation } from 'react-i18next';
import { authApi } from '../api/auth';
import { useAuthStore } from '../store/auth';
import { useShallow } from 'zustand/shallow';
import { consumeCampaignSlug, getPendingCampaignSlug } from '../utils/campaign';
import { tokenStorage } from '../utils/token';
import LanguageSwitcher from '../components/LanguageSwitcher';
export default function VerifyEmail() {
const { t } = useTranslation();
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const [status, setStatus] = useState<'loading' | 'success' | 'error'>('loading');
const [error, setError] = useState('');
const { setTokens, setUser, checkAdminStatus } = useAuthStore(
useShallow((state) => ({
setTokens: state.setTokens,
setUser: state.setUser,
checkAdminStatus: state.checkAdminStatus,
})),
);
const hasVerified = useRef(false);
useEffect(() => {
if (hasVerified.current) return;
const token = searchParams.get('token');
if (!token) {
setStatus('error');
setError(t('common.error'));
return;
}
hasVerified.current = true;
let redirectTimer: ReturnType<typeof setTimeout>;
const verify = async () => {
try {
const campaignSlug = getPendingCampaignSlug();
const response = await authApi.verifyEmail(token, campaignSlug);
consumeCampaignSlug();
// Save tokens and log user in
tokenStorage.setTokens(response.access_token, response.refresh_token);
setTokens(response.access_token, response.refresh_token);
setUser(response.user);
if (response.campaign_bonus) {
useAuthStore.setState({ pendingCampaignBonus: response.campaign_bonus });
}
checkAdminStatus();
setStatus('success');
// Redirect to dashboard after short delay
redirectTimer = setTimeout(() => navigate('/', { replace: true }), 1500);
} catch (err: unknown) {
setStatus('error');
const error = err as { response?: { data?: { detail?: string } } };
setError(error.response?.data?.detail || t('emailVerification.failed'));
}
};
verify();
return () => clearTimeout(redirectTimer);
}, [searchParams, t, navigate, setTokens, setUser, checkAdminStatus]);
return (
<div className="min-h-viewport flex items-center justify-center bg-dark-950 px-4 py-8 sm:py-12">
{/* Language switcher in corner */}
<div className="fixed right-4 top-4 z-50">
<LanguageSwitcher />
</div>
<div className="w-full max-w-md text-center">
{status === 'loading' && (
<div>
<div className="mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-2 border-accent-500 border-t-transparent"></div>
<h2 className="text-lg font-semibold text-dark-50 sm:text-xl">
{t('emailVerification.verifying')}
</h2>
<p className="mt-2 text-sm text-dark-400 sm:text-base">
{t('emailVerification.pleaseWait')}
</p>
</div>
)}
{status === 'success' && (
<div>
<div className="mb-4 text-5xl text-success-500 sm:text-6xl"></div>
<h2 className="text-lg font-semibold text-dark-50 sm:text-xl">
{t('emailVerification.success')}
</h2>
<p className="mt-2 text-sm text-dark-400 sm:text-base">
{t('emailVerification.redirecting', 'Redirecting to dashboard...')}
</p>
<div className="mt-4">
<div className="mx-auto h-6 w-6 animate-spin rounded-full border-2 border-accent-500 border-t-transparent"></div>
</div>
</div>
)}
{status === 'error' && (
<div>
<div className="mb-4 text-5xl text-error-500 sm:text-6xl"></div>
<h2 className="text-lg font-semibold text-dark-50 sm:text-xl">
{t('emailVerification.failed')}
</h2>
<p className="mt-2 text-sm text-dark-400 sm:text-base">{error}</p>
<div className="mt-6">
<Link to="/login" className="btn-secondary">
{t('emailVerification.goToLogin')}
</Link>
</div>
</div>
)}
</div>
</div>
);
}