4
0
forked from crowetic/commerce

Merge pull request #23 from marbiano/auth-forms

Auth forms
This commit is contained in:
B 2020-10-27 01:21:22 -03:00 committed by GitHub
commit 90e105684f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 12 deletions

View File

@ -15,7 +15,9 @@ const ForgotPassword: FC<Props> = () => {
const { setModalView, closeModal } = useUI() const { setModalView, closeModal } = useUI()
const handleSignup = async () => { const handleResetPassword = async (e: React.SyntheticEvent<EventTarget>) => {
e.preventDefault()
if (!dirty && !disabled) { if (!dirty && !disabled) {
setDirty(true) setDirty(true)
handleValidation() handleValidation()
@ -34,7 +36,10 @@ const ForgotPassword: FC<Props> = () => {
}, [handleValidation]) }, [handleValidation])
return ( return (
<div className="w-80 flex flex-col justify-between p-3"> <form
onSubmit={handleResetPassword}
className="w-80 flex flex-col justify-between p-3"
>
<div className="flex justify-center pb-12 "> <div className="flex justify-center pb-12 ">
<Logo width="64px" height="64px" /> <Logo width="64px" height="64px" />
</div> </div>
@ -47,7 +52,7 @@ const ForgotPassword: FC<Props> = () => {
<div className="pt-2 w-full flex flex-col"> <div className="pt-2 w-full flex flex-col">
<Button <Button
variant="slim" variant="slim"
onClick={() => handleSignup()} type="submit"
loading={loading} loading={loading}
disabled={disabled} disabled={disabled}
> >
@ -66,7 +71,7 @@ const ForgotPassword: FC<Props> = () => {
</a> </a>
</span> </span>
</div> </div>
</div> </form>
) )
} }

View File

@ -18,7 +18,9 @@ const LoginView: FC<Props> = () => {
const login = useLogin() const login = useLogin()
const handleLogin = async () => { const handleLogin = async (e: React.SyntheticEvent<EventTarget>) => {
e.preventDefault()
if (!dirty && !disabled) { if (!dirty && !disabled) {
setDirty(true) setDirty(true)
handleValidation() handleValidation()
@ -54,7 +56,10 @@ const LoginView: FC<Props> = () => {
}, [handleValidation]) }, [handleValidation])
return ( return (
<div className="w-80 flex flex-col justify-between p-3"> <form
onSubmit={handleLogin}
className="w-80 flex flex-col justify-between p-3"
>
<div className="flex justify-center pb-12 "> <div className="flex justify-center pb-12 ">
<Logo width="64px" height="64px" /> <Logo width="64px" height="64px" />
</div> </div>
@ -75,7 +80,7 @@ const LoginView: FC<Props> = () => {
<Button <Button
variant="slim" variant="slim"
onClick={() => handleLogin()} type="submit"
loading={loading} loading={loading}
disabled={disabled} disabled={disabled}
> >
@ -92,7 +97,7 @@ const LoginView: FC<Props> = () => {
</a> </a>
</div> </div>
</div> </div>
</div> </form>
) )
} }

View File

@ -21,7 +21,9 @@ const SignUpView: FC<Props> = () => {
const signup = useSignup() const signup = useSignup()
const { setModalView, closeModal } = useUI() const { setModalView, closeModal } = useUI()
const handleSignup = async () => { const handleSignup = async (e: React.SyntheticEvent<EventTarget>) => {
e.preventDefault()
if (!dirty && !disabled) { if (!dirty && !disabled) {
setDirty(true) setDirty(true)
handleValidation() handleValidation()
@ -59,7 +61,10 @@ const SignUpView: FC<Props> = () => {
}, [handleValidation]) }, [handleValidation])
return ( return (
<div className="w-80 flex flex-col justify-between p-3"> <form
onSubmit={handleSignup}
className="w-80 flex flex-col justify-between p-3"
>
<div className="flex justify-center pb-12 "> <div className="flex justify-center pb-12 ">
<Logo width="64px" height="64px" /> <Logo width="64px" height="64px" />
</div> </div>
@ -83,7 +88,7 @@ const SignUpView: FC<Props> = () => {
<div className="pt-2 w-full flex flex-col"> <div className="pt-2 w-full flex flex-col">
<Button <Button
variant="slim" variant="slim"
onClick={() => handleSignup()} type="submit"
loading={loading} loading={loading}
disabled={disabled} disabled={disabled}
> >
@ -102,7 +107,7 @@ const SignUpView: FC<Props> = () => {
</a> </a>
</span> </span>
</div> </div>
</div> </form>
) )
} }