From 339d4150b1377388dabdfe6bd6674763aa94142b Mon Sep 17 00:00:00 2001 From: Radiquum Date: Fri, 4 Apr 2025 05:26:08 +0500 Subject: [PATCH 1/4] feat: collection activity preview --- .../CollectionLink/CollectionLink.tsx | 12 +-- app/components/Profile/Profile.Activity.tsx | 84 +++++++++++++++++-- .../Profile/Profile.ActivityCollections.tsx | 64 ++++++++++++++ app/pages/Profile.tsx | 1 + 4 files changed, 150 insertions(+), 11 deletions(-) create mode 100644 app/components/Profile/Profile.ActivityCollections.tsx diff --git a/app/components/CollectionLink/CollectionLink.tsx b/app/components/CollectionLink/CollectionLink.tsx index 4b45fe8..61371e1 100644 --- a/app/components/CollectionLink/CollectionLink.tsx +++ b/app/components/CollectionLink/CollectionLink.tsx @@ -49,11 +49,13 @@ export const CollectionLink = (props: any) => { {props.title}

-

- {`${props.description.slice(0, 125)}${ - props.description.length > 125 ? "..." : "" - }`} -

+ {props.description && ( +

+ {`${props.description.slice(0, 125)}${ + props.description.length > 125 ? "..." : "" + }`} +

+ )} diff --git a/app/components/Profile/Profile.Activity.tsx b/app/components/Profile/Profile.Activity.tsx index 8768363..365a5f1 100644 --- a/app/components/Profile/Profile.Activity.tsx +++ b/app/components/Profile/Profile.Activity.tsx @@ -1,19 +1,91 @@ "use client"; -import { Card } from "flowbite-react"; -import Link from "next/link"; -import { numberDeclension } from "#/api/utils"; +import { Button, ButtonGroup, Card } from "flowbite-react"; +// import Link from "next/link"; +// import { numberDeclension } from "#/api/utils"; +import { ProfileActivityCollections } from "./Profile.ActivityCollections"; +import { useEffect, useState } from "react"; +import { CollectionCourusel } from "../CollectionCourusel/CollectionCourusel"; export function ProfileActivity(props: { profile_id: number; commentCount: number; videoCount: number; collectionCount: number; + collectionPreview: any; friendsCount: number; }) { + const [tab, setTab] = useState< + "collections" | "comments" | "friends" | "videos" + >("collections"); + + const [collections, setCollections] = useState>({}); + + function _setCollection(array: any[]) { + if (array && array.length == 0) { + return; + } + let _coll = array.filter((col) => { + if (typeof col == "number") { + return false; + } + return true; + }); + _coll.map((col) => { + setCollections((prev) => { + return { + ...prev, + [col.id]: col, + }; + }); + + if ( + col.creator.collections_preview && + col.creator.collections_preview.length > 0 + ) { + _setCollection(col.creator.collections_preview || []); + } + }); + } + + useEffect(() => { + _setCollection(props.collectionPreview || []); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [props.collectionPreview]); + return ( - +

Активность

-
+ + + + + + + {tab == "collections" && ( + + )} + {tab == "comments" && <>comments} + {tab == "friends" && <>friends} + + {/*

{props.commentCount}{" "} @@ -43,7 +115,7 @@ export function ProfileActivity(props: { {numberDeclension(props.commentCount, "друзей", "друга", "друзей")}

-
+
*/}
); } diff --git a/app/components/Profile/Profile.ActivityCollections.tsx b/app/components/Profile/Profile.ActivityCollections.tsx new file mode 100644 index 0000000..5224144 --- /dev/null +++ b/app/components/Profile/Profile.ActivityCollections.tsx @@ -0,0 +1,64 @@ +import { Swiper, SwiperSlide } from "swiper/react"; +import "swiper/css"; +import "swiper/css/navigation"; +import "swiper/css/mousewheel"; +import "swiper/css/scrollbar"; +import { Navigation, Mousewheel, Scrollbar } from "swiper/modules"; +import { CollectionLink } from "../CollectionLink/CollectionLink"; +import Link from "next/link"; + +export const ProfileActivityCollections = (props: { + content: any; + profile_id: number; +}) => { + return ( +
+ + {props.content && + props.content.length > 0 && + props.content.map((collection) => { + console.log(collection); + return ( + + +
+ +
+ +
+ ); + })} + + +
+ +

Все коллекции

+
+ +
+
+
+ ); +}; diff --git a/app/pages/Profile.tsx b/app/pages/Profile.tsx index 77ce5f1..eca09e0 100644 --- a/app/pages/Profile.tsx +++ b/app/pages/Profile.tsx @@ -131,6 +131,7 @@ export const ProfilePage = (props: any) => { commentCount={user.comment_count} videoCount={user.video_count} collectionCount={user.collection_count} + collectionPreview={user.collections_preview || []} friendsCount={user.friend_count} /> )} From 2fce051a54bfb2ecdf18f847335cb59705651999 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Fri, 4 Apr 2025 05:29:36 +0500 Subject: [PATCH 2/4] feat: add counts to activity --- app/components/Profile/Profile.Activity.tsx | 43 +++++---------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/app/components/Profile/Profile.Activity.tsx b/app/components/Profile/Profile.Activity.tsx index 365a5f1..341a7c5 100644 --- a/app/components/Profile/Profile.Activity.tsx +++ b/app/components/Profile/Profile.Activity.tsx @@ -66,13 +66,19 @@ export function ProfileActivity(props: { color={tab == "comments" ? "blue" : "light"} onClick={() => setTab("comments")} > - Комментарии + Комментарии | {props.commentCount} + @@ -84,38 +90,7 @@ export function ProfileActivity(props: { )} {tab == "comments" && <>comments} {tab == "friends" && <>friends} - - {/*
-
-

- {props.commentCount}{" "} - {numberDeclension( - props.commentCount, - "комментарий", - "комментария", - "комментариев" - )} -

-

{props.videoCount} видео

-
-
- -

- {props.collectionCount}{" "} - {numberDeclension( - props.commentCount, - "коллекция", - "коллекции", - "коллекций" - )} -

- -

- {props.friendsCount}{" "} - {numberDeclension(props.commentCount, "друзей", "друга", "друзей")} -

-
-
*/} + {tab == "videos" && <>videos}
); } From 0cd74983f3650b676269374fe86f8721bbb1a5b2 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Fri, 4 Apr 2025 05:58:13 +0500 Subject: [PATCH 3/4] feat: add user friends preview --- app/components/Profile/Profile.Activity.tsx | 4 +- .../Profile/Profile.ActivityCollections.tsx | 1 - .../Profile/Profile.ActivityFriends.tsx | 68 +++++++++++++++++++ app/pages/Profile.tsx | 1 + 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 app/components/Profile/Profile.ActivityFriends.tsx diff --git a/app/components/Profile/Profile.Activity.tsx b/app/components/Profile/Profile.Activity.tsx index 341a7c5..9438cec 100644 --- a/app/components/Profile/Profile.Activity.tsx +++ b/app/components/Profile/Profile.Activity.tsx @@ -5,6 +5,7 @@ import { Button, ButtonGroup, Card } from "flowbite-react"; import { ProfileActivityCollections } from "./Profile.ActivityCollections"; import { useEffect, useState } from "react"; import { CollectionCourusel } from "../CollectionCourusel/CollectionCourusel"; +import { ProfileActivityFriends } from "./Profile.ActivityFriends"; export function ProfileActivity(props: { profile_id: number; @@ -13,6 +14,7 @@ export function ProfileActivity(props: { collectionCount: number; collectionPreview: any; friendsCount: number; + friendsPreview: any; }) { const [tab, setTab] = useState< "collections" | "comments" | "friends" | "videos" @@ -89,7 +91,7 @@ export function ProfileActivity(props: { /> )} {tab == "comments" && <>comments} - {tab == "friends" && <>friends} + {tab == "friends" && } {tab == "videos" && <>videos} ); diff --git a/app/components/Profile/Profile.ActivityCollections.tsx b/app/components/Profile/Profile.ActivityCollections.tsx index 5224144..882965b 100644 --- a/app/components/Profile/Profile.ActivityCollections.tsx +++ b/app/components/Profile/Profile.ActivityCollections.tsx @@ -36,7 +36,6 @@ export const ProfileActivityCollections = (props: { {props.content && props.content.length > 0 && props.content.map((collection) => { - console.log(collection); return ( { + return ( +
+ + {props.content && + props.content.length > 0 && + props.content.map((profile) => { + return ( + + +
+ +

{profile.login}

+
+ +
+ ); + })} + + + +
+
+ ); +}; diff --git a/app/pages/Profile.tsx b/app/pages/Profile.tsx index eca09e0..5721be6 100644 --- a/app/pages/Profile.tsx +++ b/app/pages/Profile.tsx @@ -133,6 +133,7 @@ export const ProfilePage = (props: any) => { collectionCount={user.collection_count} collectionPreview={user.collections_preview || []} friendsCount={user.friend_count} + friendsPreview={user.friends_preview || []} /> )} {!user.is_stats_hidden && ( From 0730b7c7d453ad86743cc76e3ec1b09c32081d39 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Fri, 4 Apr 2025 06:04:23 +0500 Subject: [PATCH 4/4] add empty states --- .../Profile/Profile.ActivityCollections.tsx | 19 +++++++++++-------- .../Profile/Profile.ActivityFriends.tsx | 14 ++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/components/Profile/Profile.ActivityCollections.tsx b/app/components/Profile/Profile.ActivityCollections.tsx index 882965b..42e0fe7 100644 --- a/app/components/Profile/Profile.ActivityCollections.tsx +++ b/app/components/Profile/Profile.ActivityCollections.tsx @@ -49,14 +49,17 @@ export const ProfileActivityCollections = (props: {
); })} - - -
- -

Все коллекции

-
- -
+ + {props.content && props.content.length > 0 ? + + +
+ +

Все коллекции

+
+ +
+ :

У пользователя нет коллекций

} ); diff --git a/app/components/Profile/Profile.ActivityFriends.tsx b/app/components/Profile/Profile.ActivityFriends.tsx index 50aa264..78e2ac2 100644 --- a/app/components/Profile/Profile.ActivityFriends.tsx +++ b/app/components/Profile/Profile.ActivityFriends.tsx @@ -56,12 +56,14 @@ export const ProfileActivityFriends = (props: { content: any }) => { ); })} - - - + {props.content && props.content.length > 0 ? + + + + :

У пользователя нет друзей

} );