import { useEffect, useState } from 'react' import Alert from '@mui/material/Alert' import Box from '@mui/material/Box' import Button from '@mui/material/Button' import Paper from '@mui/material/Paper' import Stack from '@mui/material/Stack' import { alpha, useTheme } from '@mui/material/styles' import Typography from '@mui/material/Typography' import { useUnit } from 'effector-react' import { useNavigate, useSearchParams } from 'react-router-dom' import { AuthCodeForm } from '@/features/auth-code' import { AuthForgotForm } from '@/features/auth-forgot' import { OAuthButtons } from '@/features/auth-oauth' import { AuthPasswordForm } from '@/features/auth-password' import { $user } from '@/shared/model/auth' import { useThemeController } from '@/app/providers/theme-controller' import { BearLogo } from '@/shared/ui/BearLogo' export function AuthPage() { const theme = useTheme() const { scheme } = useThemeController() const [message, setMessage] = useState(null) const [oauthError, setOauthError] = useState(null) const [tab, setTab] = useState(0) const [isRegister, setIsRegister] = useState(false) const [showForgot, setShowForgot] = useState(false) const [searchParams, setSearchParams] = useSearchParams() const navigate = useNavigate() const user = useUnit($user) useEffect(() => { if (user) navigate('/', { replace: true }) }, [navigate, user]) useEffect(() => { const err = searchParams.get('oauthError') if (!err) return const timeoutId = setTimeout(() => { setOauthError(err) setSearchParams({}, { replace: true }) }, 0) return () => clearTimeout(timeoutId) }, []) if (showForgot) { return ( Восстановление пароля setShowForgot(false)} /> ) } return ( Добро пожаловать
в Любимый Креатив
Войдите или зарегистрируйтесь, чтобы продолжить {[ { label: 'Пароль', idx: 0 }, { label: 'Код', idx: 1 }, ].map(({ label, idx }) => ( ))} {oauthError && ( setOauthError(null)}> {oauthError} )} {message && ( setMessage(null)}> {message} )} {tab === 0 && ( navigate('/', { replace: true })} /> )} {tab === 1 && navigate('/', { replace: true })} />} или
) }