fix(auth): enable register tab switching
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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' }}>
|
||||
|
||||
Reference in New Issue
Block a user