2
0

feat(results): Add logs in results

This commit is contained in:
Baptiste Arnaud
2022-03-01 11:40:22 +01:00
parent 4630512b8b
commit ebf92b5536
27 changed files with 408 additions and 120 deletions

View File

@ -0,0 +1,15 @@
import { Log } from 'db'
import { fetcher } from 'services/utils'
import useSWR from 'swr'
export const useLogs = (resultId?: string, onError?: (e: Error) => void) => {
const { data, error } = useSWR<{ logs: Log[] }>(
resultId ? `/api/typebots/t/results/${resultId}/logs` : null,
fetcher
)
if (error && onError) onError(error)
return {
logs: data?.logs,
isLoading: !error && !data,
}
}