Check if router is ready (#17)
This commit is contained in:
parent
1129e3e022
commit
0a5069ba7f
@ -6,6 +6,7 @@ import { useEffect, useRef, useState } from 'react';
|
|||||||
export default function Login() {
|
export default function Login() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { id, audience, acsUrl, providerName, relayState } = router.query;
|
const { id, audience, acsUrl, providerName, relayState } = router.query;
|
||||||
|
const isRouteReady = router.isReady;
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
username: 'jackson',
|
username: 'jackson',
|
||||||
@ -25,7 +26,7 @@ export default function Login() {
|
|||||||
acsUrlInp.current.focus();
|
acsUrlInp.current.focus();
|
||||||
acsUrlInp.current.select();
|
acsUrlInp.current.select();
|
||||||
}
|
}
|
||||||
}, []);
|
}, [acsUrl]);
|
||||||
|
|
||||||
const handleChange = (e: FormEvent<HTMLInputElement | HTMLSelectElement>): void => {
|
const handleChange = (e: FormEvent<HTMLInputElement | HTMLSelectElement>): void => {
|
||||||
const { name, value } = e.currentTarget;
|
const { name, value } = e.currentTarget;
|
||||||
@ -75,7 +76,8 @@ export default function Login() {
|
|||||||
<div className='relative top-20 mx-auto w-[465px] max-w-[90%] rounded-md border p-10 text-[#145698]'>
|
<div className='relative top-20 mx-auto w-[465px] max-w-[90%] rounded-md border p-10 text-[#145698]'>
|
||||||
<h2 className='mb-3 text-center text-3xl font-bold'>Login</h2>
|
<h2 className='mb-3 text-center text-3xl font-bold'>Login</h2>
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
{acsUrl ? null : (
|
{isRouteReady ? (
|
||||||
|
acsUrl ? null : (
|
||||||
<div>
|
<div>
|
||||||
<div className='mt-5'>
|
<div className='mt-5'>
|
||||||
<label htmlFor='acsUrl' className='mb-2 block'>
|
<label htmlFor='acsUrl' className='mb-2 block'>
|
||||||
@ -109,7 +111,8 @@ export default function Login() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)
|
||||||
|
) : null}
|
||||||
<div className='mt-5 flex items-end gap-x-1'>
|
<div className='mt-5 flex items-end gap-x-1'>
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor='username' className='mb-2 block'>
|
<label htmlFor='username' className='mb-2 block'>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user