MCPcopy Create free account
hub / github.com/CodebuffAI/codebuff / OrganizationSettingsPage

Function OrganizationSettingsPage

web/src/app/orgs/[slug]/settings/page.tsx:23–502  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21import { useOrganizationData } from '@/hooks/use-organization-data'
22
23export default function OrganizationSettingsPage() {
24 const { data: session, status } = useSession()
25 const params = useParams() ?? {}
26 const router = useRouter()
27 const orgSlug = (params.slug as string) ?? ''
28
29 const [updateForm, setUpdateForm] = useState({
30 name: '',
31 description: '',
32 })
33 const [updating, setUpdating] = useState(false)
34 const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
35 const [deleting, setDeleting] = useState(false)
36 const [publishers, setPublishers] = useState<PublisherProfileResponse[]>([])
37 const [publishersLoading, setPublishersLoading] = useState(true)
38
39 // Use the custom hook for organization data
40 const { organization, isLoading, error } = useOrganizationData(orgSlug)
41
42 // Fetch publishers data for this organization
43 useEffect(() => {
44 const fetchPublishers = async () => {
45 if (!organization?.id) return
46
47 setPublishersLoading(true)
48 try {
49 const response = await fetch(`/api/orgs/${organization.id}/publishers`)
50 if (response.ok) {
51 const data = await response.json()
52 setPublishers(data.publishers || [])
53 }
54 } catch (error) {
55 console.error('Error fetching publishers:', error)
56 } finally {
57 setPublishersLoading(false)
58 }
59 }
60
61 fetchPublishers()
62 }, [organization?.id])
63
64 // Initialize form when organization data loads
65 useEffect(() => {
66 if (organization) {
67 setUpdateForm({
68 name: organization.name,
69 description: organization.description || '',
70 })
71 }
72 }, [organization])
73
74 const handleUpdateOrganization = async () => {
75 if (!organization) return
76
77 if (!updateForm.name.trim()) {
78 toast({
79 title: 'Error',
80 description: 'Organization name is required',

Callers

nothing calls this directly

Calls 2

useOrganizationDataFunction · 0.90
fetchPublishersFunction · 0.85

Tested by

no test coverage detected