From eea123a3f05e8785ce8b7b5edc6708d5cbd90f67 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sat, 16 Dec 2023 22:03:03 +0100 Subject: [PATCH] show other users --- client/src/App.tsx | 8 ++++---- client/src/Profile.tsx | 28 +++++++++++++++------------- client/src/api/Person.ts | 6 ++++++ client/src/loaders.ts | 14 ++++++++++---- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 406ec43..74f1ca6 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -11,7 +11,7 @@ import { Login } from "./Login"; import { Signup } from "./Signup"; import { Home } from "./Home"; import { loginAction, profileSelfAction, signupAction } from "./actions"; -import { homeLoader, profileSelfLoader } from "./loaders"; +import { homeLoader, profileLoader } from "./loaders"; import { isError } from "./api/dto"; import { Feed } from "./Feed"; import { Messages } from "./Messages"; @@ -40,14 +40,14 @@ const router = createBrowserRouter([ { path: "messages", element: }, { path: "profile", - loader: async () => { - return await profileSelfLoader(); - }, + loader: profileLoader, action: profileSelfAction, element: , }, { path: "profile/:username", + loader: profileLoader, + // action: profileSelfAction, element: , }, ], diff --git a/client/src/Profile.tsx b/client/src/Profile.tsx index c4536c9..d64f0d0 100644 --- a/client/src/Profile.tsx +++ b/client/src/Profile.tsx @@ -1,8 +1,7 @@ import "./Profile.scss"; import { Form, Link, useLoaderData } from "react-router-dom"; -import { LoaderToType, profileSelfLoader } from "./loaders"; +import { LoaderToType, profileLoader } from "./loaders"; import { isError } from "./api/dto"; -import { ProfileCard } from "./ProfileCard"; import { Post } from "./Post"; export interface IProfileProps { @@ -10,9 +9,7 @@ export interface IProfileProps { } export function Profile({ self }: IProfileProps) { - const loaderData = useLoaderData() as LoaderToType< - typeof profileSelfLoader - >; + const loaderData = useLoaderData() as LoaderToType; if (!loaderData || isError(loaderData)) { return
Error
; @@ -28,14 +25,19 @@ export function Profile({ self }: IProfileProps) { {loaderData.user.fullName} {loaderData.user.fullName} -
-
-