mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-08-01 10:51:29 -04:00
31 lines
782 B
TypeScript
31 lines
782 B
TypeScript
import {User} from 'common/user'
|
|
import {useEffect} from 'react'
|
|
import {usePersistentInMemoryState} from 'web/hooks/use-persistent-in-memory-state'
|
|
import {getOtherAnswers} from 'web/lib/supabase/answers'
|
|
|
|
export type OtherAnswersType = {
|
|
question_id: number
|
|
created_time: number
|
|
free_response: string
|
|
multiple_choice: number
|
|
integer: number
|
|
age: number
|
|
gender: string
|
|
city: string
|
|
data: User
|
|
}
|
|
|
|
export const useOtherAnswers = (question_id: number) => {
|
|
const [otherAnswers, setOtherAnswers] = usePersistentInMemoryState<
|
|
OtherAnswersType[] | null | undefined
|
|
>(undefined, 'other_answer_' + question_id)
|
|
|
|
useEffect(() => {
|
|
getOtherAnswers(question_id).then((data) => {
|
|
setOtherAnswers(data)
|
|
})
|
|
}, [question_id])
|
|
|
|
return otherAnswers
|
|
}
|