import React, { useState, useRef } from 'react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { Label } from './ui/label'; import { Textarea } from './ui/textarea'; import { Dialog, DialogContent, DialogTitle } from './ui/dialog'; import type { User as UserType } from '../App'; import { toast } from 'sonner'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './ui/select'; import { ChevronLeft, ChevronRight } from 'lucide-react'; interface OnboardingProps { user: UserType; onComplete: (user: UserType) => void; onSkip: () => void; } const TOTAL_STEPS = 5; export function Onboarding({ user, onComplete, onSkip }: OnboardingProps) { const [currentStep, setCurrentStep] = useState(1); const [name, setName] = useState(user.name); const [email, setEmail] = useState(user.email); const [studentId, setStudentId] = useState(''); const [department, setDepartment] = useState(''); const [year, setYear] = useState(''); const [major, setMajor] = useState(''); const [bio, setBio] = useState(''); const [photoPreview, setPhotoPreview] = useState(null); const fileInputRef = useRef(null); const handlePhotoSelect = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { // Validate file type if (!file.type.startsWith('image/')) { toast.error('Please select an image file'); return; } // Validate file size (2MB) if (file.size > 2 * 1024 * 1024) { toast.error('File size must be less than 2MB'); return; } // Create preview const reader = new FileReader(); reader.onload = (e) => { setPhotoPreview(e.target?.result as string); }; reader.readAsDataURL(file); } }; const handleChangePhotoClick = () => { fileInputRef.current?.click(); }; const handleNext = () => { if (currentStep < TOTAL_STEPS) { setCurrentStep(currentStep + 1); } else { handleComplete(); } }; const handlePrevious = () => { if (currentStep > 1) { setCurrentStep(currentStep - 1); } }; const handleSkip = () => { // Skip all remaining steps and complete onboarding onSkip(); }; const handleComplete = () => { if (name.trim() && email.trim()) { onComplete({ name: name.trim(), email: email.trim() }); toast.success('Profile setup completed!'); } else { toast.error('Please fill in all required fields'); } }; const renderStepContent = () => { switch (currentStep) { case 1: return (

Basic Information

Let's start with your basic information

setName(e.target.value)} placeholder="Enter your full name" />
setEmail(e.target.value)} placeholder="Enter your email" />
); case 2: return (

Academic Background

Tell us about your academic information

setStudentId(e.target.value)} placeholder="Enter your student ID" />
setDepartment(e.target.value)} placeholder="Enter your department" />
setMajor(e.target.value)} placeholder="Enter your major" />
); case 3: return (

About You

Share a brief introduction about yourself