diff --git a/client/src/AuthenticatedApp.tsx b/client/src/AuthenticatedApp.tsx index 8806e00..0997689 100644 --- a/client/src/AuthenticatedApp.tsx +++ b/client/src/AuthenticatedApp.tsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from "react"; import { Route, Routes } from "react-router-dom"; -import Banner from "./components/Banner/Banner"; -import Navbar from "./components/Navbar/Navbar"; +import Header from "./components/Header/Header"; import MainPage from "./pages/MainPage/MainPage"; import Forums from "./pages/Forums/Forums"; import Profiles from "./pages/Profiles/Profiles"; @@ -39,8 +38,7 @@ const AuthenticatedApp = () => { return (
- - +
} /> } /> diff --git a/client/src/components/Header/Header.tsx b/client/src/components/Header/Header.tsx new file mode 100644 index 0000000..3e9b71c --- /dev/null +++ b/client/src/components/Header/Header.tsx @@ -0,0 +1,113 @@ +import React, { useState, useRef, useEffect } from "react"; +import { Link, useLocation, useNavigate } from "react-router-dom"; +import logo from "../../assets/hammer.png"; +import { useAppDispatch, useAppSelector } from "../../app/hooks"; +import { logout } from "../../features/user/userSlice"; + +const Header = (): JSX.Element => { + const user = useAppSelector((state) => state.user.userData); + const dispatch = useAppDispatch(); + const navigate = useNavigate(); + const location = useLocation(); + const [showDropdown, setShowDropdown] = useState(false); + const dropdownRef = useRef(null); + + const handleLogout = () => { + dispatch(logout()); + navigate("/"); + //TODO CLEAR ALL STATE + }; + + const currentPath = location.pathname.replace("/app/", ""); + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if ( + dropdownRef.current && + !dropdownRef.current.contains(event.target as Node) + ) { + setShowDropdown(false); + } + }; + + document.addEventListener("mousedown", handleClickOutside); + return () => document.removeEventListener("mousedown", handleClickOutside); + }, [dropdownRef]); + + return ( +
+
+ Code Hammers Logo +

Code Hammers

+
+ +
+
+ + MainPage + + + Profiles + + + Forums + +
+
+
+ + {showDropdown && ( + + )} +
+
+ ); +}; + +export default Header; diff --git a/client/src/components/ProfileThumb/ProfileThumb.tsx b/client/src/components/ProfileThumb/ProfileThumb.tsx index 6ea3856..892b525 100644 --- a/client/src/components/ProfileThumb/ProfileThumb.tsx +++ b/client/src/components/ProfileThumb/ProfileThumb.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { useAppDispatch } from "../../app/hooks"; import { IProfile } from "../../../types/profile"; interface ProfileThumbProps { @@ -7,19 +6,18 @@ interface ProfileThumbProps { } const ProfileThumb = ({ profile }: ProfileThumbProps): JSX.Element => { - const dispatch = useAppDispatch(); + const defaultImage = "https://picsum.photos/200"; return ( -
- {profile.profilePhoto && ( - Profile - )} -

{profile.fullName}

-

{profile.personalBio}

+
+ {profile.fullName + +

{profile.fullName}

+

{profile.personalBio}

); }; diff --git a/client/src/pages/MainPage/MainPage.tsx b/client/src/pages/MainPage/MainPage.tsx index cfb1aec..75406b7 100644 --- a/client/src/pages/MainPage/MainPage.tsx +++ b/client/src/pages/MainPage/MainPage.tsx @@ -5,9 +5,105 @@ const MainPage = (): JSX.Element => { const user = useAppSelector((state) => state.user.userData); return ( -
-

Main Page

-

Welcome {user?.firstName} !

+
+

Welcome!

+ +
+ Description of Image 1 +
+

About Code Hammers

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum + in ligula eu erat sollicitudin porttitor. Nunc congue mi eget nunc + dapibus dictum.Duis tempus diam ac massa bibendum, sed tempus sapien + posuere. In elementum enim ac dui interdum porta. Pellentesque + habitant morbi tristique senectus et netus et malesuada fames ac. +

+
+
+ +
+ Description of Image 1 +
+

Features

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum + in ligula eu erat sollicitudin porttitor. Nunc congue mi eget nunc + dapibus dictum. Duis tempus diam ac massa bibendum, sed tempus + sapien posuere. In elementum enim ac dui interdum porta. + Pellentesque habitant morbi tristique senectus et netus et malesuada + fames ac. +

+
+
+ +
+ Description of Image 1 +
+

Get Started!

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum + in ligula eu erat sollicitudin porttitor. Nunc congue mi eget nunc + dapibus dictum.Duis tempus diam ac massa bibendum, sed tempus sapien + posuere. In elementum enim ac dui interdum porta. Pellentesque + habitant morbi tristique senectus et netus et malesuada fames ac. +

+
+
+ +
+ Description of Image 1 +
+

Boopity Bops

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum + in ligula eu erat sollicitudin porttitor. Nunc congue mi eget nunc + dapibus dictum. Duis tempus diam ac massa bibendum, sed tempus + sapien posuere. In elementum enim ac dui interdum porta. + Pellentesque habitant morbi tristique senectus et netus et malesuada + fames ac. +

+
+
+ +
+ Description of Image 1 +
+

Bopitty Boops

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum + in ligula eu erat sollicitudin porttitor. Nunc congue mi eget nunc + dapibus dictum.Duis tempus diam ac massa bibendum, sed tempus sapien + posuere. In elementum enim ac dui interdum porta. Pellentesque + habitant morbi tristique senectus et netus et malesuada fames ac. +

+
+
); }; diff --git a/client/src/pages/MainPage/__snapshots__/MainPage.test.tsx.snap b/client/src/pages/MainPage/__snapshots__/MainPage.test.tsx.snap deleted file mode 100644 index f9bfca1..0000000 --- a/client/src/pages/MainPage/__snapshots__/MainPage.test.tsx.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`MainPage Component renders correctly 1`] = ` -
-

- Main Page -

-

- Welcome - ! -

-
-`; diff --git a/client/src/pages/Profiles/Profiles.tsx b/client/src/pages/Profiles/Profiles.tsx index 173b3ac..6d3ba6d 100644 --- a/client/src/pages/Profiles/Profiles.tsx +++ b/client/src/pages/Profiles/Profiles.tsx @@ -14,15 +14,20 @@ const Profiles = (): JSX.Element => { return ( <> -
+

PROFILES

-
-
- {profiles.map((profile, index) => ( - - - - ))} + +
+ {profiles.map((profile, index) => ( + + + + ))} +
); diff --git a/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap b/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap deleted file mode 100644 index 5be788e..0000000 --- a/client/src/pages/Profiles/__snapshots__/Profiles.test.tsx.snap +++ /dev/null @@ -1,47 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`MainPage Component renders correctly 1`] = ` -[ -
-

- PROFILES -

-
, - , -] -`;