@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"
44import { Button } from "@/components/ui/button"
55import { Undo2 } from "lucide-react"
66
7- import type { DataQuestionSource , FileOutputConfig , InstructionsWizardProps , Responses , WizardAnswer , WizardConfirmationIntent , WizardQuestion , WizardStep } from "@/types/wizard"
7+ import type { DataQuestionSource , InstructionsWizardProps , Responses , WizardAnswer , WizardConfirmationIntent , WizardQuestion , WizardStep } from "@/types/wizard"
88import { buildFilterPlaceholder , useAnswerFilter } from "@/hooks/use-answer-filter"
99import stacksData from "@/data/stacks.json"
1010import generalData from "@/data/general.json"
@@ -189,7 +189,7 @@ export function InstructionsWizard({ onClose, selectedFileId, initialStackId }:
189189 responses ,
190190 autoFilledQuestionMap
191191 ) ,
192- [ fileSummaryQuestion , selectedFile , selectedFileFormatLabel , wizardSteps , responses , autoFilledQuestionMap ]
192+ [ selectedFile , selectedFileFormatLabel , wizardSteps , responses , autoFilledQuestionMap ]
193193 )
194194
195195 const currentAnswerValue = currentQuestion ? responses [ currentQuestion . id ] : undefined
@@ -258,20 +258,18 @@ export function InstructionsWizard({ onClose, selectedFileId, initialStackId }:
258258 setActiveEditQuestionId ( null )
259259 } , [ ] )
260260
261- if ( ! currentStep || ! currentQuestion ) {
262- return null
263- }
264-
265261 const isAnswerSelected = ( value : string ) => {
266- if ( currentQuestion . allowMultiple ) {
262+ if ( currentQuestion ? .allowMultiple ) {
267263 return Array . isArray ( currentAnswerValue ) && currentAnswerValue . includes ( value )
268264 }
269265
270266 return currentAnswerValue === value
271267 }
272268
273269 const advanceToNextQuestion = ( ) => {
274- const isLastQuestionInStep = currentQuestionIndex === currentStep . questions . length - 1
270+ const currentStepForAdvance = wizardSteps [ currentStepIndex ]
271+ const isLastQuestionInStep =
272+ currentStepForAdvance ? currentQuestionIndex === currentStepForAdvance . questions . length - 1 : false
275273 const isLastStep = currentStepIndex === wizardSteps . length - 1
276274
277275 if ( isLastQuestionInStep && isLastStep ) {
@@ -390,6 +388,10 @@ export function InstructionsWizard({ onClose, selectedFileId, initialStackId }:
390388 void loadStackQuestions ( stackAnswer . value , stackAnswer . label )
391389 } , [ initialStackId , loadStackQuestions ] )
392390
391+ if ( ! currentStep || ! currentQuestion ) {
392+ return null
393+ }
394+
393395 const applyDefaultsAcrossWizard = ( ) => {
394396 setGeneratedFile ( null )
395397 setAutoFilledQuestionMap ( { } )
@@ -807,7 +809,7 @@ export function InstructionsWizard({ onClose, selectedFileId, initialStackId }:
807809
808810 { showNoFilterMatches ? (
809811 < p className = "mt-6 rounded-xl border border-border/70 bg-muted/30 px-4 py-6 text-sm text-muted-foreground" >
810- No options match " { answerFilterQuery } " . Try a different search.
812+ No options match “ { answerFilterQuery } ” . Try a different search.
811813 </ p >
812814 ) : (
813815 < WizardAnswerGrid
0 commit comments