'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { Button, Input, Label, Card, CardContent, CardHeader, CardTitle, cn } from '@horux/shared-ui'; import { useAuthStore } from '@/stores/auth-store'; import { apiClient } from '@/lib/api/client'; import { CheckCircle2, Server, Cloud, ArrowLeft, Clock } from 'lucide-react'; type VerticalProfile = 'CONTABLE' | 'JURIDICO' | 'ARQUITECTURA'; type PlanType = 'trial' | 'business_control' | 'business_cloud'; export default function RegisterDespachoPage() { const router = useRouter(); const { setUser, setTokens } = useAuthStore(); const [step, setStep] = useState(1); const [verticalProfile, setVerticalProfile] = useState(null); const [selectedPlan, setSelectedPlan] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [form, setForm] = useState({ despachoNombre: '', ownerNombre: '', ownerEmail: '', ownerPassword: '', acceptedTerms: false, }); const handleChange = (field: string) => (e: React.ChangeEvent) => { setForm((prev) => ({ ...prev, [field]: e.target.value })); setError(''); }; const handleSubmit = async () => { if (!form.acceptedTerms) { setError('Debes aceptar los términos y condiciones'); return; } if (!verticalProfile || !selectedPlan) { setError('Completa todos los pasos'); return; } setLoading(true); setError(''); try { const { data } = await apiClient.post('/despachos/signup', { despacho: { nombre: form.despachoNombre, verticalProfile, plan: selectedPlan, }, owner: { nombre: form.ownerNombre, email: form.ownerEmail, password: form.ownerPassword, }, }); setTokens(data.accessToken, data.refreshToken); setUser(data.user); // If paid plan with payment URL, redirect to MercadoPago if (data.paymentUrl) { window.location.href = data.paymentUrl; } else { router.push('/onboarding'); } } catch (err: any) { setError(err.response?.data?.message || 'Error al registrar el despacho'); setStep(1); } finally { setLoading(false); } }; // =================== STEP 1: Registration Form =================== if (step === 1) { const canProceed = form.despachoNombre && form.ownerNombre && form.ownerEmail && form.ownerPassword.length >= 10 && form.acceptedTerms; return (
1 2 3
Crea tu cuenta

Plataforma para despachos profesionales

setForm((p) => ({ ...p, acceptedTerms: e.target.checked }))} className="mt-1" />
{error &&

{error}

}

¿Ya tienes cuenta? Inicia sesión

); } // =================== STEP 2: Vertical Selection =================== if (step === 2) { return (
2 3

¿Qué tipo de despacho eres?

Selecciona tu área profesional

⚖️

Jurídico

Próximamente

🏗️

Arquitectura

Próximamente

); } // =================== STEP 3: Subscription Selection =================== return (
3

Elige tu plan

Todos los planes incluyen las mismas funcionalidades.

{/* Trial Gratuito */} setSelectedPlan('trial')} >
Trial Gratuito

Prueba sin compromiso

$0

por 30 días

Sin tarjeta de crédito

Hasta 3 RFCs
20 timbres incluidos
Todas las funcionalidades
Base de datos en la nube
{/* Business Control */} setSelectedPlan('business_control')} >
Business Control

Tu servidor, tus datos

$21,000

primer año (IVA incluido)

$15,000/año a partir del 2do año

Base de datos en tu servidor
RFCs ilimitados
Usuarios ilimitados
Control total de tus datos
Requiere Docker en tu servidor
{/* Business Cloud */} setSelectedPlan('business_cloud')} >
Más popular
Business Cloud

Nosotros lo operamos por ti

$15,000

por año (fijo)

+ $45/mes por cada RFC gestionado

Base de datos en la nube (Horux)
Sin infraestructura propia
Usuarios ilimitados
Backups automáticos
Soporte prioritario
{error &&

{error}

}
); }