From e477823db110ca87f1d0da258fb6927bac451e88 Mon Sep 17 00:00:00 2001 From: Arphik Date: Sat, 29 May 2021 17:17:02 +0200 Subject: [PATCH 1/2] First commit --- SK.WebApp/src/pages/Home.tsx | 1 + workspace.code-workspace | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 workspace.code-workspace diff --git a/SK.WebApp/src/pages/Home.tsx b/SK.WebApp/src/pages/Home.tsx index 1ee77e9..a30533e 100644 --- a/SK.WebApp/src/pages/Home.tsx +++ b/SK.WebApp/src/pages/Home.tsx @@ -8,6 +8,7 @@ import { import { useInterval } from '../hooks/useInterval'; import { DefaultLayout } from '../components/Layout/DefaultLayout'; import { Typography } from '../components/Typography/Typography'; +import { userRegister } from '../userRegister'; export const Home = () => { const dispatch = useAppDispatch(); diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file From 49b5f4eecab0ccdd226a78474d4518664d6bf8b0 Mon Sep 17 00:00:00 2001 From: Arphik Date: Mon, 7 Jun 2021 19:07:12 +0200 Subject: [PATCH 2/2] Added new frontend method getLoggedUser() in src/getLoggedUser.ts --- SK.WebApp/src/getLoggedUser.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SK.WebApp/src/getLoggedUser.ts diff --git a/SK.WebApp/src/getLoggedUser.ts b/SK.WebApp/src/getLoggedUser.ts new file mode 100644 index 0000000..85f78ca --- /dev/null +++ b/SK.WebApp/src/getLoggedUser.ts @@ -0,0 +1,23 @@ + +export type GetLoggedUserResponse = { + username: string; + token: string; + image: string; +}; + +export const getLoggedUser = async (): Promise => { + + try { + const response = await fetch(`localhost:5001/${navigator.language}/api/User`, { + method: 'GET', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + }, + }); + + return response.json(); + } catch (error) { + console.warn('Login was failed.', error); + } +};