import React, { useState } from 'react'; import { Shield, Building2, PenLine, X, Loader2, ArrowRight } from 'lucide-react'; import { useTheme } from '../contexts/ThemeContext'; import { useAppConfig } from '../contexts/AppConfigContext'; /** * Explore-as-guest intake: two persona chips + free-text "something else". */ const DEFAULT_GUEST_GOALS = { personal: { title: "I'm securing my personal digital life", detail: 'Passwords, MFA, backups, phishing — sample Journey & chat for individuals', }, business: { title: 'I am responsible for securing an organization', detail: 'SMB / IT baseline, CIS IG1 sample track, policies & Workspace demo', }, other: { title: 'Something else', detail: "Describe your situation — we'll tailor the demo", }, }; const GuestIntakeModal = ({ onClose, onSuccess }) => { const { isDark } = useTheme(); const { config } = useAppConfig(); const guestGoals = { ...DEFAULT_GUEST_GOALS, ...(config?.homepage?.guest_goals || {}), }; const [choice, setChoice] = useState(null); // personal | business | other const [freeText, setFreeText] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const bg = isDark ? 'rgba(15,23,42,0.92)' : 'rgba(15,23,42,0.45)'; const card = { background: isDark ? '#1e293b' : '#fff', color: isDark ? '#f8fafc' : '#0f172a', border: `1px solid ${isDark ? '#334155' : '#e2e8f0'}`, borderRadius: 16, maxWidth: 480, width: '92%', padding: '1.5rem 1.4rem 1.25rem', boxShadow: '0 24px 48px rgba(15,23,42,0.25)', }; const chip = (active) => ({ display: 'flex', alignItems: 'flex-start', gap: 12, textAlign: 'left', width: '100%', padding: '14px 14px', minHeight: 44, borderRadius: 12, border: active ? '2px solid var(--accent-primary, #0B7A8A)' : `1px solid ${isDark ? '#475569' : '#cbd5e1'}`, background: active ? (isDark ? 'rgba(15,118,110,0.2)' : 'rgba(15,118,110,0.08)') : (isDark ? '#0f172a' : '#f8fafc'), cursor: 'pointer', color: 'inherit', marginBottom: 10, }); const start = async () => { if (!choice) { setError('Pick a path or describe what you need.'); return; } if (choice === 'other' && !freeText.trim()) { setError('Tell us a bit about what you need help with.'); return; } setLoading(true); setError(null); try { const resp = await fetch(`${process.env.REACT_APP_API_URL || ''}/auth/guest`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ choice, free_text: choice === 'other' ? freeText.trim() : null, }), }); if (!resp.ok) { const data = await resp.json().catch(() => ({})); throw new Error(data.detail || 'Could not start guest session'); } const data = await resp.json(); localStorage.setItem('authToken', data.access_token); localStorage.setItem('user', JSON.stringify(data.user)); onSuccess?.(data.user, data.access_token); } catch (e) { setError(e.message || 'Something went wrong'); } finally { setLoading(false); } }; return (
No account needed. We'll load a realistic demo so Chat, Journey, Workspace, and About You feel useful right away.
{error}
)}