Skip to content

Commit

Permalink
fix: fix recover password
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheusafonsouza committed Dec 9, 2024
1 parent 42e897d commit 81d43db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/hooks/useApi/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const useApi = () => {
recoverPassword: (email: string): Promise<{ data: any }> => {
return new Promise((resolve) => {
api
.post(`/auth/recover-password/${email}`)
.post(`/auth/recover-password`, { email })
.then((res) => resolve(res))
.catch((err) => resolve(getDefaultErrorUseAPIMessage(err)));
});
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {

async function recoverPassword(email: string): Promise<boolean> {
const { data } = await authRecoverPassword(email);
if (data.id) {
if (data.success) {
toaster.create({
title: 'E-mail enviado para recuperação de senha!',
type: 'success',
Expand All @@ -110,7 +110,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {

async function changePassword(password: string, token: string): Promise<boolean> {
const { data } = await authChangePassword(password, token);
if (data.id) {
if (data.success) {
toaster.create({
title: 'Senha alterada com sucesso! Você será redirecionado para o login...',
type: 'success',
Expand Down
12 changes: 10 additions & 2 deletions src/pages/SignIn/SignInForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../../../hooks/useAuth';
import { useNavigate } from 'react-router';
import { Input, Stack } from '@chakra-ui/react';
import { Link, useNavigate } from 'react-router';
import { Input, Stack, Link as ChakraLink, Text } from '@chakra-ui/react';
import { useForm } from 'react-hook-form';
import { PasswordInput } from '../../../components/ui/password-input';
import { Button } from '../../../components/ui/button';
Expand Down Expand Up @@ -62,6 +62,14 @@ function SignInForm() {
{...register('password', { required: "Campo obrigatório." })}
/>
</Field>
<Stack gap={'25px'} width={'100%'}>
<Text
textAlign={'center'}
color={'blue.100'}
>
Não lembra sua senha? <ChakraLink color={'green.100'}><Link to='/recuperar-senha'>Recupere ela aqui</Link></ChakraLink>
</Text>
</Stack>
</Stack>
<Button
loading={loading}
Expand Down

0 comments on commit 81d43db

Please sign in to comment.