diff --git a/src/components/cost-estimator/cost-estimator-form.tsx b/src/components/cost-estimator/cost-estimator-form.tsx index c34c1b4..8e4cb82 100644 --- a/src/components/cost-estimator/cost-estimator-form.tsx +++ b/src/components/cost-estimator/cost-estimator-form.tsx @@ -3,12 +3,14 @@ import React, { useState, useTransition } from 'react'; import { Step1ProjectType } from './step-1-project-type'; import { Step2ServiceType } from './step-2-service-type'; +import { Step3ProjectStage } from './step-3-project-stage'; import { Card, CardContent } from '@/components/ui/card'; import { AnimatePresence, motion } from 'framer-motion'; export type FormData = { projectType: 'website' | 'mobile-app' | 'platform' | null; serviceType: 'entire-project' | 'development' | 'ui-ux-design' | 'identity-branding' | null; + projectStage: number; }; export function CostEstimatorForm() { @@ -16,6 +18,7 @@ export function CostEstimatorForm() { const [formData, setFormData] = useState({ projectType: null, serviceType: null, + projectStage: 0, }); const [isPending, startTransition] = useTransition(); @@ -25,6 +28,12 @@ export function CostEstimatorForm() { }); }; + const handlePrevStep = () => { + startTransition(() => { + setCurrentStep((prev) => prev - 1); + }); + }; + const handleUpdateFormData = (newData: Partial) => { setFormData((prev) => ({ ...prev, ...newData })); }; @@ -42,7 +51,18 @@ export function CostEstimatorForm() { return ( + ); + case 3: + return ( + ); default: diff --git a/src/components/cost-estimator/step-2-service-type.tsx b/src/components/cost-estimator/step-2-service-type.tsx index 2f1c44a..22e585a 100644 --- a/src/components/cost-estimator/step-2-service-type.tsx +++ b/src/components/cost-estimator/step-2-service-type.tsx @@ -6,7 +6,9 @@ import React from 'react'; type Step2Props = { onNext: () => void; + onBack: () => void; onUpdateData: (data: Partial) => void; + formData: FormData; }; const serviceTypes = [ @@ -28,8 +30,8 @@ const serviceTypes = [ }, ]; -export function Step2ServiceType({ onNext, onUpdateData }: Step2Props) { - const [selectedService, setSelectedService] = React.useState(null); +export function Step2ServiceType({ onNext, onBack, onUpdateData, formData }: Step2Props) { + const [selectedService, setSelectedService] = React.useState(formData.serviceType); const handleSelect = (serviceId: 'entire-project' | 'development' | 'ui-ux-design' | 'identity-branding') => { setSelectedService(serviceId); @@ -39,7 +41,7 @@ export function Step2ServiceType({ onNext, onUpdateData }: Step2Props) { return (

Choose Service

-
+
{serviceTypes.map((type) => (
+
diff --git a/src/components/cost-estimator/step-3-project-stage.tsx b/src/components/cost-estimator/step-3-project-stage.tsx new file mode 100644 index 0000000..57bbde5 --- /dev/null +++ b/src/components/cost-estimator/step-3-project-stage.tsx @@ -0,0 +1,75 @@ +"use client"; + +import type { FormData } from './cost-estimator-form'; +import { Button } from '@/components/ui/button'; +import { Slider } from '@/components/ui/slider'; +import React, { useState, useMemo } from 'react'; + +type Step3Props = { + onNext: () => void; + onBack: () => void; + onUpdateData: (data: Partial) => void; + formData: FormData; +}; + +const stageLabels = [ + "From scratch", // 0 + "Idea & concept", // 10 + "Prototype ready", // 20 + "Design ready", // 30 + "In development", // 40 + "MVP ready", // 50 + "Live product", // 60 + "Re-design", // 70 + "Adding features", // 80 + "Ongoing support", // 90 +]; + +export function Step3ProjectStage({ onNext, onBack, onUpdateData, formData }: Step3Props) { + const [value, setValue] = useState([formData.projectStage]); + + const handleSliderChange = (newValue: number[]) => { + setValue(newValue); + onUpdateData({ projectStage: newValue[0] }); + }; + + const currentLabel = useMemo(() => { + const index = Math.floor(value[0] / 10); + return stageLabels[index]; + }, [value]); + + return ( +
+

Choose the stage of your project or let's start from scratch

+
+
+

{currentLabel}

+

{value[0] === 90 ? "90+%" : `${value[0]}%`}

+
+ +
+ 0% + 90+% +
+
+
+ +
+
+
+
+
+
+ +
+
+ ); +}