import { useState } from "react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../ui/dialog"; type OnboardingStep = { title: string; description: string; type: "info" | "settings"; settings?: { type: "switch" | "input"; label: string; key: string; }[]; }; const onboardingSteps: OnboardingStep[] = [ { title: "Welcome to Upscayl 🎉", description: "Let's get you started with a few quick steps.", type: "info", }, { title: "Choose Your Preferences", description: "Configure your initial settings.", type: "settings", settings: [ { type: "switch", label: "Enable automatic updates", key: "autoUpdate", }, { type: "input", label: "Default output folder", key: "outputFolder", }, ], }, { title: "You're All Set!", description: "You can now start upscaling your images.", type: "info", }, ]; export function OnboardingDialog({ open, onOpenChange, }: { open: boolean; onOpenChange: (open: boolean) => void; }) { const [currentStep, setCurrentStep] = useState(0); const [settings, setSettings] = useState>({}); const currentStepData = onboardingSteps[currentStep]; const isLastStep = currentStep === onboardingSteps.length - 1; const isFirstStep = currentStep === 0; const handleNext = () => { if (isLastStep) { onOpenChange(false); // Here you can handle saving the settings console.log("Final settings:", settings); } else { setCurrentStep((prev) => prev + 1); } }; const handleSettingChange = (key: string, value: any) => { setSettings((prev) => ({ ...prev, [key]: value })); }; return ( {currentStepData.title} {currentStepData.description} {currentStepData.type === "settings" && currentStepData.settings && (
{currentStepData.settings.map((setting) => (
{setting.type === "switch" && ( handleSettingChange(setting.key, e.target.checked) } /> )} {setting.type === "input" && ( handleSettingChange(setting.key, e.target.value) } /> )}
))}
)} {!isFirstStep && ( )}
); }