import { useEffect, useState } from 'react'
import { getOrgs, type Org } from './api/client'

export default function App() {
  const [orgs, setOrgs] = useState<Org[]>([])
  const [error, setError] = useState<string | null>(null)

  useEffect(() => {
    getOrgs().then(setOrgs).catch((e: Error) => setError(e.message))
  }, [])

  return (
    <div className="p-8">
      <h1 className="text-xl font-semibold">ITN-HUB 사업관리시스템</h1>
      {error && <p className="mt-4 text-red-600">{error}</p>}
      <p className="mt-4 text-gray-600">기관 {orgs.length}개</p>
    </div>
  )
}
