mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
- 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>
46 lines
1000 B
TypeScript
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,
|
|
}
|
|
}
|