Skip to content

Commit de3fde3

Browse files
committed
refactor: streamline free text response handling across components
1 parent 32d190c commit de3fde3

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

app/new/stack/stack-summary-page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,10 @@ export function StackSummaryPage({ stackId, mode }: StackSummaryPageProps) {
435435
return null
436436
}
437437
const currentValue = responses ? responses[editingQuestion.id] : undefined
438-
const currentFreeText = typeof freeTextResponses[editingQuestion.id] === "string"
439-
? freeTextResponses[editingQuestion.id]
440-
: ""
438+
const storedFreeTextValue = freeTextResponses[editingQuestion.id]
439+
const currentFreeText = typeof storedFreeTextValue === "string"
440+
? storedFreeTextValue
441+
: undefined
441442
return (
442443
<WizardEditAnswerDialog
443444
question={editingQuestion}

components/instructions-wizard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ export function InstructionsWizard({
883883
>
884884
<CheckCircle2 className="h-3.5 w-3.5" />
885885
<span>
886-
We'll use
886+
We&apos;ll use
887887
{" "}
888888
<code className="rounded bg-muted px-1.5 py-0.5 text-[0.7rem] font-medium">
889889
{savedCustomFreeTextValue}

components/wizard-edit-answer-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function WizardEditAnswerDialog({
157157
>
158158
<CheckCircle2 className="h-3.5 w-3.5" />
159159
<span>
160-
We'll use
160+
We&apos;ll use
161161
{" "}
162162
<code className="rounded bg-muted px-1.5 py-0.5 text-[0.7rem] font-medium">
163163
{persistedCustomAnswer}

lib/wizard-response.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ export const serializeWizardResponses = (
4949

5050
const answer = responses[question.id]
5151
const targetKey = responseKey as keyof WizardResponses
52-
const freeTextValue = typeof freeTextResponses[question.id] === "string"
53-
? freeTextResponses[question.id]?.trim()
52+
const rawFreeTextValue = freeTextResponses[question.id]
53+
const freeTextValue = typeof rawFreeTextValue === "string"
54+
? rawFreeTextValue.trim()
5455
: ""
5556
const entries: string[] = []
5657

lib/wizard-summary.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ export const buildCompletionSummary = (
7878
return value === answer.value
7979
})
8080

81-
const freeTextValue = typeof freeTextResponses[question.id] === "string"
82-
? freeTextResponses[question.id]?.trim()
81+
const storedFreeTextValue = freeTextResponses[question.id]
82+
const freeTextValue = typeof storedFreeTextValue === "string"
83+
? storedFreeTextValue.trim()
8384
: ""
8485
const customAnswer = freeTextValue.length > 0 ? `Custom: ${freeTextValue}` : null
8586
const answerSummaries = customAnswer

0 commit comments

Comments
 (0)