fix(auth): enable register tab switching

This commit is contained in:
Kirill
2026-05-22 15:59:38 +05:00
parent 237106f2a4
commit c903db439d
3 changed files with 13 additions and 4 deletions
@@ -29,10 +29,11 @@ type FormValues = {
type Props = {
isRegister: boolean
onRegisterChange: (v: boolean) => void
onSuccess: () => void
}
export function AuthPasswordForm({ isRegister, onSuccess }: Props) {
export function AuthPasswordForm({ isRegister, onRegisterChange, onSuccess }: Props) {
const { register, watch } = useForm<FormValues>({
defaultValues: { email: '', password: '', passwordConfirm: '', displayName: '' },
mode: 'onChange',
@@ -79,7 +80,7 @@ export function AuthPasswordForm({ isRegister, onSuccess }: Props) {
pb: 0.5,
textTransform: 'none',
}}
disabled
onClick={() => onRegisterChange(false)}
>
Вход
</Button>
@@ -94,7 +95,7 @@ export function AuthPasswordForm({ isRegister, onSuccess }: Props) {
pb: 0.5,
textTransform: 'none',
}}
disabled
onClick={() => onRegisterChange(true)}
>
Регистрация
</Button>
+9 -1
View File
@@ -20,6 +20,7 @@ export function AuthPage() {
const [message, setMessage] = useState<string | null>(null)
const [oauthError, setOauthError] = useState<string | null>(null)
const [tab, setTab] = useState(0)
const [isRegister, setIsRegister] = useState(false)
const [showForgot, setShowForgot] = useState(false)
const [searchParams, setSearchParams] = useSearchParams()
const navigate = useNavigate()
@@ -122,6 +123,7 @@ export function AuthPage() {
}}
onClick={() => {
setTab(idx)
if (idx === 0) setIsRegister(false)
setMessage(null)
setOauthError(null)
}}
@@ -142,7 +144,13 @@ export function AuthPage() {
</Alert>
)}
{tab === 0 && <AuthPasswordForm isRegister={false} onSuccess={() => navigate('/', { replace: true })} />}
{tab === 0 && (
<AuthPasswordForm
isRegister={isRegister}
onRegisterChange={setIsRegister}
onSuccess={() => navigate('/', { replace: true })}
/>
)}
{tab === 1 && <AuthCodeForm onSuccess={() => navigate('/', { replace: true })} />}
<Box sx={{ mt: 2, mb: 1, display: 'flex', justifyContent: 'center' }}>