diff --git a/client/src/App.tsx b/client/src/App.tsx index 5a507c2..8bab753 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -11,6 +11,7 @@ import { Login } from "./Login"; import { Signup } from "./Signup"; import { Home } from "./Home"; import { + homeAction, loginAction, profileSelfAction, signupAction, @@ -42,9 +43,8 @@ const router = createBrowserRouter([ }, { path: "/home", - loader: async () => { - return await homeLoader(); - }, + loader: homeLoader, + action: homeAction, element: , children: [ { path: "feed", element: , loader: feedLoader }, diff --git a/client/src/Home.scss b/client/src/Home.scss index 1a3d23f..db2229c 100644 --- a/client/src/Home.scss +++ b/client/src/Home.scss @@ -14,6 +14,16 @@ #SidebarUserInfo { display: flex; flex-direction: column; + + button { + background: none; + border: none; + padding: 0; + text-decoration: none; + cursor: pointer; + color: inherit; + font-size: inherit; + } } * { diff --git a/client/src/Home.tsx b/client/src/Home.tsx index b0a083e..10b4af8 100644 --- a/client/src/Home.tsx +++ b/client/src/Home.tsx @@ -1,4 +1,10 @@ -import { NavLink, NavLinkProps, Outlet, useLoaderData } from "react-router-dom"; +import { + Form, + NavLink, + NavLinkProps, + Outlet, + useLoaderData, +} from "react-router-dom"; import { homeLoader, LoaderToType } from "./loaders"; import { isError } from "./api/dto"; @@ -26,6 +32,16 @@ export function Home() {
username: {loaderData.username} name: {loaderData.fullName} + {/*method post for everything to reload*/} +
+ +
diff --git a/client/src/ProfileCard.scss b/client/src/ProfileCard.scss index 10f0d61..efa37cc 100644 --- a/client/src/ProfileCard.scss +++ b/client/src/ProfileCard.scss @@ -2,14 +2,38 @@ width: 15rem; height: 5rem; display: flex; - flex-direction: column; + flex-direction: row; border: 1px solid #EFEFEF; border-radius: 7px; padding: 1rem; - .fullName{ - font-size: 1.3rem; - } - .username{ +flex: auto; + .profileInfo { + display: flex; + flex-direction: column; + flex-grow: 1; + a { + text-decoration: none; + color: black; + } + + .fullName{ + font-size: 1.3rem; + } + .username{ + + } + } + + .profileActions { + button { + background: none; + border: none; + padding: 0; + text-decoration: none; + cursor: pointer; + color: inherit; + font-size: 0.8rem; + } } } \ No newline at end of file diff --git a/client/src/ProfileCard.tsx b/client/src/ProfileCard.tsx index b8a4b66..f3b1d60 100644 --- a/client/src/ProfileCard.tsx +++ b/client/src/ProfileCard.tsx @@ -16,36 +16,40 @@ export function ProfileCard({ }) { return (
- - {fullName} - - - {username} - - {actions && - (alreadyFollowing ? ( -
- - -
- ) : ( -
- - -
- ))} +
+ + {fullName} + + + {username} + +
+
+ {actions && + (alreadyFollowing ? ( +
+ + +
+ ) : ( +
+ + +
+ ))} +
); } diff --git a/client/src/UserList.scss b/client/src/UserList.scss new file mode 100644 index 0000000..8d87b47 --- /dev/null +++ b/client/src/UserList.scss @@ -0,0 +1,11 @@ +.userList { + min-width: 100%; + display: flex; + flex-direction: row; + padding: 2.5rem 2rem 0; + flex-wrap: wrap; + + .profileCard { + margin: 0.2rem; + } +} \ No newline at end of file diff --git a/client/src/UserList.tsx b/client/src/UserList.tsx index eb02ed9..7db546b 100644 --- a/client/src/UserList.tsx +++ b/client/src/UserList.tsx @@ -4,6 +4,8 @@ import { isError } from "./api/dto"; import { ProfileCard } from "./ProfileCard"; import { useHomeContext } from "./HomeContext"; +import "./UserList.scss"; + export function UserList() { const loaderData = useLoaderData() as LoaderToType; const homeContext = useHomeContext(); @@ -17,7 +19,7 @@ export function UserList() { return
Error
; } return ( -
+
{people.map((u) => { return ( any> = @@ -62,10 +62,18 @@ export async function profileSelfAction({ request }: ActionFunctionArgs) { } } +export async function homeAction({ request }: ActionFunctionArgs) { + const formData = await request.formData(); + const intent = formData.get("intent")!.toString(); + if (intent == "logout") { + deleteToken(); + return redirect("/"); + } +} + export async function userListAction({ request }: ActionFunctionArgs) { const formData = await request.formData(); const intent = formData.get("intent")!.toString(); - console.log(intent); if (intent == "follow") { return await addFollower(formData.get("uuid")!.toString()); } else if (intent == "unfollow") {