'use client'; import { useState } from 'react'; import { motion } from 'framer-motion'; import { HardDrive, Lock, User, ArrowRight, Check } from 'lucide-react'; import api from '@/lib/api'; interface SetupWizardProps { onComplete: () => void; } export default function SetupWizard({ onComplete }: SetupWizardProps) { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const [step, setStep] = useState(1); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); if (step === 1) { if (username.length < 3) { setError('Username must be at least 3 characters'); return; } setStep(2); return; } if (password.length < 8) { setError('Password must be at least 8 characters'); return; } if (password !== confirmPassword) { setError('Passwords do not match'); return; } setLoading(true); try { const result = await api.setup(username, password); if (result.error) { setError(result.error); } else { setStep(3); setTimeout(onComplete, 1500); } } catch { setError('Failed to complete setup'); } finally { setLoading(false); } } return (
{/* Logo & Title */}

Welcome to Drive

{step === 3 ? 'Setup complete!' : "Let's set up your account"}

{/* Progress Indicator */}
{[1, 2, 3].map((s) => (
= s ? '2rem' : '0.75rem', backgroundColor: step >= s ? 'var(--color-accent)' : 'var(--color-border)', }} /> ))}
{/* Card */}
{step === 3 ? (

Account created successfully!

Redirecting to login...

) : (
{step === 1 && (
)} {step === 2 && (
)}
{error && ( {error} )}
)}
); }