Files
jaengseung-made/app/gyeol/components/Q5Step.tsx
gahusb d622dafcce feat(gyeol): Q4Step (비용 라디오 6) + Q5Step (도구 라디오 8 + 만족도 1-5)
- Q4: 라디오 패턴 재사용 (Q2와 동일 스타일)
- Q5: 두 입력 한 화면 — 도구 라디오 + 만족도 1-5 버튼 그리드
- 둘 다 선택 시 다음 활성

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 05:27:56 +09:00

84 lines
2.9 KiB
TypeScript

'use client';
import { useState } from 'react';
import { BEST_TOOLS, SATISFY_SCALE } from '@/lib/survey/questions';
import type { SurveyResponse } from '@/lib/survey/types';
import QuestionLayout from './QuestionLayout';
interface Props {
initial: Partial<SurveyResponse>;
onPrev: () => void;
onNext: (partial: Partial<SurveyResponse>) => void;
}
export default function Q5Step({ initial, onPrev, onNext }: Props) {
const [tool, setTool] = useState(initial.best_tool ?? '');
const [satisfy, setSatisfy] = useState<number | null>(initial.best_satisfy ?? null);
const valid = tool && satisfy !== null;
return (
<QuestionLayout
step="q5"
onPrev={onPrev}
onNext={() => onNext({ best_tool: tool, best_satisfy: satisfy ?? undefined })}
nextDisabled={!valid}
>
<div className="space-y-6">
<div>
<p className="text-xs text-white/60 mb-2 font-mono tracking-widest uppercase"> </p>
<div className="space-y-2">
{BEST_TOOLS.map((option) => (
<label
key={option}
className={`flex items-center gap-3 px-4 py-3 rounded-xl border cursor-pointer transition ${
tool === option
? 'border-violet-400 bg-violet-400/10'
: 'border-white/15 bg-white/[0.02] hover:border-white/30'
}`}
>
<input
type="radio"
name="best_tool"
value={option}
checked={tool === option}
onChange={() => setTool(option)}
className="sr-only"
/>
<span
className={`w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${
tool === option ? 'border-violet-400' : 'border-white/30'
}`}
>
{tool === option && <span className="w-2 h-2 rounded-full bg-violet-400" />}
</span>
<span className="text-sm text-white">{option}</span>
</label>
))}
</div>
</div>
<div>
<p className="text-xs text-white/60 mb-2 font-mono tracking-widest uppercase"> (5 )</p>
<div className="flex gap-2">
{SATISFY_SCALE.map((n) => (
<button
key={n}
type="button"
onClick={() => setSatisfy(n)}
className={`flex-1 py-3 rounded-xl border text-sm font-bold transition ${
satisfy === n
? 'border-violet-400 bg-violet-400/10 text-white'
: 'border-white/15 bg-white/[0.02] text-white/60 hover:border-white/30'
}`}
>
{n}
</button>
))}
</div>
</div>
</div>
</QuestionLayout>
);
}