2
0
Files
bot/apps/viewer/services/result.ts

32 lines
776 B
TypeScript
Raw Normal View History

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