import React, { useState } from 'react'; import { Leaf, UtensilsCrossed, ArrowRight } from 'lucide-react'; import './SearchPathGate.css'; export const SEARCH_PATH_OPTIONS = [ { value: 'Clean eating basics', title: 'Get started', description: 'I want practical clean eating and real-food basics without overwhelm.', icon: Leaf, }, { value: 'More fruits & vegetables', title: 'More produce', description: 'I want help enjoying fruits, vegetables, recipes, and easy prep.', icon: UtensilsCrossed, }, ]; /** * First-run gate: healthy-eating focus steers advisor trajectory. */ const SearchPathGate = ({ authToken, onComplete }) => { const [selected, setSelected] = useState(null); const [saving, setSaving] = useState(false); const [error, setError] = useState(''); const handleContinue = async () => { if (!selected) { setError('Pick a focus to continue.'); return; } setSaving(true); setError(''); try { const resp = await fetch(`${process.env.REACT_APP_API_URL}/api/users/me/profile`, { method: 'PUT', headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ cyber_role: selected }), }); if (!resp.ok) { const data = await resp.json().catch(() => ({})); throw new Error(data.detail || 'Could not save your choice'); } const profile = await resp.json(); localStorage.setItem('healthyEatingSearchPath', selected); onComplete?.(profile, selected); } catch (e) { setError(e.message || 'Could not save your choice'); } finally { setSaving(false); } }; return (
This steers every advisor — Kitchen Coach, produce specialists, superfoods, enzymes, and book guidance.