@@ -23,6 +23,7 @@ import { Skeleton } from '@/components/ui/skeleton'
2323import { Textarea } from '@/components/ui/textarea'
2424import { toast } from '@/components/ui/use-toast'
2525import { useOrganizationData } from '@/hooks/use-organization-data'
26+ import type { PublisherProfileResponse } from '@codebuff/common/types/publisher'
2627
2728export default function OrganizationSettingsPage ( ) {
2829 const { data : session , status } = useSession ( )
@@ -38,10 +39,34 @@ export default function OrganizationSettingsPage() {
3839 const [ deleteDialogOpen , setDeleteDialogOpen ] = useState ( false )
3940 const [ deleteConfirmSlug , setDeleteConfirmSlug ] = useState ( '' )
4041 const [ deleting , setDeleting ] = useState ( false )
42+ const [ publishers , setPublishers ] = useState < PublisherProfileResponse [ ] > ( [ ] )
43+ const [ publishersLoading , setPublishersLoading ] = useState ( true )
4144
4245 // Use the custom hook for organization data
4346 const { organization, isLoading, error } = useOrganizationData ( orgSlug )
4447
48+ // Fetch publishers data for this organization
49+ useEffect ( ( ) => {
50+ const fetchPublishers = async ( ) => {
51+ if ( ! organization ?. id ) return
52+
53+ setPublishersLoading ( true )
54+ try {
55+ const response = await fetch ( `/api/orgs/${ organization . id } /publishers` )
56+ if ( response . ok ) {
57+ const data = await response . json ( )
58+ setPublishers ( data . publishers || [ ] )
59+ }
60+ } catch ( error ) {
61+ console . error ( 'Error fetching publishers:' , error )
62+ } finally {
63+ setPublishersLoading ( false )
64+ }
65+ }
66+
67+ fetchPublishers ( )
68+ } , [ organization ?. id ] )
69+
4570 // Initialize form when organization data loads
4671 useEffect ( ( ) => {
4772 if ( organization ) {
@@ -278,26 +303,104 @@ export default function OrganizationSettingsPage() {
278303 { canManageOrg && (
279304 < Card >
280305 < CardHeader >
281- < CardTitle > Publisher Profile</ CardTitle >
306+ < CardTitle className = "flex items-center" >
307+ < User className = "mr-2 h-5 w-5" />
308+ Publisher Profiles
309+ </ CardTitle >
310+ < p className = "text-sm text-muted-foreground" >
311+ Manage publisher profiles for this organization to publish and
312+ distribute agents
313+ </ p >
282314 </ CardHeader >
283315 < CardContent className = "space-y-4" >
284- < div >
285- < h4 className = "font-medium mb-2" >
286- Create Organization Publisher
287- </ h4 >
288- < p className = "text-sm text-muted-foreground mb-4" >
289- Create a publisher profile for this organization to publish
290- agents.
291- </ p >
292- < Link
293- href = { `/publishers?org=${ organization . id } &type=organization` }
294- >
295- < Button className = "flex items-center" >
296- < User className = "mr-2 h-4 w-4" />
297- Create Publisher Profile
298- </ Button >
299- </ Link >
300- </ div >
316+ { publishersLoading ? (
317+ < div className = "space-y-2" >
318+ < Skeleton className = "h-4 w-48" />
319+ < Skeleton className = "h-4 w-64" />
320+ < Skeleton className = "h-10 w-40" />
321+ </ div >
322+ ) : (
323+ < div >
324+ < div className = "flex items-center justify-between mb-4" >
325+ < h4 className = "font-medium" >
326+ Organization Publishers ({ publishers . length } )
327+ </ h4 >
328+ < Link
329+ href = { `/publishers/new?org=${ organization . id } &type=organization` }
330+ >
331+ < Button className = "flex items-center" >
332+ < User className = "mr-2 h-4 w-4" />
333+ Create Publisher Profile
334+ </ Button >
335+ </ Link >
336+ </ div >
337+
338+ { publishers . length === 0 ? (
339+ < div className = "text-center py-8 bg-muted/50 rounded-lg" >
340+ < p className = "text-sm text-muted-foreground mb-4" >
341+ No publisher profiles created yet.
342+ </ p >
343+ < p className = "text-xs text-muted-foreground" >
344+ Create a publisher profile to start publishing agents
345+ for this organization.
346+ </ p >
347+ </ div >
348+ ) : (
349+ < div className = "space-y-3" >
350+ { publishers . map ( ( publisher ) => (
351+ < div
352+ key = { publisher . id }
353+ className = "bg-muted/50 rounded-lg p-4"
354+ >
355+ < div className = "flex items-start justify-between" >
356+ < div className = "flex-1" >
357+ < div className = "flex items-center space-x-2 mb-2" >
358+ < h5 className = "font-medium" >
359+ { publisher . name }
360+ </ h5 >
361+ { publisher . verified && (
362+ < span className = "text-green-600 text-sm" >
363+ ✓ Verified
364+ </ span >
365+ ) }
366+ </ div >
367+ < p className = "text-sm text-muted-foreground mb-2" >
368+ @{ publisher . id }
369+ </ p >
370+ { publisher . bio && (
371+ < p className = "text-sm mb-2" >
372+ { publisher . bio }
373+ </ p >
374+ ) }
375+ < div className = "flex items-center space-x-4 text-sm text-muted-foreground" >
376+ < span >
377+ { publisher . agentCount || 0 } agents published
378+ </ span >
379+ < span >
380+ Created{ ' ' }
381+ { new Date (
382+ publisher . created_at
383+ ) . toLocaleDateString ( ) }
384+ </ span >
385+ </ div >
386+ </ div >
387+ < Link href = { `/publishers/${ publisher . id } ` } >
388+ < Button
389+ variant = "outline"
390+ size = "sm"
391+ className = "flex items-center"
392+ >
393+ < User className = "mr-2 h-4 w-4" />
394+ View Profile
395+ </ Button >
396+ </ Link >
397+ </ div >
398+ </ div >
399+ ) ) }
400+ </ div >
401+ ) }
402+ </ div >
403+ ) }
301404 </ CardContent >
302405 </ Card >
303406 ) }
0 commit comments