Fixed registration page

This commit is contained in:
Keannu Bernasol 2023-07-04 14:34:31 +08:00
parent fb7b77efb7
commit 4a00dd1817
2 changed files with 11 additions and 8 deletions

View file

@ -48,10 +48,10 @@ export function UserRegister(register: RegistrationParams) {
return instance return instance
.post("/api/v1/accounts/users/", register) .post("/api/v1/accounts/users/", register)
.then(async (response) => { .then(async (response) => {
return [response.status]; return [true, response.status];
}) })
.catch((error) => { .catch((error) => {
return [error.response.status, error.response.data]; return [false, error.response.status, error.response.data];
}); });
} }

View file

@ -141,12 +141,7 @@ export default function Register() {
last_name: user.last_name, last_name: user.last_name,
}).then((result) => { }).then((result) => {
console.log(result); console.log(result);
try { if (result[0]) {
setUser({
...user,
feedback: ParseError(JSON.stringify(result[1])),
});
} catch {
setUser({ setUser({
...user, ...user,
first_name: "", first_name: "",
@ -158,6 +153,14 @@ export default function Register() {
feedback: feedback:
"Success! An email has been sent to activate your account", "Success! An email has been sent to activate your account",
}); });
setTimeout(() => {
navigation.navigate("Login");
}, 10000);
} else {
setUser({
...user,
feedback: ParseError(JSON.stringify(result[2])),
});
} }
}); });
{ {