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

@ -1,4 +1,4 @@
import { Result } from 'db'
import { Log, Result } from 'db'
import { VariableWithValue } from 'models'
import { sendRequest } from 'utils'
@ -7,19 +7,25 @@ export const createResult = async (
prefilledVariables: VariableWithValue[]
) => {
return sendRequest<Result>({
url: `/api/results`,
url: `/api/typebots/${typebotId}/results`,
method: 'POST',
body: { typebotId, prefilledVariables },
body: { prefilledVariables },
})
}
export const updateResult = async (
resultId: string,
result: Partial<Result>
) => {
return sendRequest<Result>({
url: `/api/results/${resultId}`,
export const updateResult = async (resultId: string, result: Partial<Result>) =>
sendRequest<Result>({
url: `/api/typebots/t/results/${resultId}`,
method: 'PATCH',
body: result,
})
}
export const createLog = (
resultId: string,
log: Omit<Log, 'id' | 'createdAt' | 'resultId'>
) =>
sendRequest<Result>({
url: `/api/typebots/t/results/${resultId}/logs`,
method: 'POST',
body: log,
})