Skip to content

Commit

Permalink
feat: useGetOrganization
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSlain committed Dec 3, 2024
1 parent 7b7acf0 commit 00edcf4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './useAddFeedback'
export * from './useGetChunk'
export * from './useGetChatArchiveById'
export * from './useGetInstitutions'
export * from './useGetEvaluationQuestions'
1 change: 1 addition & 0 deletions src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export const getSheetsUrl = `${apiBase}/get_sheets`
export const getChunksUrl = `${apiBase}/get_chunks`
export const getChunkUrl = `${apiBase}/get_chunk`
export const mfsOrganizationsUrl = `${apiBase}/organizations/mfs`
export const evaluationsUrl = `${apiBase}/evaluations`
30 changes: 30 additions & 0 deletions src/api/useGetEvaluationQuestions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { evaluationsUrl } from '@api'
import { useQuery } from '@tanstack/react-query'

export function useGetEvaluationQuestions() {
return useQuery({
queryKey: ['getEvaluationQuestions'],
queryFn: () => fetchEvaluations(),
enabled: true,
})
}

const fetchEvaluations = async (): Promise<string[]> => {
const authToken = localStorage.getItem('authToken')

const res = await fetch(`${evaluationsUrl}`, {
method: 'GET',
credentials: 'include',
headers: {
Authorization: `Bearer ${authToken}`,
'Content-Type': 'application/json',
},
})

if (!res.ok) {
console.error('error: response not ok', res)
throw new Error('Impossible de récupérer les archives', { cause: res })
}
const institutions = await res.json()
return institutions as string[]
}
1 change: 1 addition & 0 deletions src/pages/Evaluations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default function Evaluations() {
}

function Questions({ setSelectedCardIndex }) {
// const questionList =
return (
<div className="grid grid-cols-2 gap-4">
{questions.map((question, index) => (
Expand Down

0 comments on commit 00edcf4

Please sign in to comment.