// SetupWizard.jsx — İlk açılış: yönetici hesabı oluştur const { useState: useStateSW, useEffect: useEffectSW } = React; function SetupWizard({ onComplete }) { const [step, setStep] = useStateSW(1); const [name, setName] = useStateSW(''); const [phoneDigits, setPhoneDigits] = useStateSW(''); const [pin, setPin] = useStateSW(''); const [error, setError] = useStateSW(null); const [submitting, setSubmitting] = useStateSW(false); const phoneOk = phoneDigits.length === 10; const goStep1Next = () => { setError(null); if (!name.trim()) { setError('Ad gerekli'); return; } if (!phoneOk) { setError('Geçerli bir telefon gir (10 hane)'); return; } setStep(2); }; // Step 2 onSubmit: save the chosen pin and advance to confirm const handleSetPin = async (entered) => { setPin(entered); setError(null); setStep(3); return true; }; // Step 3 onSubmit: must match step 2 pin, then create admin const submitFinal = async (confirmedPin) => { if (confirmedPin !== pin) { setError('PIN\'ler eşleşmiyor'); return false; } setError(null); setSubmitting(true); try { await Store.setupAdmin(name.trim(), '+90' + phoneDigits, pin); onComplete(); return true; } catch (e) { setError(e.message || 'Kurulum başarısız'); setSubmitting(false); return false; } }; return (
adisyon
ilk kurulum
{/* Step indicator */}
{[1, 2, 3].map((n) => (
))}
{step === 1 && ( <>
Yönetici Hesabı
Adını ve telefonunu gir. Daha sonra giriş yaparken kullanacaksın.
{ setName(e.target.value); setError(null); }} placeholder="Örn. Ali Yılmaz" autoFocus style={{ marginBottom: 14, fontSize: 16, padding: '12px 14px' }} />
+90
{ const d = e.target.value.replace(/\D/g, '').slice(0, 10); setPhoneDigits(d); setError(null); }} style={{ flex: 1, padding: '14px 14px', border: 'none', outline: 'none', fontFamily: 'inherit', fontSize: 17, fontWeight: 600, letterSpacing: '0.04em' }} />
{error &&
{error}
} )} {step === 2 && ( <>
PIN Belirle
Giriş yaparken kullanacağın 6 haneli PIN'i belirle.
)} {step === 3 && ( <>
PIN'i Onayla
Aynı PIN'i tekrar gir.
{submitting &&
Kuruluyor…
} )}
); } Object.assign(window, { SetupWizard });