diff --git a/src/components/cost-estimator/cost-estimator-form.tsx b/src/components/cost-estimator/cost-estimator-form.tsx index 65e40a9..111e81c 100644 --- a/src/components/cost-estimator/cost-estimator-form.tsx +++ b/src/components/cost-estimator/cost-estimator-form.tsx @@ -72,17 +72,34 @@ export function CostEstimatorForm() { const handleNextStep = () => { startTransition(() => { - if (currentStep === 2 && formData.serviceType === 'development') { - setCurrentStep(5); - } else if (currentStep === 2 && formData.serviceType === 'ui-ux-design') { - setCurrentStep(12); - } else if (currentStep === 5 && formData.serviceType === 'development') { - setCurrentStep(9); - } else if (currentStep === 12) { - setCurrentStep(11); - } else { - setCurrentStep((prev) => prev + 1); + // 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') { + setCurrentStep(9); + return; + } + + // After branding, if service is identity-branding, skip to results + if (currentStep === 8 && formData.serviceType === 'identity-branding') { + setCurrentStep(11); + return; + } + + // After UI/UX design step, go to page count + if (currentStep === 12) { + setCurrentStep(5); + return; + } + + setCurrentStep((prev) => prev + 1); }); }; @@ -90,14 +107,26 @@ export function CostEstimatorForm() { startTransition(() => { if (currentStep === 5 && formData.serviceType === 'development') { setCurrentStep(2); - } else if (currentStep === 9 && formData.serviceType === 'development') { + return; + } + if (currentStep === 9 && formData.serviceType === 'development') { setCurrentStep(5); - } else if (currentStep === 12) { + return; + } + if (currentStep === 12) { setCurrentStep(2); + return; } - else { - setCurrentStep((prev) => prev - 1); + if (currentStep === 5 && formData.serviceType === 'ui-ux-design') { + setCurrentStep(12); + return; } + if(currentStep === 8 && formData.serviceType === 'identity-branding') { + setCurrentStep(2); + return; + } + + setCurrentStep((prev) => prev - 1); }); }; diff --git a/src/components/cost-estimator/step-11-results.tsx b/src/components/cost-estimator/step-11-results.tsx index 300aa2b..1345f91 100644 --- a/src/components/cost-estimator/step-11-results.tsx +++ b/src/components/cost-estimator/step-11-results.tsx @@ -42,9 +42,19 @@ const uiUxDesignHoursMap = { export const calculateTotalHours = (formData: FormData) => { + let customHours = 0; + if (formData.serviceType === 'ui-ux-design') { - const hours = formData.uiUxDesignProcess ? uiUxDesignHoursMap[formData.uiUxDesignProcess] : 0; - return { customHours: hours, readyMadeHours: Math.round(hours * 0.4) }; + customHours = formData.uiUxDesignProcess ? uiUxDesignHoursMap[formData.uiUxDesignProcess] : 0; + const pageVal = formData.pageCount === 10 ? 50 : (formData.pageCount + 1) * 5 - 1; + const pageHours = pageVal * 6; + customHours += pageHours; + return { customHours: customHours, readyMadeHours: Math.round(customHours * 0.4) }; + } + + if (formData.serviceType === 'identity-branding') { + customHours = formData.branding ? (brandingHoursMap[formData.branding] ?? 0) : 0; + return { customHours: customHours, readyMadeHours: Math.round(customHours * 0.4) }; } @@ -78,7 +88,7 @@ export const calculateTotalHours = (formData: FormData) => { } } - let customHours = pageHours + stageHours + additionalFeaturesHours + cartHours; + customHours = pageHours + stageHours + additionalFeaturesHours + cartHours; if (formData.serviceType !== 'development') { customHours += designHours + animationHours + illustrationTotalHours + brandingH; }