Skip to content

Commit

Permalink
#126 FIX: Retorna a página anterior após cadastro
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgbezerra committed Jun 21, 2023
1 parent a00886c commit e5f8507
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/pages/user-register/UserRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@
handleSubmit,
formState: { errors },
} = useForm<RegisterUserPayload>();

const onSubmit = handleSubmit(async (formData) => {
try {

const { username,email,name,cpf,role,jobFunction,password, ...rest } =
formData;

const payload = {
username: username.toString,
email: email.toString,
name: name.toString,
cpf: cpf.toString,
role: role.toString,
jobFunction: jobFunction.toString,
password: password.toString,
username: formData.username,
email: formData.email,
name: formData.name,
cpf: formData.cpf,
role: formData.role,
jobFunction: formData.jobFunction,
password: formData.password,
...rest,
};

const loggedUser = JSON.parse(
localStorage.getItem('@alectrion:user') || ''
) as unknown as LoginResponse;
Expand All @@ -64,8 +64,9 @@
}});

if (response.status === 200) {
toast.success('Usuário cadastrado com sucesso', 'Sucesso');
setRefreshRequest(!refreshRequest);
window.history.back()
toast.success('Usuário cadastrado com sucesso', 'Sucesso');
return;
}
toast.error('Erro ao tentar cadastrar o usuario', 'Erro');
Expand Down Expand Up @@ -262,7 +263,6 @@
</Button>
</Flex>
</Box>

</form>
<Spacer />
</Flex>
Expand Down

0 comments on commit e5f8507

Please sign in to comment.