diff --git a/src/components/Api/Api.tsx b/src/components/Api/Api.tsx index f6c5975..5d2e6dd 100644 --- a/src/components/Api/Api.tsx +++ b/src/components/Api/Api.tsx @@ -48,10 +48,10 @@ export function UserRegister(register: RegistrationParams) { return instance .post("/api/v1/accounts/users/", register) .then(async (response) => { - return [response.status]; + return [true, response.status]; }) .catch((error) => { - return [error.response.status, error.response.data]; + return [false, error.response.status, error.response.data]; }); } diff --git a/src/routes/Register/Register.tsx b/src/routes/Register/Register.tsx index 8e0a567..f484f11 100644 --- a/src/routes/Register/Register.tsx +++ b/src/routes/Register/Register.tsx @@ -141,12 +141,7 @@ export default function Register() { last_name: user.last_name, }).then((result) => { console.log(result); - try { - setUser({ - ...user, - feedback: ParseError(JSON.stringify(result[1])), - }); - } catch { + if (result[0]) { setUser({ ...user, first_name: "", @@ -158,6 +153,14 @@ export default function Register() { feedback: "Success! An email has been sent to activate your account", }); + setTimeout(() => { + navigation.navigate("Login"); + }, 10000); + } else { + setUser({ + ...user, + feedback: ParseError(JSON.stringify(result[2])), + }); } }); {