From ae34d46cf02500fa529840e47ead794d8afc0845 Mon Sep 17 00:00:00 2001 From: koss-service Date: Sat, 16 Dec 2023 12:20:22 +0000 Subject: [PATCH] Applied prettier formatting --- src/util/auth.tsx | 48 ++++++++++++++++++++++++----------------------- src/util/types.ts | 4 ++-- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/util/auth.tsx b/src/util/auth.tsx index 8adf7474..0da07f46 100644 --- a/src/util/auth.tsx +++ b/src/util/auth.tsx @@ -62,11 +62,11 @@ const DEFAULT_AUTH_CONTEXT: IAuthContext = { formLink: ROUTER_PATHS.STUDENT_FORM, dashboardLink: ROUTER_PATHS.STUDENT_DASHBOARD, jwt: DEFAULT_AUTH_OBJ.jwt, - setUserType: () => { }, - updateUserData: () => { }, - onLogin: () => { }, - onRegister: () => { }, - onLogout: () => { }, + setUserType: () => {}, + updateUserData: () => {}, + onLogin: () => {}, + onRegister: () => {}, + onLogout: () => {}, }; const getLsAuthObj = () => { @@ -154,7 +154,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { const updateAuth = (auth: ILocalStorageAuthObj) => { setUserAuth(auth); - console.log(auth) + console.log(auth); setFormLink( userAuth.userData.type === "student" ? ROUTER_PATHS.STUDENT_FORM @@ -197,27 +197,29 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { // Load the profile once useEffect(() => { if (isAuthenticated) { - makeRequest( - 'profile', - 'get', - null, - userAuth.jwt - ).then(({ response, is_ok }) => { - if (is_ok) { - onRegister({ username: response.username, name: response.name, email: response.email, college: userAuth.userData.college, type: response.type }); - } else { - if (response.status_code === 400) { - setIsRegistered(false); + makeRequest("profile", "get", null, userAuth.jwt) + .then(({ response, is_ok }) => { + if (is_ok) { + onRegister({ + username: response.username, + name: response.name, + email: response.email, + college: userAuth.userData.college, + type: response.type, + }); } else { - onLogout(); + if (response.status_code === 400) { + setIsRegistered(false); + } else { + onLogout(); + } } - } - }) - .catch((err) => { - console.log('Error fetching profile from the backend: ', err); }) + .catch((err) => { + console.log("Error fetching profile from the backend: ", err); + }); } - }, []) + }, []); useEffect(() => { localStorage.setItem("auth", JSON.stringify(userAuth)); diff --git a/src/util/types.ts b/src/util/types.ts index 5f2ded47..4c94adb6 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -28,8 +28,8 @@ export interface IEndpointTypes { username: string; email: string; type: UserType; - } - }, + }; + }; "student/form": { request: { username: string;