@@ -8,7 +8,7 @@ import { Button } from '@/components/ui/button'
88import { Input } from '@/components/ui/input'
99import { Badge } from '@/components/ui/badge'
1010import { Skeleton } from '@/components/ui/skeleton'
11- import {
11+ import {
1212 Search ,
1313 Users ,
1414 CreditCard ,
@@ -18,7 +18,7 @@ import {
1818 Eye ,
1919 Filter ,
2020 Download ,
21- GitBranch
21+ GitBranch ,
2222} from 'lucide-react'
2323import Link from 'next/link'
2424import { toast } from '@/components/ui/use-toast'
@@ -40,11 +40,13 @@ interface OrganizationSummary {
4040export default function AdminOrganizationsPage ( ) {
4141 const { data : session , status } = useSession ( )
4242 const router = useRouter ( )
43-
43+
4444 const [ organizations , setOrganizations ] = useState < OrganizationSummary [ ] > ( [ ] )
4545 const [ loading , setLoading ] = useState ( true )
4646 const [ searchTerm , setSearchTerm ] = useState ( '' )
47- const [ statusFilter , setStatusFilter ] = useState < 'all' | 'healthy' | 'warning' | 'critical' > ( 'all' )
47+ const [ statusFilter , setStatusFilter ] = useState <
48+ 'all' | 'healthy' | 'warning' | 'critical'
49+ > ( 'all' )
4850
4951 useEffect ( ( ) => {
5052 if ( status === 'authenticated' ) {
@@ -56,7 +58,7 @@ export default function AdminOrganizationsPage() {
5658 try {
5759 setLoading ( true )
5860 const response = await fetch ( '/api/admin/organizations' )
59-
61+
6062 if ( ! response . ok ) {
6163 if ( response . status === 403 ) {
6264 toast ( {
@@ -86,8 +88,8 @@ export default function AdminOrganizationsPage() {
8688
8789 const exportData = async ( ) => {
8890 try {
89- const response = await fetch ( '/api/admin/organizations /export' )
90-
91+ const response = await fetch ( '/api/admin/orgs /export' )
92+
9193 if ( ! response . ok ) {
9294 throw new Error ( 'Failed to export data' )
9395 }
@@ -115,24 +117,38 @@ export default function AdminOrganizationsPage() {
115117 }
116118 }
117119
118- const filteredOrganizations = organizations . filter ( org => {
119- const matchesSearch = org . name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) ||
120- org . slug . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) ||
121- org . owner_name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) )
122-
123- const matchesStatus = statusFilter === 'all' || org . health_status === statusFilter
124-
120+ const filteredOrganizations = organizations . filter ( ( org ) => {
121+ const matchesSearch =
122+ org . name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) ||
123+ org . slug . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) ||
124+ org . owner_name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) )
125+
126+ const matchesStatus =
127+ statusFilter === 'all' || org . health_status === statusFilter
128+
125129 return matchesSearch && matchesStatus
126130 } )
127131
128132 const getHealthStatusBadge = ( status : string ) => {
129133 switch ( status ) {
130134 case 'healthy' :
131- return < Badge className = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200" > Healthy</ Badge >
135+ return (
136+ < Badge className = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200" >
137+ Healthy
138+ </ Badge >
139+ )
132140 case 'warning' :
133- return < Badge className = "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200" > Warning</ Badge >
141+ return (
142+ < Badge className = "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200" >
143+ Warning
144+ </ Badge >
145+ )
134146 case 'critical' :
135- return < Badge className = "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200" > Critical</ Badge >
147+ return (
148+ < Badge className = "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200" >
149+ Critical
150+ </ Badge >
151+ )
136152 default :
137153 return < Badge variant = "secondary" > Unknown</ Badge >
138154 }
@@ -174,7 +190,9 @@ export default function AdminOrganizationsPage() {
174190 < CardTitle > Sign in Required</ CardTitle >
175191 </ CardHeader >
176192 < CardContent >
177- < p className = "mb-4" > Please sign in to access the admin dashboard.</ p >
193+ < p className = "mb-4" >
194+ Please sign in to access the admin dashboard.
195+ </ p >
178196 < Link href = "/login" >
179197 < Button > Sign In</ Button >
180198 </ Link >
@@ -232,7 +250,9 @@ export default function AdminOrganizationsPage() {
232250 < div className = "grid gap-6 md:grid-cols-4 mb-8" >
233251 < Card >
234252 < CardHeader className = "flex flex-row items-center justify-between space-y-0 pb-2" >
235- < CardTitle className = "text-sm font-medium" > Total Organizations</ CardTitle >
253+ < CardTitle className = "text-sm font-medium" >
254+ Total Organizations
255+ </ CardTitle >
236256 < Users className = "h-4 w-4 text-muted-foreground" />
237257 </ CardHeader >
238258 < CardContent >
@@ -247,7 +267,10 @@ export default function AdminOrganizationsPage() {
247267 </ CardHeader >
248268 < CardContent >
249269 < div className = "text-2xl font-bold text-green-600" >
250- { organizations . filter ( org => org . health_status === 'healthy' ) . length }
270+ {
271+ organizations . filter ( ( org ) => org . health_status === 'healthy' )
272+ . length
273+ }
251274 </ div >
252275 </ CardContent >
253276 </ Card >
@@ -259,7 +282,10 @@ export default function AdminOrganizationsPage() {
259282 </ CardHeader >
260283 < CardContent >
261284 < div className = "text-2xl font-bold text-yellow-600" >
262- { organizations . filter ( org => org . health_status === 'warning' ) . length }
285+ {
286+ organizations . filter ( ( org ) => org . health_status === 'warning' )
287+ . length
288+ }
263289 </ div >
264290 </ CardContent >
265291 </ Card >
@@ -271,7 +297,11 @@ export default function AdminOrganizationsPage() {
271297 </ CardHeader >
272298 < CardContent >
273299 < div className = "text-2xl font-bold text-red-600" >
274- { organizations . filter ( org => org . health_status === 'critical' ) . length }
300+ {
301+ organizations . filter (
302+ ( org ) => org . health_status === 'critical'
303+ ) . length
304+ }
275305 </ div >
276306 </ CardContent >
277307 </ Card >
@@ -291,7 +321,8 @@ export default function AdminOrganizationsPage() {
291321 { getHealthStatusBadge ( org . health_status ) }
292322 </ div >
293323 < p className = "text-sm text-muted-foreground" >
294- Owner: { org . owner_name } • Created: { new Date ( org . created_at ) . toLocaleDateString ( ) }
324+ Owner: { org . owner_name } • Created:{ ' ' }
325+ { new Date ( org . created_at ) . toLocaleDateString ( ) }
295326 </ p >
296327 < div className = "flex items-center space-x-4 mt-2 text-sm text-muted-foreground" >
297328 < span className = "flex items-center" >
@@ -310,7 +341,7 @@ export default function AdminOrganizationsPage() {
310341 </ div >
311342 </ div >
312343 < div className = "flex items-center space-x-2" >
313- < Link href = { `/orgs/${ org . id } ` } >
344+ < Link href = { `/orgs/${ org . slug } ` } >
314345 < Button variant = "outline" size = "sm" >
315346 < Eye className = "mr-2 h-4 w-4" />
316347 View
0 commit comments