"use client"; import type { FormData, IllustrationSelection } from './cost-estimator-form'; import { Button } from '@/components/ui/button'; import { Checkbox } from '@/components/ui/checkbox'; import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; import { Label } from '@/components/ui/label'; import { Gauge } from 'lucide-react'; import React, { useState, useMemo, useEffect } from 'react'; type Step7Props = { onNext: () => void; onBack: () => void; onUpdateData: (data: Partial) => void; formData: FormData; }; const designHoursMap = { custom: 60, mockups: 30, existing: 0, }; const illustrationHours = { '2d_static': 10, '2d_animated': 25, '3d_static': 20, '3d_animated': 40, } const calculateHours = ( pageCount: number, projectStage: number, designProcess: 'custom' | 'mockups' | 'existing' | null, animatedElements: boolean | null, illustrations: IllustrationSelection ): number => { const pageVal = pageCount === 10 ? 50 : (pageCount + 1) * 5 - 1; const pageHours = pageVal * 6; const stageHours = Math.round((projectStage / 100) * 50); const designHours = designProcess ? designHoursMap[designProcess] : 0; const animationHours = animatedElements ? 30 : 0; let illustrationTotalHours = 0; if (illustrations.has2d) { if (illustrations.is2dAnimated === 'static') illustrationTotalHours += illustrationHours['2d_static']; if (illustrations.is2dAnimated === 'animated') illustrationTotalHours += illustrationHours['2d_animated']; } if (illustrations.has3d) { if (illustrations.is3dAnimated === 'static') illustrationTotalHours += illustrationHours['3d_static']; if (illustrations.is3dAnimated === 'animated') illustrationTotalHours += illustrationHours['3d_animated']; } return pageHours + stageHours + designHours + animationHours + illustrationTotalHours; }; export function Step7Illustrations({ onNext, onBack, onUpdateData, formData }: Step7Props) { const [selections, setSelections] = useState(formData.illustrations); const [noIllustrations, setNoIllustrations] = useState(false); useEffect(() => { const no2d = !selections.has2d || selections.is2dAnimated === null; const no3d = !selections.has3d || selections.is3dAnimated === null; const noIllustrationsSelected = !selections.has2d && !selections.has3d; setNoIllustrations(noIllustrationsSelected); }, [selections]); const handleUpdate = (newSelections: Partial) => { const updated = { ...selections, ...newSelections }; setSelections(updated); onUpdateData({ illustrations: updated }); if(updated.has2d || updated.has3d) { setNoIllustrations(false); } }; const handleNoIllustrationsChange = (checked: boolean) => { setNoIllustrations(checked); if(checked) { const resetSelections = { has2d: false, is2dAnimated: null, has3d: false, is3dAnimated: null, }; setSelections(resetSelections); onUpdateData({ illustrations: resetSelections }); } } const handle2dCheck = (checked: boolean) => { handleUpdate({ has2d: checked, is2dAnimated: checked ? selections.is2dAnimated || 'static' : null }); }; const handle3dCheck = (checked: boolean) => { handleUpdate({ has3d: checked, is3dAnimated: checked ? selections.is3dAnimated || 'static' : null }); }; const estimatedHours = useMemo(() => { return calculateHours( formData.pageCount, formData.projectStage, formData.designProcess, formData.animatedElements, selections ); }, [selections, formData]); const isNextDisabled = (selections.has2d && !selections.is2dAnimated) || (selections.has3d && !selections.is3dAnimated) return (

Would you like us to create illustrations tailored to your project?

{selections.has2d && ( handleUpdate({ is2dAnimated: value })} className="ml-6 space-y-2" >
)}
{selections.has3d && ( handleUpdate({ is3dAnimated: value })} className="ml-6 space-y-2" >
)}
{estimatedHours}+ hours
); }