|
|
@ -1,6 +1,6 @@ |
|
|
|
import Cookies from 'js-cookie'; |
|
|
|
import Cookies from 'js-cookie'; |
|
|
|
import type { FormEvent } from 'react'; |
|
|
|
import type { FormEvent } from 'react'; |
|
|
|
import { useState } from 'react'; |
|
|
|
import { useId, useState } from 'react'; |
|
|
|
import { httpPost } from '../../lib/http'; |
|
|
|
import { httpPost } from '../../lib/http'; |
|
|
|
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; |
|
|
|
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; |
|
|
|
|
|
|
|
|
|
|
@ -53,13 +53,16 @@ export function EmailLoginForm(props: EmailLoginFormProps) { |
|
|
|
setError(error?.message || 'Something went wrong. Please try again later.'); |
|
|
|
setError(error?.message || 'Something went wrong. Please try again later.'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emailFieldId = `form:${useId()}`; |
|
|
|
|
|
|
|
const passwordFieldId = `form:${useId()}`; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<form className="w-full" onSubmit={handleFormSubmit}> |
|
|
|
<form className="w-full" onSubmit={handleFormSubmit}> |
|
|
|
<label htmlFor="email" className="sr-only"> |
|
|
|
<label htmlFor={emailFieldId} className="sr-only"> |
|
|
|
Email address |
|
|
|
Email address |
|
|
|
</label> |
|
|
|
</label> |
|
|
|
<input |
|
|
|
<input |
|
|
|
id="email" |
|
|
|
id={emailFieldId} |
|
|
|
name="email" |
|
|
|
name="email" |
|
|
|
type="email" |
|
|
|
type="email" |
|
|
|
autoComplete="email" |
|
|
|
autoComplete="email" |
|
|
@ -69,11 +72,11 @@ export function EmailLoginForm(props: EmailLoginFormProps) { |
|
|
|
value={email} |
|
|
|
value={email} |
|
|
|
onInput={(e) => setEmail(String((e.target as any).value))} |
|
|
|
onInput={(e) => setEmail(String((e.target as any).value))} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<label htmlFor="password" className="sr-only"> |
|
|
|
<label htmlFor={passwordFieldId} className="sr-only"> |
|
|
|
Password |
|
|
|
Password |
|
|
|
</label> |
|
|
|
</label> |
|
|
|
<input |
|
|
|
<input |
|
|
|
id="password" |
|
|
|
id={passwordFieldId} |
|
|
|
name="password" |
|
|
|
name="password" |
|
|
|
type="password" |
|
|
|
type="password" |
|
|
|
autoComplete="current-password" |
|
|
|
autoComplete="current-password" |
|
|
|