From f99e39c712f9bb6b6cbf1d61dc7ea506acfa93d7 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 2 Feb 2025 14:33:49 +0300 Subject: [PATCH] Profile page barebones --- .../RightButtonBar/UserButton/UserButton.tsx | 29 ++--- .../ProfileNavbar/ProfileNavbar.tsx | 123 ++++++++++++++++++ .../LoginRegisterPage/LoginPage/LoginPage.tsx | 2 +- .../src/Pages/UserBlogsPage/UserBlogsPage.tsx | 8 +- .../src/Pages/UserPostsPage/UserPostsPage.tsx | 8 ++ .../Pages/UserProfilePage/UserProfilePage.tsx | 11 ++ .../UserSecurityPage/UserSecurityPage.tsx | 8 ++ enshi/src/layout/MainPage/MainPage.tsx | 9 +- enshi/src/layout/ProfilePage/ProfilePage.tsx | 17 +++ enshi/src/routes/routes.tsx | 19 +++ 10 files changed, 204 insertions(+), 30 deletions(-) create mode 100644 enshi/src/Components/ProfileNavbar/ProfileNavbar.tsx create mode 100644 enshi/src/Pages/UserPostsPage/UserPostsPage.tsx create mode 100644 enshi/src/Pages/UserProfilePage/UserProfilePage.tsx create mode 100644 enshi/src/Pages/UserSecurityPage/UserSecurityPage.tsx create mode 100644 enshi/src/layout/ProfilePage/ProfilePage.tsx diff --git a/enshi/src/Components/NavBar/RightButtonBar/UserButton/UserButton.tsx b/enshi/src/Components/NavBar/RightButtonBar/UserButton/UserButton.tsx index cd34fde..4e893d7 100644 --- a/enshi/src/Components/NavBar/RightButtonBar/UserButton/UserButton.tsx +++ b/enshi/src/Components/NavBar/RightButtonBar/UserButton/UserButton.tsx @@ -1,12 +1,9 @@ -import { - LaptopIcon, - PersonIcon -} from "@radix-ui/react-icons"; +import { LaptopIcon, PersonIcon } from "@radix-ui/react-icons"; import { DropdownMenu, Flex, IconButton, Text } from "@radix-ui/themes"; import { Icon } from "@radix-ui/themes/dist/esm/components/callout.js"; import { useAtomValue } from "jotai"; import { useTranslation } from "react-i18next"; -import { Link } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; import { userAtom } from "../../../../AtomStore/AtomStore"; import LoginButton from "./LoginButton/LoginButton"; import LogoutButton from "./LogoutButton/LogoutButton"; @@ -15,6 +12,8 @@ export default function UserButton() { const user = useAtomValue(userAtom); const { t } = useTranslation(); + const navigate = useNavigate(); + return (
@@ -25,37 +24,33 @@ export default function UserButton() { - - - + navigate("/profile")}> +
+ {t("profile")} - +
- - + navigate("/user/blogs")}> +
{t("yourBlogs")} - +
- {user ? ( - - ) : ( - - )} + {user ? : }
diff --git a/enshi/src/Components/ProfileNavbar/ProfileNavbar.tsx b/enshi/src/Components/ProfileNavbar/ProfileNavbar.tsx new file mode 100644 index 0000000..3a7c6b6 --- /dev/null +++ b/enshi/src/Components/ProfileNavbar/ProfileNavbar.tsx @@ -0,0 +1,123 @@ +import { + BoxIcon, + FileTextIcon, + LockClosedIcon, + PersonIcon +} from "@radix-ui/react-icons"; +import { + Avatar, + Badge, + Box, + Button, + Card, + Flex, + Separator, + TabNav, + Text, +} from "@radix-ui/themes"; + +import { useLocation, useNavigate } from "react-router-dom"; + +export default function ProfileNavbar() { + const { hash, pathname } = useLocation(); + + const navigate = useNavigate(); + + console.log(`pathname: ${pathname}, hash: ${hash}`); + return ( + <> + + + navigate("/profile")} + > + + About + + + + navigate("/profile/sec")} + > + + Security + + + + navigate("/profile/posts")} + > + + Posts + {/* */} + + + + + + + + + + + Test User + + + + test + user + + + + + + + + + + + + + + + + + ); +} diff --git a/enshi/src/Pages/LoginRegisterPage/LoginPage/LoginPage.tsx b/enshi/src/Pages/LoginRegisterPage/LoginPage/LoginPage.tsx index 2b1e3db..32faa67 100644 --- a/enshi/src/Pages/LoginRegisterPage/LoginPage/LoginPage.tsx +++ b/enshi/src/Pages/LoginRegisterPage/LoginPage/LoginPage.tsx @@ -63,7 +63,7 @@ export default function LoginPage() { return ( diff --git a/enshi/src/Pages/UserBlogsPage/UserBlogsPage.tsx b/enshi/src/Pages/UserBlogsPage/UserBlogsPage.tsx index b6a9fe6..c00ec11 100644 --- a/enshi/src/Pages/UserBlogsPage/UserBlogsPage.tsx +++ b/enshi/src/Pages/UserBlogsPage/UserBlogsPage.tsx @@ -7,10 +7,6 @@ import BlogCreationDialog from "../../Components/Dialogs/BlogCreationDialog/Blog import { JSONWithInt64 } from "../../utils/idnex"; import SkeletonBoxes from "./SkeletonBoxes/SkeletonBoxes"; -const TAGS = Array.from({ length: 50 }).map( - (_, i, a) => `v1.2.0-beta.${a.length - i}` -); - export default function UserBlogsPage() { const { data, isPending, isFetching } = useQuery({ queryKey: ["userBlogs"], @@ -52,16 +48,14 @@ export default function UserBlogsPage() { {data - ? data?.map((blog: any, b) => { + ? data?.map((blog: any, b: number) => { return ( - <> - ); }) : null} diff --git a/enshi/src/Pages/UserPostsPage/UserPostsPage.tsx b/enshi/src/Pages/UserPostsPage/UserPostsPage.tsx new file mode 100644 index 0000000..c6b7644 --- /dev/null +++ b/enshi/src/Pages/UserPostsPage/UserPostsPage.tsx @@ -0,0 +1,8 @@ + +export default function UserPostsPage() { + return ( +
+

User Posts Page

+
+ ) +} diff --git a/enshi/src/Pages/UserProfilePage/UserProfilePage.tsx b/enshi/src/Pages/UserProfilePage/UserProfilePage.tsx new file mode 100644 index 0000000..ccdf0ca --- /dev/null +++ b/enshi/src/Pages/UserProfilePage/UserProfilePage.tsx @@ -0,0 +1,11 @@ +import { Box, Flex, Text } from "@radix-ui/themes"; + +export default function UserProfilePage() { + return ( + + + This is user profile + + + ); +} diff --git a/enshi/src/Pages/UserSecurityPage/UserSecurityPage.tsx b/enshi/src/Pages/UserSecurityPage/UserSecurityPage.tsx new file mode 100644 index 0000000..324d9fc --- /dev/null +++ b/enshi/src/Pages/UserSecurityPage/UserSecurityPage.tsx @@ -0,0 +1,8 @@ + +export default function UserSecurityPage() { + return ( +
+

User Security Page

+
+ ) +} diff --git a/enshi/src/layout/MainPage/MainPage.tsx b/enshi/src/layout/MainPage/MainPage.tsx index 9b1d1cf..042d1b3 100644 --- a/enshi/src/layout/MainPage/MainPage.tsx +++ b/enshi/src/layout/MainPage/MainPage.tsx @@ -12,10 +12,6 @@ const RETRY_INTERVAL_IN_SECONDS = 1; const SECONDS_IN_MINUTE = 60; const MILLS_IN_SECOND = 1000; -const TAGS = Array.from({ length: 50 }).map( - (_, i, a) => `v1.2.0-beta.${a.length - i}` -); - export default function MainPage() { const setUserData = useSetAtom(userAtom); @@ -65,7 +61,10 @@ export default function MainPage() { - +
diff --git a/enshi/src/layout/ProfilePage/ProfilePage.tsx b/enshi/src/layout/ProfilePage/ProfilePage.tsx new file mode 100644 index 0000000..fffb086 --- /dev/null +++ b/enshi/src/layout/ProfilePage/ProfilePage.tsx @@ -0,0 +1,17 @@ +import { Box, Flex, Separator } from "@radix-ui/themes"; +import { Outlet } from "react-router-dom"; +import ProfileNavbar from "../../Components/ProfileNavbar/ProfileNavbar"; + +export default function ProfilePage() { + return ( + + + + + + + + + + ); +} diff --git a/enshi/src/routes/routes.tsx b/enshi/src/routes/routes.tsx index ef8fa3e..dfe716e 100644 --- a/enshi/src/routes/routes.tsx +++ b/enshi/src/routes/routes.tsx @@ -7,6 +7,7 @@ import { } from "react-router-dom"; import ArticleViewer from "../Components/ArticleViewer/ArticleViewer"; import MainPage from "../layout/MainPage/MainPage"; +import ProfilePage from "../layout/ProfilePage/ProfilePage"; import AuthPageWrapper from "../Pages/AuthPageWrapper/AuthPageWrapper"; import BlogPage from "../Pages/BlogPage/BlogPage"; import LoginPage from "../Pages/LoginRegisterPage/LoginPage/LoginPage"; @@ -15,6 +16,9 @@ import RegisterPage from "../Pages/LoginRegisterPage/RegisterPage/RegisterPage"; import PostCreatorPage from "../Pages/PostCreatorPage/PostCreatorPage"; import RandomPostsPage from "../Pages/RandomPostsPage/RandomPostsPage"; import UserBlogsPage from "../Pages/UserBlogsPage/UserBlogsPage"; +import UserPostsPage from "../Pages/UserPostsPage/UserPostsPage"; +import UserProfilePage from "../Pages/UserProfilePage/UserProfilePage"; +import UserSecurityPage from "../Pages/UserSecurityPage/UserSecurityPage"; function ErrorBoundary() { let error = useRouteError(); @@ -46,6 +50,21 @@ export const routes = createRoutesFromElements( } /> + + + + } + > + } /> + + } /> + + } /> + + } /> }>