2025-07-17 10:51:28 +00:00
|
|
|
|
2025-07-17 10:06:15 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2025-07-17 10:33:28 +00:00
|
|
|
import React, { useState, useTransition, useMemo } from 'react';
|
2025-07-17 10:06:15 +00:00
|
|
|
import { Step1ProjectType } from './step-1-project-type';
|
2025-07-17 10:08:17 +00:00
|
|
|
import { Step2ServiceType } from './step-2-service-type';
|
2025-07-17 10:09:34 +00:00
|
|
|
import { Step3ProjectStage } from './step-3-project-stage';
|
2025-07-17 10:15:39 +00:00
|
|
|
import { Step4DesignProcess } from './step-4-design-process';
|
2025-07-17 10:18:40 +00:00
|
|
|
import { Step5PageCount } from './step-5-page-count';
|
2025-07-17 10:21:29 +00:00
|
|
|
import { Step6Animations } from './step-6-animations';
|
2025-07-17 10:25:08 +00:00
|
|
|
import { Step7Illustrations } from './step-7-illustrations';
|
2025-07-17 10:31:26 +00:00
|
|
|
import { Step8Branding } from './step-8-branding';
|
2025-07-17 10:45:05 +00:00
|
|
|
import { Step9AdditionalFeatures } from './step-9-additional-features';
|
2025-07-17 10:51:28 +00:00
|
|
|
import { Step10ShoppingCart } from './step-10-shopping-cart';
|
|
|
|
|
import { Step11Results, calculateTotalHours } from './step-11-results';
|
2025-07-17 11:04:26 +00:00
|
|
|
import { Step12UiUxDesign } from './step-12-uiux-design';
|
2025-07-17 10:06:15 +00:00
|
|
|
import { Card, CardContent } from '@/components/ui/card';
|
|
|
|
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
|
|
|
|
2025-07-17 10:25:08 +00:00
|
|
|
export type IllustrationSelection = {
|
|
|
|
|
has2d: boolean;
|
|
|
|
|
is2dAnimated: 'static' | 'animated' | null;
|
|
|
|
|
has3d: boolean;
|
|
|
|
|
is3dAnimated: 'static' | 'animated' | null;
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-17 10:31:26 +00:00
|
|
|
export type BrandingSelection = 'full-cycle' | 'brush-up' | 'logo-only' | 'none' | null;
|
|
|
|
|
|
2025-07-17 10:52:57 +00:00
|
|
|
export type ShoppingCartSelection = {
|
|
|
|
|
hasCart: boolean | null;
|
|
|
|
|
multiplePurchases: boolean | null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-17 10:06:15 +00:00
|
|
|
export type FormData = {
|
|
|
|
|
projectType: 'website' | 'mobile-app' | 'platform' | null;
|
2025-07-17 10:08:17 +00:00
|
|
|
serviceType: 'entire-project' | 'development' | 'ui-ux-design' | 'identity-branding' | null;
|
2025-07-17 10:09:34 +00:00
|
|
|
projectStage: number;
|
2025-07-17 10:15:39 +00:00
|
|
|
designProcess: 'custom' | 'mockups' | 'existing' | null;
|
2025-07-17 10:18:40 +00:00
|
|
|
pageCount: number;
|
2025-07-17 10:21:29 +00:00
|
|
|
animatedElements: boolean | null;
|
2025-07-17 10:25:08 +00:00
|
|
|
illustrations: IllustrationSelection;
|
2025-07-17 10:31:26 +00:00
|
|
|
branding: BrandingSelection;
|
2025-07-17 10:45:05 +00:00
|
|
|
additionalFeatures: string[];
|
2025-07-17 10:52:57 +00:00
|
|
|
shoppingCart: ShoppingCartSelection;
|
2025-07-17 11:04:26 +00:00
|
|
|
uiUxDesignProcess: 'custom' | 'concepts' | null;
|
2025-07-17 10:06:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function CostEstimatorForm() {
|
|
|
|
|
const [currentStep, setCurrentStep] = useState(1);
|
|
|
|
|
const [formData, setFormData] = useState<FormData>({
|
|
|
|
|
projectType: null,
|
2025-07-17 10:08:17 +00:00
|
|
|
serviceType: null,
|
2025-07-17 10:09:34 +00:00
|
|
|
projectStage: 0,
|
2025-07-17 10:15:39 +00:00
|
|
|
designProcess: null,
|
2025-07-17 10:18:40 +00:00
|
|
|
pageCount: 0,
|
2025-07-17 10:21:29 +00:00
|
|
|
animatedElements: null,
|
2025-07-17 10:25:08 +00:00
|
|
|
illustrations: {
|
|
|
|
|
has2d: false,
|
|
|
|
|
is2dAnimated: null,
|
|
|
|
|
has3d: false,
|
|
|
|
|
is3dAnimated: null,
|
|
|
|
|
},
|
2025-07-17 10:31:26 +00:00
|
|
|
branding: null,
|
2025-07-17 10:45:05 +00:00
|
|
|
additionalFeatures: [],
|
2025-07-17 10:52:57 +00:00
|
|
|
shoppingCart: {
|
|
|
|
|
hasCart: null,
|
|
|
|
|
multiplePurchases: null,
|
|
|
|
|
},
|
2025-07-17 11:04:26 +00:00
|
|
|
uiUxDesignProcess: null,
|
2025-07-17 10:06:15 +00:00
|
|
|
});
|
|
|
|
|
const [isPending, startTransition] = useTransition();
|
|
|
|
|
|
|
|
|
|
const handleNextStep = () => {
|
|
|
|
|
startTransition(() => {
|
2025-07-17 11:05:18 +00:00
|
|
|
// Logic for step 2 (Service Type)
|
|
|
|
|
if (currentStep === 2) {
|
|
|
|
|
if (formData.serviceType === 'development') setCurrentStep(5);
|
|
|
|
|
else if (formData.serviceType === 'ui-ux-design') setCurrentStep(12);
|
|
|
|
|
else if (formData.serviceType === 'identity-branding') setCurrentStep(8);
|
|
|
|
|
else setCurrentStep(3);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After page count, if service is development, skip to features
|
|
|
|
|
if (currentStep === 5 && formData.serviceType === 'development') {
|
2025-07-17 11:01:19 +00:00
|
|
|
setCurrentStep(9);
|
2025-07-17 11:05:18 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After branding, if service is identity-branding, skip to results
|
|
|
|
|
if (currentStep === 8 && formData.serviceType === 'identity-branding') {
|
2025-07-17 11:04:26 +00:00
|
|
|
setCurrentStep(11);
|
2025-07-17 11:05:18 +00:00
|
|
|
return;
|
2025-07-17 11:00:08 +00:00
|
|
|
}
|
2025-07-17 11:05:18 +00:00
|
|
|
|
|
|
|
|
// After UI/UX design step, go to page count
|
|
|
|
|
if (currentStep === 12) {
|
|
|
|
|
setCurrentStep(5);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setCurrentStep((prev) => prev + 1);
|
2025-07-17 10:06:15 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-17 10:09:34 +00:00
|
|
|
const handlePrevStep = () => {
|
|
|
|
|
startTransition(() => {
|
2025-07-17 11:00:08 +00:00
|
|
|
if (currentStep === 5 && formData.serviceType === 'development') {
|
|
|
|
|
setCurrentStep(2);
|
2025-07-17 11:05:18 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (currentStep === 9 && formData.serviceType === 'development') {
|
2025-07-17 11:01:19 +00:00
|
|
|
setCurrentStep(5);
|
2025-07-17 11:05:18 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (currentStep === 12) {
|
2025-07-17 11:04:26 +00:00
|
|
|
setCurrentStep(2);
|
2025-07-17 11:05:18 +00:00
|
|
|
return;
|
2025-07-17 11:04:26 +00:00
|
|
|
}
|
2025-07-17 11:05:18 +00:00
|
|
|
if (currentStep === 5 && formData.serviceType === 'ui-ux-design') {
|
|
|
|
|
setCurrentStep(12);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(currentStep === 8 && formData.serviceType === 'identity-branding') {
|
|
|
|
|
setCurrentStep(2);
|
|
|
|
|
return;
|
2025-07-17 11:00:08 +00:00
|
|
|
}
|
2025-07-17 11:05:18 +00:00
|
|
|
|
|
|
|
|
setCurrentStep((prev) => prev - 1);
|
2025-07-17 10:09:34 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-17 10:06:15 +00:00
|
|
|
const handleUpdateFormData = (newData: Partial<FormData>) => {
|
|
|
|
|
setFormData((prev) => ({ ...prev, ...newData }));
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-17 10:33:28 +00:00
|
|
|
const handleReset = () => {
|
|
|
|
|
setFormData({
|
|
|
|
|
projectType: null,
|
|
|
|
|
serviceType: null,
|
|
|
|
|
projectStage: 0,
|
|
|
|
|
designProcess: null,
|
|
|
|
|
pageCount: 0,
|
|
|
|
|
animatedElements: null,
|
|
|
|
|
illustrations: {
|
|
|
|
|
has2d: false,
|
|
|
|
|
is2dAnimated: null,
|
|
|
|
|
has3d: false,
|
|
|
|
|
is3dAnimated: null,
|
|
|
|
|
},
|
|
|
|
|
branding: null,
|
2025-07-17 10:45:05 +00:00
|
|
|
additionalFeatures: [],
|
2025-07-17 10:52:57 +00:00
|
|
|
shoppingCart: {
|
|
|
|
|
hasCart: null,
|
|
|
|
|
multiplePurchases: null
|
|
|
|
|
},
|
2025-07-17 11:04:26 +00:00
|
|
|
uiUxDesignProcess: null,
|
2025-07-17 10:33:28 +00:00
|
|
|
});
|
|
|
|
|
setCurrentStep(1);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-17 10:57:28 +00:00
|
|
|
const { customHours, readyMadeHours } = useMemo(() => calculateTotalHours(formData), [formData]);
|
2025-07-17 10:33:28 +00:00
|
|
|
|
2025-07-17 10:06:15 +00:00
|
|
|
const renderStep = () => {
|
|
|
|
|
switch (currentStep) {
|
|
|
|
|
case 1:
|
|
|
|
|
return (
|
|
|
|
|
<Step1ProjectType
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
case 2:
|
|
|
|
|
return (
|
2025-07-17 10:08:17 +00:00
|
|
|
<Step2ServiceType
|
|
|
|
|
onNext={handleNextStep}
|
2025-07-17 10:09:34 +00:00
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
case 3:
|
|
|
|
|
return (
|
|
|
|
|
<Step3ProjectStage
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
2025-07-17 10:08:17 +00:00
|
|
|
onUpdateData={handleUpdateFormData}
|
2025-07-17 10:09:34 +00:00
|
|
|
formData={formData}
|
2025-07-17 10:08:17 +00:00
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:15:39 +00:00
|
|
|
case 4:
|
|
|
|
|
return (
|
|
|
|
|
<Step4DesignProcess
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:18:40 +00:00
|
|
|
case 5:
|
|
|
|
|
return (
|
|
|
|
|
<Step5PageCount
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:21:29 +00:00
|
|
|
case 6:
|
|
|
|
|
return (
|
|
|
|
|
<Step6Animations
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:25:08 +00:00
|
|
|
case 7:
|
|
|
|
|
return (
|
|
|
|
|
<Step7Illustrations
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:31:26 +00:00
|
|
|
case 8:
|
|
|
|
|
return (
|
|
|
|
|
<Step8Branding
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:33:28 +00:00
|
|
|
case 9:
|
|
|
|
|
return (
|
2025-07-17 10:45:05 +00:00
|
|
|
<Step9AdditionalFeatures
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
case 10:
|
|
|
|
|
return (
|
2025-07-17 10:51:28 +00:00
|
|
|
<Step10ShoppingCart
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
case 11:
|
|
|
|
|
return (
|
|
|
|
|
<Step11Results
|
2025-07-17 10:33:28 +00:00
|
|
|
onReset={handleReset}
|
2025-07-17 10:57:28 +00:00
|
|
|
customHours={customHours}
|
|
|
|
|
readyMadeHours={readyMadeHours}
|
2025-07-17 10:33:28 +00:00
|
|
|
/>
|
|
|
|
|
)
|
2025-07-17 11:04:26 +00:00
|
|
|
case 12:
|
|
|
|
|
return (
|
|
|
|
|
<Step12UiUxDesign
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onBack={handlePrevStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
formData={formData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-07-17 10:06:15 +00:00
|
|
|
default:
|
|
|
|
|
return (
|
|
|
|
|
<Step1ProjectType
|
|
|
|
|
onNext={handleNextStep}
|
|
|
|
|
onUpdateData={handleUpdateFormData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-17 10:57:28 +00:00
|
|
|
const isResultsStep = currentStep === 11;
|
|
|
|
|
|
2025-07-17 10:06:15 +00:00
|
|
|
return (
|
2025-07-17 10:57:28 +00:00
|
|
|
<Card className={`mt-8 w-full max-w-4xl shadow-2xl overflow-hidden ${isResultsStep ? 'bg-transparent border-none' : ''}`}>
|
|
|
|
|
<CardContent className={`p-4 sm:p-8 ${isResultsStep ? 'p-0 sm:p-0' : ''}`}>
|
2025-07-17 10:06:15 +00:00
|
|
|
<AnimatePresence mode="wait">
|
|
|
|
|
<motion.div
|
|
|
|
|
key={currentStep}
|
|
|
|
|
initial={{ opacity: 0, x: 50 }}
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
exit={{ opacity: 0, x: -50 }}
|
|
|
|
|
transition={{ duration: 0.3 }}
|
|
|
|
|
>
|
|
|
|
|
{renderStep()}
|
|
|
|
|
</motion.div>
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|