Skip to content

Commit

Permalink
remove warnings given by next build
Browse files Browse the repository at this point in the history
  • Loading branch information
visrut-at-incubyte committed Oct 25, 2023
1 parent d3c29c8 commit d129174
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/survey/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { useEffect } from 'react'
import { useCallback, useEffect } from 'react'
import AnswerForm from './components/AnswerForm'
import LoadingSpinner from '@/app/components/LoadingSpinner'
import { useAppContext } from '@/app/context/AppContext'
Expand All @@ -8,15 +8,14 @@ import { Answer } from '@/app/models/types'
export default function FillSurvey({ params }: { params: { id: string } }) {
const { setName, setQuestions, questions, name } = useAppContext()

const getSurvey = async () => {
const getSurvey = useCallback(async () => {
const res = await fetch(`/survey/${params.id}/api`)
const data = await res.json()
setName(data.surveyName)
setQuestions([...data.questions])
}
}, [params.id, setName, setQuestions])

const submitSurvey = async (answers: Answer[]) => {
console.log('submitting survey....')
const res = await fetch(`/survey/${params.id}/api`, {
method: 'POST',
headers: {
Expand All @@ -33,7 +32,7 @@ export default function FillSurvey({ params }: { params: { id: string } }) {

useEffect(() => {
getSurvey()
}, [])
}, [getSurvey])

if (questions.length === 0) return <LoadingSpinner />

Expand Down

0 comments on commit d129174

Please sign in to comment.