diff --git a/apps/builder/layouts/results/LogsModal.tsx b/apps/builder/layouts/results/LogsModal.tsx index 5e6fa123b1..0b40f38120 100644 --- a/apps/builder/layouts/results/LogsModal.tsx +++ b/apps/builder/layouts/results/LogsModal.tsx @@ -21,14 +21,13 @@ import { Log } from 'db' import { useLogs } from 'services/typebots/logs' import { isDefined } from 'utils' -export const LogsModal = ({ - resultId, - onClose, -}: { +type Props = { + typebotId: string resultId?: string onClose: () => void -}) => { - const { isLoading, logs } = useLogs(resultId) +} +export const LogsModal = ({ typebotId, resultId, onClose }: Props) => { + const { isLoading, logs } = useLogs(typebotId, resultId) return ( diff --git a/apps/builder/layouts/results/SubmissionContent.tsx b/apps/builder/layouts/results/SubmissionContent.tsx index 2e56a960fa..ae31b69ef2 100644 --- a/apps/builder/layouts/results/SubmissionContent.tsx +++ b/apps/builder/layouts/results/SubmissionContent.tsx @@ -152,10 +152,13 @@ export const SubmissionsContent = ({ contentLabel="You are seeing complete submissions only." /> )} - + {publishedTypebot && ( + + )} { const typebotId = req.query.typebotId as string const resultId = req.query.resultId as string const logs = await prisma.log.findMany({ - where: { resultId, result: { typebot: canReadTypebot(typebotId, user) } }, + where: { + result: { id: resultId, typebot: canReadTypebot(typebotId, user) }, + }, }) return res.send({ logs }) } diff --git a/apps/builder/services/typebots/logs.ts b/apps/builder/services/typebots/logs.ts index 44ab5cd553..5b0d8af0d2 100644 --- a/apps/builder/services/typebots/logs.ts +++ b/apps/builder/services/typebots/logs.ts @@ -2,9 +2,13 @@ import { Log } from 'db' import { fetcher } from 'services/utils' import useSWR from 'swr' -export const useLogs = (resultId?: string, onError?: (e: Error) => void) => { +export const useLogs = ( + typebotId: string, + resultId?: string, + onError?: (e: Error) => void +) => { const { data, error } = useSWR<{ logs: Log[] }>( - resultId ? `/api/typebots/t/results/${resultId}/logs` : null, + resultId ? `/api/typebots/${typebotId}/results/${resultId}/logs` : null, fetcher ) if (error && onError) onError(error)