From d856c3cae8eb61b2c5611eb271c8a319ee17ee45 Mon Sep 17 00:00:00 2001 From: Michael Liendo Date: Fri, 19 Jul 2024 13:32:08 -0400 Subject: [PATCH] fix: add to the state the correct user (#16) --- client/src/Routes.tsx | 13 +++++++++++-- client/src/pages/(app)/Home.tsx | 14 ++++++++++++++ client/src/services/User.ts | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 client/src/pages/(app)/Home.tsx diff --git a/client/src/Routes.tsx b/client/src/Routes.tsx index 074678f..a780cad 100644 --- a/client/src/Routes.tsx +++ b/client/src/Routes.tsx @@ -1,5 +1,6 @@ import { Routes as ReactRoutes, Route } from 'react-router'; import useAuth from './hooks/Auth'; +import HomeApp from './pages/(app)/Home'; import Login from './pages/(auth)/Login'; import Signup from './pages/(auth)/Signup'; import Home from './pages/home'; @@ -14,7 +15,9 @@ export enum AuthRoutesEnum { Welcome = '/welcome', } -export enum PrivateRoutesEnum {} +export enum PrivateRoutesEnum { + Home = '/home', +} export function Routes() { const { user } = useAuth(); @@ -28,7 +31,13 @@ export function Routes() { ); } -const PrivateRoutes: JSX.Element[] = []; +const PrivateRoutes: JSX.Element[] = [ + , +]; const AuthRoutes: JSX.Element[] = [ +

Home

+

+ {user?.first_name} {user?.last_name} {user?.email} +

+ + ); +} diff --git a/client/src/services/User.ts b/client/src/services/User.ts index 01a915d..b378176 100644 --- a/client/src/services/User.ts +++ b/client/src/services/User.ts @@ -8,7 +8,7 @@ export default class User { const response = await request.json(); - return response as IUser; + return response.data.user as IUser; } catch (error) { console.error('UserServices', error); throw error;