Skip to content

Commit

Permalink
fix: add to the state the correct user (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Liendo authored Jul 19, 2024
1 parent ef1b342 commit d856c3c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
13 changes: 11 additions & 2 deletions client/src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -14,7 +15,9 @@ export enum AuthRoutesEnum {
Welcome = '/welcome',
}

export enum PrivateRoutesEnum {}
export enum PrivateRoutesEnum {
Home = '/home',
}

export function Routes() {
const { user } = useAuth();
Expand All @@ -28,7 +31,13 @@ export function Routes() {
);
}

const PrivateRoutes: JSX.Element[] = [];
const PrivateRoutes: JSX.Element[] = [
<Route
key={PrivateRoutesEnum.Home}
path={PrivateRoutesEnum.Home}
Component={HomeApp}
/>,
];

const AuthRoutes: JSX.Element[] = [
<Route
Expand Down
14 changes: 14 additions & 0 deletions client/src/pages/(app)/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import useAuth from '../../hooks/Auth';

export default function HomeApp() {
const { user } = useAuth();
console.log(user);
return (
<>
<h1>Home</h1>
<h2>
{user?.first_name} {user?.last_name} {user?.email}
</h2>
</>
);
}
2 changes: 1 addition & 1 deletion client/src/services/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d856c3c

Please sign in to comment.