File size: 12,851 Bytes
921d377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/**
 * OnboardingWizard — 3-step minimalist onboarding.
 *
 * Shown after first registration. Claude-inspired: clean, fast, no friction.
 * Step 1: Your name
 * Step 2: What you'll use HomePilot for + preferred tone
 * Step 3: Ready — welcome screen
 */
import React, { useState } from 'react';
import { ArrowRight, ArrowLeft, Check, Sparkles, MessageSquare, Image, Search, Heart, Film } from 'lucide-react';
const USE_CASES = [
    { id: 'chat', label: 'Chat & Conversation', icon: MessageSquare, color: '#3b82f6' },
    { id: 'images', label: 'Image Generation', icon: Image, color: '#8b5cf6' },
    { id: 'research', label: 'Research & Knowledge', icon: Search, color: '#06b6d4' },
    { id: 'companion', label: 'AI Companion', icon: Heart, color: '#ec4899' },
    { id: 'content', label: 'Content Creation', icon: Film, color: '#f59e0b' },
];
const TONES = [
    { id: 'casual', label: 'Casual', desc: 'Friendly and relaxed' },
    { id: 'balanced', label: 'Balanced', desc: 'Natural and adaptable' },
    { id: 'professional', label: 'Professional', desc: 'Clear and formal' },
];
export default function OnboardingWizard({ backendUrl, token, username, onComplete }) {
    const [step, setStep] = useState(1);
    const [displayName, setDisplayName] = useState('');
    const [selectedUseCases, setSelectedUseCases] = useState([]);
    const [tone, setTone] = useState('balanced');
    const [saving, setSaving] = useState(false);
    const toggleUseCase = (id) => {
        setSelectedUseCases(prev => prev.includes(id) ? prev.filter(x => x !== id) : [...prev, id]);
    };
    const handleFinish = async () => {
        setSaving(true);
        try {
            await fetch(`${backendUrl}/v1/auth/onboarding`, {
                method: 'PUT',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${token}`,
                },
                credentials: 'include',
                body: JSON.stringify({
                    display_name: displayName.trim() || username,
                    use_cases: selectedUseCases,
                    preferred_tone: tone,
                }),
            });
        }
        catch {
            // Non-fatal — proceed anyway
        }
        setSaving(false);
        onComplete(displayName.trim() || username);
    };
    const cardStyle = {
        width: '100%',
        maxWidth: 480,
        background: 'rgba(30, 41, 59, 0.8)',
        border: '1px solid rgba(148, 163, 184, 0.1)',
        borderRadius: 16,
        padding: 32,
        backdropFilter: 'blur(12px)',
    };
    return (<div style={{
            minHeight: '100vh',
            display: 'flex',
            flexDirection: 'column',
            alignItems: 'center',
            justifyContent: 'center',
            background: 'linear-gradient(135deg, #0a0a1a 0%, #111827 50%, #0f172a 100%)',
            fontFamily: 'system-ui, -apple-system, sans-serif',
            padding: 20,
        }}>
      {/* Progress dots */}
      <div style={{ display: 'flex', gap: 8, marginBottom: 24 }}>
        {[1, 2, 3].map(s => (<div key={s} style={{
                width: 8,
                height: 8,
                borderRadius: '50%',
                background: s <= step ? '#3b82f6' : 'rgba(148, 163, 184, 0.2)',
                transition: 'background 0.3s',
            }}/>))}
      </div>

      {/* Step 1: Your name */}
      {step === 1 && (<div style={cardStyle}>
          <div style={{ textAlign: 'center', marginBottom: 24 }}>
            <Sparkles size={32} style={{ color: '#3b82f6', marginBottom: 12 }}/>
            <h2 style={{ fontSize: 22, fontWeight: 700, color: '#e2e8f0', margin: 0 }}>
              Welcome to HomePilot
            </h2>
            <p style={{ color: '#94a3b8', fontSize: 14, marginTop: 8 }}>
              Let's set up your profile so your AI companions know who you are.
            </p>
          </div>

          <label style={{ display: 'block', fontSize: 13, color: '#94a3b8', marginBottom: 8, fontWeight: 500 }}>
            What should we call you?
          </label>
          <input type="text" value={displayName} onChange={e => setDisplayName(e.target.value)} placeholder={username} autoFocus maxLength={64} style={{
                width: '100%',
                padding: '12px 14px',
                borderRadius: 10,
                border: '1px solid rgba(148, 163, 184, 0.15)',
                background: 'rgba(15, 23, 42, 0.5)',
                color: '#e2e8f0',
                fontSize: 16,
                outline: 'none',
                boxSizing: 'border-box',
                marginBottom: 24,
            }} onKeyDown={e => e.key === 'Enter' && setStep(2)}/>

          <button onClick={() => setStep(2)} style={{
                width: '100%',
                padding: 12,
                borderRadius: 10,
                border: 'none',
                background: 'linear-gradient(135deg, #2563eb 0%, #3b82f6 100%)',
                color: '#fff',
                fontSize: 15,
                fontWeight: 600,
                cursor: 'pointer',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                gap: 8,
            }}>
            Continue <ArrowRight size={16}/>
          </button>
        </div>)}

      {/* Step 2: Use cases + tone */}
      {step === 2 && (<div style={cardStyle}>
          <div style={{ textAlign: 'center', marginBottom: 24 }}>
            <h2 style={{ fontSize: 20, fontWeight: 700, color: '#e2e8f0', margin: 0 }}>
              How will you use HomePilot?
            </h2>
            <p style={{ color: '#94a3b8', fontSize: 13, marginTop: 6 }}>
              Select all that apply — this helps personalize your experience.
            </p>
          </div>

          {/* Use case chips */}
          <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginBottom: 24 }}>
            {USE_CASES.map(uc => {
                const selected = selectedUseCases.includes(uc.id);
                const Icon = uc.icon;
                return (<button key={uc.id} onClick={() => toggleUseCase(uc.id)} style={{
                        display: 'flex',
                        alignItems: 'center',
                        gap: 6,
                        padding: '8px 14px',
                        borderRadius: 20,
                        border: `1.5px solid ${selected ? uc.color : 'rgba(148, 163, 184, 0.15)'}`,
                        background: selected ? `${uc.color}20` : 'transparent',
                        color: selected ? uc.color : '#94a3b8',
                        fontSize: 13,
                        fontWeight: 500,
                        cursor: 'pointer',
                        transition: 'all 0.2s',
                    }}>
                  <Icon size={14}/>
                  {uc.label}
                  {selected && <Check size={12}/>}
                </button>);
            })}
          </div>

          {/* Tone */}
          <label style={{ display: 'block', fontSize: 13, color: '#94a3b8', marginBottom: 8, fontWeight: 500 }}>
            Preferred conversation style
          </label>
          <div style={{ display: 'flex', gap: 8, marginBottom: 24 }}>
            {TONES.map(t => (<button key={t.id} onClick={() => setTone(t.id)} style={{
                    flex: 1,
                    padding: '10px 8px',
                    borderRadius: 10,
                    border: `1.5px solid ${tone === t.id ? '#3b82f6' : 'rgba(148, 163, 184, 0.15)'}`,
                    background: tone === t.id ? 'rgba(59, 130, 246, 0.1)' : 'transparent',
                    color: tone === t.id ? '#93c5fd' : '#94a3b8',
                    fontSize: 13,
                    fontWeight: 500,
                    cursor: 'pointer',
                    textAlign: 'center',
                    transition: 'all 0.2s',
                }}>
                <div>{t.label}</div>
                <div style={{ fontSize: 11, color: '#64748b', marginTop: 2 }}>{t.desc}</div>
              </button>))}
          </div>

          <div style={{ display: 'flex', gap: 8 }}>
            <button onClick={() => setStep(1)} style={{
                padding: '12px 20px',
                borderRadius: 10,
                border: '1px solid rgba(148, 163, 184, 0.15)',
                background: 'transparent',
                color: '#94a3b8',
                fontSize: 14,
                cursor: 'pointer',
                display: 'flex',
                alignItems: 'center',
                gap: 6,
            }}>
              <ArrowLeft size={14}/> Back
            </button>
            <button onClick={() => setStep(3)} style={{
                flex: 1,
                padding: 12,
                borderRadius: 10,
                border: 'none',
                background: 'linear-gradient(135deg, #2563eb 0%, #3b82f6 100%)',
                color: '#fff',
                fontSize: 15,
                fontWeight: 600,
                cursor: 'pointer',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                gap: 8,
            }}>
              Continue <ArrowRight size={16}/>
            </button>
          </div>
        </div>)}

      {/* Step 3: Ready */}
      {step === 3 && (<div style={cardStyle}>
          <div style={{ textAlign: 'center', marginBottom: 24 }}>
            <div style={{
                width: 56,
                height: 56,
                borderRadius: '50%',
                background: 'linear-gradient(135deg, #2563eb 0%, #8b5cf6 100%)',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                margin: '0 auto 16px',
            }}>
              <Check size={28} style={{ color: '#fff' }}/>
            </div>
            <h2 style={{ fontSize: 22, fontWeight: 700, color: '#e2e8f0', margin: 0 }}>
              You're all set{displayName ? `, ${displayName}` : ''}!
            </h2>
            <p style={{ color: '#94a3b8', fontSize: 14, marginTop: 8, lineHeight: 1.5 }}>
              Your profile is ready. Your AI companions will use this to personalize your experience over time.
            </p>
          </div>

          {/* Summary */}
          <div style={{
                background: 'rgba(15, 23, 42, 0.5)',
                borderRadius: 10,
                padding: 16,
                marginBottom: 24,
                fontSize: 13,
                color: '#94a3b8',
            }}>
            {displayName && <div>Name: <span style={{ color: '#e2e8f0' }}>{displayName}</span></div>}
            {selectedUseCases.length > 0 && (<div style={{ marginTop: 6 }}>
                Interests: <span style={{ color: '#e2e8f0' }}>
                  {selectedUseCases.map(id => USE_CASES.find(u => u.id === id)?.label).join(', ')}
                </span>
              </div>)}
            <div style={{ marginTop: 6 }}>
              Style: <span style={{ color: '#e2e8f0' }}>{TONES.find(t => t.id === tone)?.label}</span>
            </div>
          </div>

          <div style={{ display: 'flex', gap: 8 }}>
            <button onClick={() => setStep(2)} style={{
                padding: '12px 20px',
                borderRadius: 10,
                border: '1px solid rgba(148, 163, 184, 0.15)',
                background: 'transparent',
                color: '#94a3b8',
                fontSize: 14,
                cursor: 'pointer',
                display: 'flex',
                alignItems: 'center',
                gap: 6,
            }}>
              <ArrowLeft size={14}/> Back
            </button>
            <button onClick={handleFinish} disabled={saving} style={{
                flex: 1,
                padding: 12,
                borderRadius: 10,
                border: 'none',
                background: saving ? '#1e3a5f' : 'linear-gradient(135deg, #2563eb 0%, #8b5cf6 100%)',
                color: '#fff',
                fontSize: 15,
                fontWeight: 600,
                cursor: saving ? 'wait' : 'pointer',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                gap: 8,
            }}>
              {saving ? 'Saving...' : 'Start using HomePilot'}
              {!saving && <Sparkles size={16}/>}
            </button>
          </div>
        </div>)}

      {/* Skip link */}
      {step < 3 && (<button onClick={handleFinish} style={{
                background: 'none',
                border: 'none',
                color: '#475569',
                fontSize: 13,
                cursor: 'pointer',
                marginTop: 16,
            }}>
          Skip for now
        </button>)}
    </div>);
}