|
| 1 | +import { useState } from 'react'; |
| 2 | +import Navigation from '../../components/Navigation'; |
| 3 | +import FormButton from '../../components/onboarding/FormButton'; |
| 4 | +import { useNavigate } from 'react-router-dom'; |
| 5 | +import TextInput from '../../components/onboarding/TextInput'; |
| 6 | +import PriceInput from '../../components/onboarding/PriceInput'; |
| 7 | +import SingleSelect from '../../components/onboarding/SingleSelect'; |
| 8 | +import MultiSelect from '../../components/onboarding/MultiSelect'; |
| 9 | + |
1 | 10 | const Onboarding = () => { |
2 | | - return <div>Onboarding</div>; |
| 11 | + const navigate = useNavigate(); |
| 12 | + const [currentStep, setCurrentStep] = useState(1); |
| 13 | + const totalSteps = 5; |
| 14 | + |
| 15 | + const handlePrev = () => { |
| 16 | + if (currentStep > 1) { |
| 17 | + setCurrentStep(currentStep - 1); |
| 18 | + } |
| 19 | + }; |
| 20 | + |
| 21 | + const handleNext = () => { |
| 22 | + if (currentStep < totalSteps) { |
| 23 | + setCurrentStep(currentStep + 1); |
| 24 | + } |
| 25 | + }; |
| 26 | + |
| 27 | + const handleComplete = () => { |
| 28 | + navigate('/chat'); |
| 29 | + }; |
| 30 | + |
| 31 | + const renderStepContent = () => { |
| 32 | + switch (currentStep) { |
| 33 | + case 1: |
| 34 | + return <SingleSelect key="step1" title="업종을" />; |
| 35 | + case 2: |
| 36 | + return <TextInput key="step2" title="업체명을" placeholder="" />; |
| 37 | + case 3: |
| 38 | + return <TextInput key="step3" title="위치(시군구)를" placeholder="" />; |
| 39 | + case 4: |
| 40 | + return <PriceInput key="step4" title="평균 월매출" placeholder="숫자" />; |
| 41 | + case 5: |
| 42 | + return <PriceInput key="step5" title="목표 월매출" placeholder="숫자" />; |
| 43 | + default: |
| 44 | + return <MultiSelect key="default" title="원하는 타겟층" />; |
| 45 | + } |
| 46 | + }; |
| 47 | + |
| 48 | + return ( |
| 49 | + <div className="flex h-full flex-col"> |
| 50 | + <Navigation /> |
| 51 | + <div className="flex flex-1 flex-col p-5"> |
| 52 | + <div className="mb-6"> |
| 53 | + <div className="mb-2 flex justify-between text-sm text-gray-600"> |
| 54 | + <span>단계 {currentStep}</span> |
| 55 | + <span> |
| 56 | + {currentStep} / {totalSteps} |
| 57 | + </span> |
| 58 | + </div> |
| 59 | + <div className="h-2 w-full rounded-full bg-gray-200"> |
| 60 | + <div |
| 61 | + className="h-2 rounded-full bg-blue-500 transition-all duration-300" |
| 62 | + style={{ width: `${(currentStep / totalSteps) * 100}%` }} |
| 63 | + /> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + |
| 67 | + <div className="flex-1 overflow-y-auto">{renderStepContent()}</div> |
| 68 | + |
| 69 | + <div className="mt-6 flex gap-3"> |
| 70 | + {currentStep > 1 && <FormButton type="prev" onClick={handlePrev} />} |
| 71 | + {currentStep === totalSteps ? ( |
| 72 | + <FormButton type="submit" onClick={handleComplete} /> |
| 73 | + ) : ( |
| 74 | + <FormButton type="next" onClick={handleNext} /> |
| 75 | + )} |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + ); |
3 | 80 | }; |
4 | 81 |
|
5 | 82 | export default Onboarding; |
0 commit comments