import React, { useState } from 'react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { toast } from 'sonner'; import { api } from '@/api'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'; export default function OnboardingWizard({ onComplete }) { const [step, setStep] = useState(0); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [confirm, setConfirm] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const handleCreate = async (e) => { e.preventDefault(); setError(''); let validationError = ''; if (password !== confirm) { validationError = 'Passwords do not match.'; } else if (password.length < 8) { validationError = 'Password must be at least 8 characters.'; } if (validationError) { setError(validationError); toast.error(validationError); return; } setLoading(true); try { await api.createUser({ username, password }); toast.success('User created successfully.'); onComplete(); } catch (err) { const errorMessage = err.message || 'Failed to create user.'; setError(errorMessage); toast.error(errorMessage); } finally { setLoading(false); } }; return (
Before creating your first user, please understand what your admin account can and cannot do.
This account will be used to access the bill tracker.