diff --git a/client/src/components/AppHeader.tsx b/client/src/components/AppHeader.tsx new file mode 100644 index 0000000..0ae6dff --- /dev/null +++ b/client/src/components/AppHeader.tsx @@ -0,0 +1,26 @@ +import logo from '@assets/images/logo.svg'; + +const AppHeader = () => { + return ( +
+
+ logo +
+
+
+
+ avatar +
+
+ John Doe +
+ +
+
+
+ ); +}; + +export default AppHeader; diff --git a/client/src/routes/home.tsx b/client/src/routes/home.tsx index 68ce43f..8586d4e 100644 --- a/client/src/routes/home.tsx +++ b/client/src/routes/home.tsx @@ -1,5 +1,6 @@ import { useCookies } from "react-cookie"; import { Navigate } from "react-router-dom"; +import AppHeader from "@components/AppHeader"; const Home = () => { const [cookie, setCookie] = useCookies(["token"]); @@ -9,9 +10,9 @@ const Home = () => { } return ( -
-

Home

-
+ <> + + ); } diff --git a/client/src/routes/login.tsx b/client/src/routes/login.tsx index 4344b20..80561f0 100644 --- a/client/src/routes/login.tsx +++ b/client/src/routes/login.tsx @@ -3,6 +3,7 @@ import logo from '@assets/images/logo.svg'; import { useQuery } from '@tanstack/react-query'; import { useState } from 'react'; import { useCookies } from 'react-cookie'; +import type { Token } from '../types'; const Login = () => { const [cookie, setCookie] = useCookies(['token']); @@ -23,7 +24,7 @@ const Login = () => { return response.json(); }, { - onSuccess: (data) => { + onSuccess: (data: Token) => { setCookie('token', data.token, { path: '/', expires: new Date(data.expiresAt) }); return ; }, diff --git a/client/src/types/index.d.ts b/client/src/types/index.d.ts index e69de29..f7756e6 100644 --- a/client/src/types/index.d.ts +++ b/client/src/types/index.d.ts @@ -0,0 +1,7 @@ +type Token = { + userId: number; + token: string; + expiresAt: Date; +}; + +export { Token }; \ No newline at end of file