Skip to content

Commit

Permalink
feat: usePostEvaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSlain committed Dec 3, 2024
1 parent 515f833 commit 0c9dea6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/api/usePostEvaluations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { evaluationsUrl } from '@api'
import { useMutation } from '@tanstack/react-query'

export function usePostEvaluations() {
return useMutation({
mutationKey: ['postEvaluations'],
mutationFn: (params) => postEvaluations(params),
})
}

function postEvaluations(params) {
const authToken = localStorage.getItem('authToken')

const data = {
question: params.question,
themes: params.themes,
operators: params.operators,
title: params.title,
rating: params.rating,
positiveFeedback: params.positiveFeedback,
negativeFeedback: params.negativeFeedback,
comments: params.comments,
}

return fetch(`${evaluationsUrl}/evaluations`, {
method: 'POST',
credentials: 'include',
headers: {
Authorization: `Bearer ${authToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
}

0 comments on commit 0c9dea6

Please sign in to comment.