'use client' import Link from 'next/link' import { useState } from 'react' import { useRouter } from 'next/navigation' import { apiFetch } from '@/lib/api' import PublicShell from '@/components/layout/PublicShell' import { marketplaceUrl } from '@/lib/urls' type Step = 1 | 2 | 3 export default function OnboardingPage() { const router = useRouter() const [step, setStep] = useState(1) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const [company, setCompany] = useState({ name: '', slug: '' }) const [brand, setBrand] = useState({ displayName: '', tagline: '', primaryColor: '#2563eb', publicCity: '', publicCountry: '', }) const [payments, setPayments] = useState({ amanpayMerchantId: '', amanpaySecretKey: '', paypalEmail: '', isListedOnMarketplace: true, }) async function handleStep1() { if (!company.name.trim()) return setError('Company name is required') setLoading(true) setError(null) try { await apiFetch('/companies/me', { method: 'PATCH', body: JSON.stringify({ name: company.name }), }) setStep(2) } catch (err: any) { setError(err.message) } finally { setLoading(false) } } async function handleStep2() { if (!brand.displayName.trim()) return setError('Display name is required') setLoading(true) setError(null) try { await apiFetch('/companies/me/brand', { method: 'PATCH', body: JSON.stringify({ displayName: brand.displayName, tagline: brand.tagline || undefined, primaryColor: brand.primaryColor, publicCity: brand.publicCity || undefined, publicCountry: brand.publicCountry || undefined, }), }) setStep(3) } catch (err: any) { setError(err.message) } finally { setLoading(false) } } async function handleStep3() { setLoading(true) setError(null) try { await apiFetch('/companies/me/brand', { method: 'PATCH', body: JSON.stringify({ amanpayMerchantId: payments.amanpayMerchantId || undefined, amanpaySecretKey: payments.amanpaySecretKey || undefined, paypalEmail: payments.paypalEmail || undefined, isListedOnMarketplace: payments.isListedOnMarketplace, }), }) router.push('/') } catch (err: any) { setError(err.message) } finally { setLoading(false) } } return (
FleetOS

Set up your account

Step {step} of 3

{[1, 2, 3].map((s) => (
))}
{error && (
{error}
)} {step === 1 && (

Your company

Tell us the basics about your rental company.

setCompany({ ...company, name: e.target.value })} />
)} {step === 2 && (

Brand & identity

Customize how your company appears to renters.

setBrand({ ...brand, displayName: e.target.value })} />
setBrand({ ...brand, tagline: e.target.value })} />
setBrand({ ...brand, publicCity: e.target.value })} />
setBrand({ ...brand, publicCountry: e.target.value })} />
setBrand({ ...brand, primaryColor: e.target.value })} /> setBrand({ ...brand, primaryColor: e.target.value })} />
)} {step === 3 && (

Payment setup

Connect payment providers so renters can book online. You can skip this for now.

setPayments({ ...payments, amanpayMerchantId: e.target.value })} />
setPayments({ ...payments, amanpaySecretKey: e.target.value })} />
setPayments({ ...payments, paypalEmail: e.target.value })} />
)}
) }