22
33import { SharedCollection } from '@/api' ;
44import { PageContent } from '@/components/page-container' ;
5- import { useAppContext } from '@/components/providers/app-provider' ;
6- import { Badge } from '@/components/ui/badge' ;
75import {
86 Breadcrumb ,
97 BreadcrumbItem ,
@@ -14,21 +12,17 @@ import {
1412import { Button } from '@/components/ui/button' ;
1513import {
1614 Card ,
17- CardAction ,
1815 CardDescription ,
1916 CardHeader ,
2017 CardTitle ,
2118} from '@/components/ui/card' ;
2219import { Separator } from '@/components/ui/separator' ;
23- import { apiClient } from '@/lib/api/client' ;
2420import { cn } from '@/lib/utils' ;
2521import _ from 'lodash' ;
26- import { BookOpen , Files , Star , User , VectorSquare } from 'lucide-react' ;
22+ import { BookOpen , Files , VectorSquare } from 'lucide-react' ;
2723import { useTranslations } from 'next-intl' ;
2824import Link from 'next/link' ;
29- import { usePathname , useRouter } from 'next/navigation' ;
30- import { useCallback , useMemo } from 'react' ;
31- import { FaStar } from 'react-icons/fa6' ;
25+ import { usePathname } from 'next/navigation' ;
3226
3327export const CollectionHeader = ( {
3428 className,
@@ -37,47 +31,13 @@ export const CollectionHeader = ({
3731 className ?: string ;
3832 collection : SharedCollection ;
3933} ) => {
40- const router = useRouter ( ) ;
4134 const pathname = usePathname ( ) ;
4235
43- const { user, signIn } = useAppContext ( ) ;
44- const page_collections = useTranslations ( 'page_collections' ) ;
4536 const page_documents = useTranslations ( 'page_documents' ) ;
4637 const page_marketplace = useTranslations ( 'page_marketplace' ) ;
4738 const page_graph = useTranslations ( 'page_graph' ) ;
4839 const sidebar_workspace = useTranslations ( 'sidebar_workspace' ) ;
4940
50- const isOwner = useMemo (
51- ( ) => collection . owner_user_id === user ?. id ,
52- [ collection . owner_user_id , user ?. id ] ,
53- ) ;
54- const isSubscriber = useMemo (
55- ( ) => collection . subscription_id !== null ,
56- [ collection . subscription_id ] ,
57- ) ;
58-
59- const handleSubscribe = useCallback ( async ( ) => {
60- if ( ! user ) {
61- signIn ( ) ;
62- return ;
63- }
64-
65- if ( isSubscriber ) {
66- await apiClient . defaultApi . marketplaceCollectionsCollectionIdSubscribeDelete (
67- {
68- collectionId : collection . id ,
69- } ,
70- ) ;
71- } else {
72- await apiClient . defaultApi . marketplaceCollectionsCollectionIdSubscribePost (
73- {
74- collectionId : collection . id ,
75- } ,
76- ) ;
77- }
78- router . refresh ( ) ;
79- } , [ collection . id , isSubscriber , router , signIn , user ] ) ;
80-
8141 return (
8242 < PageContent className = { cn ( 'flex flex-col gap-4 pb-0' , className ) } >
8343 < div className = "flex items-center" >
@@ -110,31 +70,6 @@ export const CollectionHeader = ({
11070 < Card className = "gap-0 p-0" >
11171 < CardHeader className = "p-4 pb-0" >
11272 < CardTitle className = "mb-0 text-2xl" > { collection . title } </ CardTitle >
113- < CardAction className = "text-muted-foreground flex flex-row items-center gap-4 text-xs" >
114- { isOwner ? (
115- < Badge > { page_collections ( 'mine' ) } </ Badge >
116- ) : (
117- < div className = "flex flex-row items-center gap-1" >
118- < User className = "size-4" />
119- < div className = "max-w-60 truncate" >
120- { collection . owner_username }
121- </ div >
122- </ div >
123- ) }
124- < Button
125- variant = "outline"
126- size = "sm"
127- hidden = { isOwner }
128- onClick = { handleSubscribe }
129- className = "text-muted-foreground cursor-pointer text-xs"
130- >
131- { isSubscriber ? < FaStar className = "text-orange-500" /> : < Star /> }
132-
133- { isSubscriber
134- ? page_collections ( 'subscribed' )
135- : page_collections ( 'subscribe' ) }
136- </ Button >
137- </ CardAction >
13873 </ CardHeader >
13974 < CardDescription className = "mb-4 px-4" >
14075 { _ . truncate ( collection . description || 'No description available' , {
0 commit comments