diff --git a/README.md b/README.md
index 8366388..450d2a2 100644
--- a/README.md
+++ b/README.md
@@ -19,3 +19,4 @@ Table:
| 14.07.2023 | Navbar | 10 |
| 16.07.2023 | Login and register page | 20 |
| 16.07.2023 | Fix mock schema and move mock injections out of index.js | 1 |
+| 18.07.2023 | Home page and navigate to login/register page if not logged in | 20 |
diff --git a/client/src/App.js b/client/src/App.js
index d8cee44..c788691 100644
--- a/client/src/App.js
+++ b/client/src/App.js
@@ -11,6 +11,7 @@ import { themeSettings } from "theme";
function App() {
const mode = useSelector((state) => state.mode);
const theme = useMemo(() => createTheme(themeSettings(mode)), [mode]);
+ const isLogged = Boolean(useSelector((state) => state.token));
return (
@@ -19,8 +20,14 @@ function App() {
} />
- } />
- } />
+ : }
+ />
+ : }
+ />
diff --git a/client/src/components/ProfilePhoto.jsx b/client/src/components/ProfilePhoto.jsx
new file mode 100644
index 0000000..762226f
--- /dev/null
+++ b/client/src/components/ProfilePhoto.jsx
@@ -0,0 +1,20 @@
+import { Box } from "@mui/material";
+
+const ProfilePhoto = ({ image, size = "60px" }) => {
+ return (
+
+
+
+ );
+};
+
+export default ProfilePhoto;
diff --git a/client/src/components/WidgetWrapper.jsx b/client/src/components/WidgetWrapper.jsx
new file mode 100644
index 0000000..c057247
--- /dev/null
+++ b/client/src/components/WidgetWrapper.jsx
@@ -0,0 +1,10 @@
+import { Box } from "@mui/material";
+import { styled } from "@mui/system";
+
+const WidgetWrapper = styled(Box)(({ theme }) => ({
+ padding: " 1.5 rem 1.5 rem 0.75rem 1.5rem",
+ backgroundColor: theme.palette.background.alt,
+ borderRadius: "0.75rem",
+}));
+
+export default WidgetWrapper;
diff --git a/client/src/scenes/homePage/index.jsx b/client/src/scenes/homePage/index.jsx
index 35b800d..3b38331 100644
--- a/client/src/scenes/homePage/index.jsx
+++ b/client/src/scenes/homePage/index.jsx
@@ -1,7 +1,33 @@
+import { Box, useMediaQuery } from "@mui/material";
+import { useSelector } from "react-redux";
+import Navbar from "scenes/navbar";
+import UserWidget from "scenes/widgets/UserWidget";
+
const HomePage = () => {
- return (
-
homepage
- )
+ const isNotMobile = useMediaQuery("(min-width: 1000px)");
+ const { _id, profilePicturePath } = useSelector((state) => state.user);
+
+ return (
+
+
+
+
+
+
+
+ {isNotMobile && }
+
+
+ );
};
export default HomePage;
diff --git a/client/src/scenes/widgets/UserWidget.jsx b/client/src/scenes/widgets/UserWidget.jsx
new file mode 100644
index 0000000..eedfcd6
--- /dev/null
+++ b/client/src/scenes/widgets/UserWidget.jsx
@@ -0,0 +1,132 @@
+import {
+ ManageAccountsOutlined,
+ EditOutlined,
+ LocationOnOutlined,
+ FavoriteOutlined,
+} from "@mui/icons-material";
+import { Box, Typography, Divider, useTheme } from "@mui/material";
+import ProfilePhoto from "components/ProfilePhoto";
+import WidgetWrapper from "components/WidgetWrapper";
+import FlexBetween from "components/FlexBetween";
+import { useSelector } from "react-redux";
+import { useEffect, useState } from "react";
+import { useNavigate } from "react-router-dom";
+
+const UserWidget = ({ userId, profilePicturePath }) => {
+ const [user, setUser] = useState(null);
+ const { palette } = useTheme();
+ const navigate = useNavigate();
+ const token = useSelector((state) => state.token);
+ const dark = palette.neutral.dark;
+ const medium = palette.neutral.medium;
+ const main = palette.neutral.main;
+
+ const getUser = async () => {
+ const response = await fetch(`http://localhost:3001/users/${userId}`, {
+ method: "GET",
+ headers: { Authorization: `Bearer ${token}` },
+ });
+ const data = await response.json();
+ setUser(data);
+ };
+
+ useEffect(() => {
+ getUser();
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
+
+ if (!user) return null;
+
+ const { firstName, lastName, location, description, friends } = user;
+
+ return (
+
+ navigate(`/profile/${userId}`)}
+ >
+
+
+
+
+ {firstName} {lastName}
+
+
+ {friends.length} friend(s)
+
+
+
+
+
+
+
+
+
+
+ {location}
+
+
+
+ {description}
+
+
+
+
+
+ Other platforms
+
+
+
+
+
+
+ Facebook
+
+ Social media
+
+
+
+
+
+
+
+
+
+ Instagram
+
+ Social media
+
+
+
+
+
+
+
+
+
+ LinkedIn
+
+ Network platform
+
+
+
+
+
+
+ );
+};
+
+export default UserWidget;