fix(auth): enable register tab switching
This commit is contained in:
@@ -29,10 +29,11 @@ type FormValues = {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isRegister: boolean
|
isRegister: boolean
|
||||||
|
onRegisterChange: (v: boolean) => void
|
||||||
onSuccess: () => void
|
onSuccess: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AuthPasswordForm({ isRegister, onSuccess }: Props) {
|
export function AuthPasswordForm({ isRegister, onRegisterChange, onSuccess }: Props) {
|
||||||
const { register, watch } = useForm<FormValues>({
|
const { register, watch } = useForm<FormValues>({
|
||||||
defaultValues: { email: '', password: '', passwordConfirm: '', displayName: '' },
|
defaultValues: { email: '', password: '', passwordConfirm: '', displayName: '' },
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
@@ -79,7 +80,7 @@ export function AuthPasswordForm({ isRegister, onSuccess }: Props) {
|
|||||||
pb: 0.5,
|
pb: 0.5,
|
||||||
textTransform: 'none',
|
textTransform: 'none',
|
||||||
}}
|
}}
|
||||||
disabled
|
onClick={() => onRegisterChange(false)}
|
||||||
>
|
>
|
||||||
Вход
|
Вход
|
||||||
</Button>
|
</Button>
|
||||||
@@ -94,7 +95,7 @@ export function AuthPasswordForm({ isRegister, onSuccess }: Props) {
|
|||||||
pb: 0.5,
|
pb: 0.5,
|
||||||
textTransform: 'none',
|
textTransform: 'none',
|
||||||
}}
|
}}
|
||||||
disabled
|
onClick={() => onRegisterChange(true)}
|
||||||
>
|
>
|
||||||
Регистрация
|
Регистрация
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export function AuthPage() {
|
|||||||
const [message, setMessage] = useState<string | null>(null)
|
const [message, setMessage] = useState<string | null>(null)
|
||||||
const [oauthError, setOauthError] = useState<string | null>(null)
|
const [oauthError, setOauthError] = useState<string | null>(null)
|
||||||
const [tab, setTab] = useState(0)
|
const [tab, setTab] = useState(0)
|
||||||
|
const [isRegister, setIsRegister] = useState(false)
|
||||||
const [showForgot, setShowForgot] = useState(false)
|
const [showForgot, setShowForgot] = useState(false)
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
@@ -122,6 +123,7 @@ export function AuthPage() {
|
|||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTab(idx)
|
setTab(idx)
|
||||||
|
if (idx === 0) setIsRegister(false)
|
||||||
setMessage(null)
|
setMessage(null)
|
||||||
setOauthError(null)
|
setOauthError(null)
|
||||||
}}
|
}}
|
||||||
@@ -142,7 +144,13 @@ export function AuthPage() {
|
|||||||
</Alert>
|
</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 })} />}
|
{tab === 1 && <AuthCodeForm onSuccess={() => navigate('/', { replace: true })} />}
|
||||||
|
|
||||||
<Box sx={{ mt: 2, mb: 1, display: 'flex', justifyContent: 'center' }}>
|
<Box sx={{ mt: 2, mb: 1, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user