2
0

⚗️ Add delete results logic

This commit is contained in:
Baptiste Arnaud
2022-01-04 09:15:33 +01:00
parent 6db34a8d4f
commit 8ddf608c9e
6 changed files with 218 additions and 22 deletions

View File

@ -1,6 +1,6 @@
import { Result } from 'bot-engine'
import useSWR from 'swr'
import { fetcher } from './utils'
import { fetcher, sendRequest } from './utils'
import { stringify } from 'qs'
import { Answer } from 'db'
@ -28,6 +28,19 @@ export const useResults = ({
}
}
export const deleteResults = async (typebotId: string, ids: string[]) => {
const params = stringify(
{
ids,
},
{ indices: false }
)
return sendRequest({
url: `/api/typebots/${typebotId}/results?${params}`,
method: 'DELETE',
})
}
export const parseDateToReadable = (dateStr: string): string => {
const date = new Date(dateStr)
return (