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..9438cec 100644 --- a/app/components/Profile/Profile.Activity.tsx +++ b/app/components/Profile/Profile.Activity.tsx @@ -1,49 +1,98 @@ "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"; +import { ProfileActivityFriends } from "./Profile.ActivityFriends"; export function ProfileActivity(props: { profile_id: number; commentCount: number; videoCount: number; collectionCount: number; + collectionPreview: any; friendsCount: number; + friendsPreview: any; }) { + 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 ( - +

Активность

-
-
-

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

-

{props.videoCount} видео

-
-
- -

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

- -

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

-
-
+ + + + + + + + {tab == "collections" && ( + + )} + {tab == "comments" && <>comments} + {tab == "friends" && } + {tab == "videos" && <>videos}
); } diff --git a/app/components/Profile/Profile.ActivityCollections.tsx b/app/components/Profile/Profile.ActivityCollections.tsx new file mode 100644 index 0000000..42e0fe7 --- /dev/null +++ b/app/components/Profile/Profile.ActivityCollections.tsx @@ -0,0 +1,66 @@ +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) => { + return ( + + +
+ +
+ +
+ ); + })} + + {props.content && props.content.length > 0 ? + + +
+ +

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

+
+ +
+ :

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

} +
+
+ ); +}; diff --git a/app/components/Profile/Profile.ActivityFriends.tsx b/app/components/Profile/Profile.ActivityFriends.tsx new file mode 100644 index 0000000..78e2ac2 --- /dev/null +++ b/app/components/Profile/Profile.ActivityFriends.tsx @@ -0,0 +1,70 @@ +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"; +import { Avatar, Button } from "flowbite-react"; + +export const ProfileActivityFriends = (props: { content: any }) => { + return ( +
+ + {props.content && + props.content.length > 0 && + props.content.map((profile) => { + return ( + + +
+ +

{profile.login}

+
+ +
+ ); + })} + {props.content && props.content.length > 0 ? + + + + :

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

} +
+
+ ); +}; diff --git a/app/pages/Profile.tsx b/app/pages/Profile.tsx index 77ce5f1..5721be6 100644 --- a/app/pages/Profile.tsx +++ b/app/pages/Profile.tsx @@ -131,7 +131,9 @@ 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} + friendsPreview={user.friends_preview || []} /> )} {!user.is_stats_hidden && (