Skip to content

Commit

Permalink
Handle case where there are no stored questions
Browse files Browse the repository at this point in the history
  • Loading branch information
martincai8 committed Nov 13, 2024
1 parent ba96410 commit d059490
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/questionCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ const QuestionCard = ({
}

const addOption = () => {
handleChange(id, 'options', [...question.options, ''])
const currentOptions = question.options || []
handleChange(id, 'options', [...currentOptions, ''])
}

const removeOption = index => {
Expand Down
4 changes: 3 additions & 1 deletion pages/hackerapps/[id]/basicinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default ({ id, hackathons }) => {
useEffect(() => {
const fetchQuestions = async () => {
const appQuestions = await getHackerAppQuestions(id, 'BasicInfo')
setQuestions(appQuestions)
if (appQuestions?.length > 0) {
setQuestions(appQuestions)
}
}
const fetchMetadata = async () => {
const fetchedMetadata = await getHackerAppQuestionsMetadata(id, 'BasicInfo')
Expand Down
4 changes: 3 additions & 1 deletion pages/hackerapps/[id]/questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default ({ id, hackathons }) => {
useEffect(() => {
const fetchQuestions = async () => {
const appQuestions = await getHackerAppQuestions(id, 'Questionnaire')
setQuestions(appQuestions)
if (appQuestions?.length > 0) {
setQuestions(appQuestions)
}
}
const fetchMetadata = async () => {
const fetchedMetadata = await getHackerAppQuestionsMetadata(id, 'Questionnaire')
Expand Down
4 changes: 3 additions & 1 deletion pages/hackerapps/[id]/skills.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default ({ id, hackathons }) => {
useEffect(() => {
const fetchQuestions = async () => {
const appQuestions = await getHackerAppQuestions(id, 'Skills')
setQuestions(appQuestions)
if (appQuestions?.length > 0) {
setQuestions(appQuestions)
}
}
const fetchMetadata = async () => {
const fetchedMetadata = await getHackerAppQuestionsMetadata(id, 'Skills')
Expand Down

0 comments on commit d059490

Please sign in to comment.