diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index ec58330b..824e695c 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -32,8 +32,12 @@ export default function NavBar({ appName, useAuth }: { appName: string, useAuth: // other options icon: "✌️", }, - error: 'Error', - pending: '123 ...' + error: { + render( {data} ) { + return `${data}` + }, + }, + pending: 'creating new user ...' }); setSignupOpen(false); } @@ -49,7 +53,11 @@ export default function NavBar({ appName, useAuth }: { appName: string, useAuth: // other options icon: "✌️", }, - error: 'Error', + error: { + render( {data} ) { + return `${data}` + }, + }, pending: 'logging in ...' }); setLoginOpen(false); @@ -66,7 +74,11 @@ export default function NavBar({ appName, useAuth }: { appName: string, useAuth: // other options icon: "👋", }, - error: 'Error', + error: { + render( {data} ) { + return `${data}` + }, + }, pending: 'logging out ..' }); } diff --git a/src/Components/Auth/useAuth.tsx b/src/Components/Auth/useAuth.tsx index 4a0556a9..060413e7 100644 --- a/src/Components/Auth/useAuth.tsx +++ b/src/Components/Auth/useAuth.tsx @@ -67,6 +67,7 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { return undefined; } } + const login = async (credentials: AuthCredentials): Promise => { setLoading(true); @@ -76,8 +77,7 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { return (await loadUser()); } catch (error: any) { setLoading(false); - console.log(error.response.data.error[0]); - return error.response.data.error[0]; + throw error; }; } @@ -88,16 +88,20 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { return (await login(credentials)); } catch (error: any) { setLoading(false); - console.log(error); - return error.response.data.error[0]; + throw error; }; } const logout = async () => { - await userApi.logout(); - setUser(null); - }; + try { + await userApi.logout(); + setUser(null); + } catch (error: any) { + setLoading(false); + throw error; + }; + } const updateUser = async (user: UserItem) => { setLoading(true); @@ -108,12 +112,10 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { setUser(res as any); setLoading(false); return res as any; - } catch (error: any) { setLoading(false); - return error.response.data.error[0]; - } - + throw error; + }; } diff --git a/src/Components/Map/Subcomponents/AddButton.tsx b/src/Components/Map/Subcomponents/AddButton.tsx index 0254af0a..fadcd8be 100644 --- a/src/Components/Map/Subcomponents/AddButton.tsx +++ b/src/Components/Map/Subcomponents/AddButton.tsx @@ -14,7 +14,7 @@ export default function AddButton({ setSelectMode }: { setSelectMode: React.Disp -