From 8cf1bb534dfcb12cda47c4c6656a48198ebdb0da Mon Sep 17 00:00:00 2001 From: Radiquum Date: Thu, 3 Apr 2025 21:07:44 +0500 Subject: [PATCH] refactor: start redesign of user page --- .gitignore | 2 + app/components/Profile/Profile.Role.tsx | 15 ++ app/components/Profile/Profile.Social.tsx | 20 ++ app/components/Profile/Profile.User.tsx | 259 +++++++++++----------- app/pages/Profile.tsx | 100 ++++----- 5 files changed, 211 insertions(+), 185 deletions(-) create mode 100644 app/components/Profile/Profile.Role.tsx create mode 100644 app/components/Profile/Profile.Social.tsx diff --git a/.gitignore b/.gitignore index f6c46f4..8595241 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ videos/* !videos/*.js !videos/*.ts public/_next-video + +API-Trace/* \ No newline at end of file diff --git a/app/components/Profile/Profile.Role.tsx b/app/components/Profile/Profile.Role.tsx new file mode 100644 index 0000000..ac1e13a --- /dev/null +++ b/app/components/Profile/Profile.Role.tsx @@ -0,0 +1,15 @@ +interface UserRoleProps { + name: string; + color: string; +} + +export const UserRole = ({ name, color }: UserRoleProps) => { + return ( +
+

{name}

+
+ ); +}; diff --git a/app/components/Profile/Profile.Social.tsx b/app/components/Profile/Profile.Social.tsx new file mode 100644 index 0000000..e9ae218 --- /dev/null +++ b/app/components/Profile/Profile.Social.tsx @@ -0,0 +1,20 @@ +interface UserSocialProps { + icon: string; + url?: string; + nickname: string; + color: string; +} + +export const UserSocial = ({ nickname, icon, color }: UserSocialProps) => { + return ( +
+
+ +

{nickname}

+
+
+ ); +}; diff --git a/app/components/Profile/Profile.User.tsx b/app/components/Profile/Profile.User.tsx index 2cdaa99..e2033cc 100644 --- a/app/components/Profile/Profile.User.tsx +++ b/app/components/Profile/Profile.User.tsx @@ -1,143 +1,150 @@ "use client"; -import { Avatar, Card, Button } from "flowbite-react"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -import { Chip } from "../Chip/Chip"; -export const ProfileUser = (props: { - isOnline: boolean; +import { Avatar, Card, useThemeMode } from "flowbite-react"; +import { UserRole } from "./Profile.Role"; +import { UserSocial } from "./Profile.Social"; +import Link from "next/link"; + +interface ProfileUserProps { avatar: string; login: string; status: string; - socials: { - isPrivate: boolean; - hasSocials: boolean; - socials: { - name: string; - nickname: any; - icon: string; - urlPrefix?: string | undefined; - }[]; - }; - chips: { - hasChips: boolean; - isMyProfile: boolean; - isVerified: boolean; - isSponsor: boolean; - isBlocked: boolean; - roles?: { - id: number; - name: string; - color: string; - }[]; - }; rating: number; -}) => { - const router = useRouter(); + roles: { + id: number; + name: string; + color: string; + }[]; + isMyProfile: boolean; + isSponsor: boolean; + isBlocked: boolean; + isVerified: boolean; + isOnline: boolean; + socials: { + vk: string; + tg: string; + tt: string; + inst: string; + discord: string; + }; +} + +export const ProfileUser = ({ + avatar, + login, + status, + rating, + roles, + isMyProfile, + isVerified, + isOnline, + isSponsor, + isBlocked, + socials, +}: ProfileUserProps) => { + + const theme = useThemeMode().mode; + return ( - - {props.chips.hasChips && ( -
- {props.chips.isMyProfile && ( - - )} - {props.chips.isVerified && ( - - )} - {props.chips.isSponsor && ( - - )} - {props.chips.isBlocked && ( - - )} - {props.chips.roles && - props.chips.roles.length > 0 && - props.chips.roles.map((role: any) => ( - - ))} + + {(isMyProfile || + isVerified || + isSponsor || + isBlocked || + roles.length > 0) && ( +
+ {isMyProfile && } + {isBlocked && } + {isVerified && } + {isSponsor && } + {roles.map((role) => ( + + ))}
)} - -
-
- {props.login}{" "} +
+ +
+

+ {login} 0 - ? "border-green-500 text-green-500" - : "border-red-500 text-red-500" + className={`border rounded-md px-2 py-1 min-w-8 text-sm flex items-center justify-center ${ + rating > 0 ? + "border-green-500 text-green-500" + : "border-red-500 text-red-500" }`} > - {props.rating} + {rating} -

-
- {props.status} -
+

+

{status}

- - {props.socials.hasSocials && !props.socials.isPrivate && ( -
- {props.socials.socials - .filter((social: any) => { - if (social.nickname == "") { - return false; - } - return true; - }) - .map((social: any) => { - if (social.name == "discord" && social.nickname != "") - return ( - - ); - return ( - - - - ); - })} +
+ {(socials.vk || + socials.tg || + socials.discord || + socials.tt || + socials.inst) && ( +
+ {socials.vk && ( + + + + )} + {socials.tg && ( + + + + )} + {socials.tt && ( + + + + )} + {socials.inst && ( + + + + )} + {socials.discord && ( + + )}
)} diff --git a/app/pages/Profile.tsx b/app/pages/Profile.tsx index 7a81d93..65bd2c3 100644 --- a/app/pages/Profile.tsx +++ b/app/pages/Profile.tsx @@ -59,50 +59,7 @@ export const ProfilePage = (props: any) => { ); } - const hasSocials = - user.vk_page != "" || - user.tg_page != "" || - user.tt_page != "" || - user.inst_page != "" || - user.discord_page != "" || - false; - const socials = [ - { - name: "vk", - nickname: user.vk_page, - icon: "fa6-brands--vk", - urlPrefix: "https://vk.com/", - }, - { - name: "telegram", - nickname: user.tg_page, - icon: "fa6-brands--telegram", - urlPrefix: "https://t.me/", - }, - { - name: "discord", - nickname: user.discord_page, - icon: "fa6-brands--discord", - }, - { - name: "tiktok", - nickname: user.tt_page, - icon: "fa6-brands--tiktok", - urlPrefix: "https://tiktok.com/@", - }, - { - name: "instagram", - nickname: user.inst_page, - icon: "fa6-brands--instagram", - urlPrefix: "https://instagram.com/", - }, - ]; - const hasChips = - user.is_verified || - user.is_blocked || - (user.roles && user.roles.length > 0) || - isMyProfile; const isPrivacy = user.is_stats_hidden || user.is_counts_hidden || user.is_social_hidden; @@ -120,7 +77,45 @@ export const ProfilePage = (props: any) => { is_me_blocked={user.is_me_blocked} />
-
+
+ + {authUser.token && ( + + )} +
+
+
+ {/*
{ )}
- {authUser.token && ( - - )} + {!user.is_stats_hidden && ( <> { )}
-
+
*/}