-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e34389
commit 4155333
Showing
8 changed files
with
165 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,25 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '~/com | |
import { Input } from '~/components/ui/input' | ||
import { Label } from '~/components/ui/label' | ||
import { useError } from '~/hooks/use_error' | ||
import { useForm } from '@inertiajs/react' | ||
import { useForm, usePage } from '@inertiajs/react' | ||
import { cn } from '~/lib/utils' | ||
import BaseLayout from '~/layouts/base' | ||
import CardLayout from '~/layouts/card' | ||
|
||
export default function ForgotPasswor() { | ||
const page = usePage() | ||
const oauthError = useError('oauth') | ||
|
||
const { data, setData, errors, post } = useForm({ | ||
email: '', | ||
const { data, setData, post } = useForm({ | ||
email: String(page.props.email), | ||
password: '', | ||
password_confirmation: '', | ||
}) | ||
|
||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault() | ||
|
||
post('/auth/password/forgot/new') | ||
post('/auth/password/forgot/reset') | ||
} | ||
|
||
return ( | ||
|
@@ -29,27 +31,37 @@ export default function ForgotPasswor() { | |
<CardHeader> | ||
<CardTitle className="text-2xl">Repôr palavra-passe</CardTitle> | ||
<CardDescription> | ||
Introduz o teu e-mail para recuperares a tua palavra-passe | ||
Introduz a tua nova palavra-passe | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<form onSubmit={handleSubmit} method="POST" action="/auth/login"> | ||
<div className="flex flex-col gap-6"> | ||
<div className="grid gap-2"> | ||
<Label htmlFor="email">E-mail</Label> | ||
<Label htmlFor="password">Palavra-passe</Label> | ||
<Input | ||
id="email" | ||
type="email" | ||
placeholder="[email protected]" | ||
value={data.email} | ||
onChange={(e) => setData('email', e.target.value)} | ||
id="password" | ||
type="password" | ||
placeholder="••••••••••••" | ||
value={data.password} | ||
onChange={(e) => setData('password', e.target.value)} | ||
required | ||
/> | ||
</div> | ||
<div className="grid gap-2"> | ||
<Label htmlFor="password">Confirmar palavra-passe</Label> | ||
<Input | ||
id="password_confirmation" | ||
type="password" | ||
placeholder="••••••••••••" | ||
value={data.password_confirmation} | ||
onChange={(e) => setData('password_confirmation', e.target.value)} | ||
required | ||
/> | ||
{errors.email && <p className="text-sm text-red-600">{errors.email}</p>} | ||
</div> | ||
<div className="flex flex-col gap-4 "> | ||
<Button type="submit" className="w-full bg-enei-blue"> | ||
Recuperar palavra-passe | ||
Definir palavra-passe | ||
</Button> | ||
</div> | ||
</div> | ||
|
@@ -61,3 +73,4 @@ export default function ForgotPasswor() { | |
</BaseLayout> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useForm } from '@inertiajs/react' | ||
import { Button } from '~/components/ui/button' | ||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '~/components/ui/card' | ||
import { useCooldown } from '~/hooks/use_cooldown' | ||
import { useToast } from '~/hooks/use_toast' | ||
import { useTuyau } from '~/hooks/use_tuyau' | ||
import BaseLayout from '~/layouts/base' | ||
import CardLayout from '~/layouts/card' | ||
|
||
export default function EmailVerification() { | ||
const tuyau = useTuyau() | ||
|
||
const cooldown = useCooldown({ | ||
seconds: 60, | ||
}) | ||
|
||
const { post } = useForm() | ||
const { toast } = useToast() | ||
function onSubmit(e: React.FormEvent<HTMLFormElement>) { | ||
e.preventDefault() | ||
post(tuyau.$url('actions:auth.forgot-password.send'), { | ||
onSuccess: () => { | ||
toast({ | ||
title: 'E-mail reenviado!', | ||
description: 'Por favor, verifica a tua caixa de entrada, incluindo o spam!', | ||
duration: 5000, | ||
}) | ||
}, | ||
}) | ||
} | ||
|
||
return ( | ||
<BaseLayout title="Repôr palavra-passe"> | ||
<CardLayout> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle className="text-2xl">E-mail de recuperação de palavra-passe enviado</CardTitle> | ||
<CardDescription> | ||
Um e-mail de confirmação foi enviado para o e-mail indicado. | ||
Por favor, verifica a tua caixa de entrada | ||
, <span className="font-bold">incluindo o spam</span>! | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<form onSubmit={cooldown.throttle(onSubmit)} method="post"> | ||
<Button type="submit" className="w-full" disabled={cooldown.active}> | ||
Não recebi nada... | ||
</Button> | ||
{cooldown.active && ( | ||
<p className="text-muted-foreground text-xs mt-2"> | ||
Por favor espera {cooldown.secondsLeft} segundos antes de tentar novamente. | ||
</p> | ||
)} | ||
</form> | ||
</CardContent> | ||
</Card> | ||
</CardLayout> | ||
</BaseLayout> | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Link } from '@tuyau/inertia/react' | ||
import { buttonVariants } from '~/components/ui/button' | ||
import { Card, CardContent, CardHeader, CardTitle } from '~/components/ui/card' | ||
import BaseLayout from '~/layouts/base' | ||
import CardLayout from '~/layouts/card' | ||
|
||
export default function EmailVerification() { | ||
return ( | ||
<BaseLayout title="E-mail confirmado"> | ||
<CardLayout> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>A tua palavra-passe foi alterada com sucesso!</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<Link route="pages:auth.login" className={buttonVariants()}> | ||
Ir para a página de login | ||
</Link> | ||
</CardContent> | ||
</Card> | ||
</CardLayout> | ||
</BaseLayout> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters