Files
metabuilder/frontends/nextjs/src/hooks/useGitHubFetcher.ts
copilot-swe-agent[bot] af2a59ee6a fix: Resolve TypeScript errors and dependency issues
- Fixed Storybook dependency version mismatch (downgraded to 8.6.15)
- Added @types/better-sqlite3 for better-sqlite3 type definitions
- Fixed Prisma adapter import (PrismaBetterSqlite3 vs PrismaBetterSQLite3)
- Removed datasource URL from Prisma schema (Prisma 7 requirement)
- Generated DBAL types.generated.ts from Prisma schema
- Added index signatures to Update*Input types for Record<string, unknown> compatibility
- Fixed ErrorBoundary override modifiers
- Fixed Zod record schema (requires both key and value types)
- Fixed orderBy syntax in get-error-logs (array format)
- Fixed type safety in API routes (user type assertions)
- Fixed hook imports and exports
- Fixed conditional expression type guards
- Added .npmrc for legacy peer deps support

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2026-01-08 01:26:50 +00:00

46 lines
1000 B
TypeScript

/**
* useGitHubFetcher hook
*/
import { useState, useEffect, useCallback } from 'react'
export interface WorkflowRun {
id: number
name: string
status: string
conclusion?: string
createdAt: string
}
export function useGitHubFetcher() {
const [runs, setRuns] = useState<WorkflowRun[]>([])
const [loading, setLoading] = useState(false)
const [error, setError] = useState<Error | null>(null)
const refetch = useCallback(async () => {
setLoading(true)
setError(null)
try {
const { listWorkflowRuns } = await import('@/lib/github/workflows/listing/list-workflow-runs')
// TODO: Get owner/repo from environment or context
const workflowRuns = await listWorkflowRuns({ owner: 'owner', repo: 'repo' })
setRuns(workflowRuns)
} catch (err) {
setError(err as Error)
} finally {
setLoading(false)
}
}, [])
useEffect(() => {
void refetch()
}, [refetch])
return {
runs,
loading,
error,
refetch,
}
}