// data.jsx — bundle catalogue, Telecel number validation, shared purchase widgets const FIRST_VISIT_KEY = "telecel_portal_verified"; /* ── Telecel number validation: 9 digits, 96 5XX / 96 6XX / 96 9XX ── */ function normalizeTelecel(input) { let d = String(input || "").replace(/\D/g, ""); if (d.startsWith("00245")) d = d.slice(5); else if (d.startsWith("245") && d.length > 9) d = d.slice(3); return d; } function telecelError(input) { const d = normalizeTelecel(input); if (!d) return "Introduz um número"; if (!d.startsWith("96") && d.length >= 2) return "Só números Telecel (começam por 96)"; if (d.length >= 3 && !/^96[569]/.test(d)) return "Só números Telecel: 96 5, 96 6 ou 96 9"; if (d.length < 9) return "O número deve ter 9 dígitos"; if (d.length > 9) return "O número tem dígitos a mais"; return null; } function isTelecelNumber(input) { return telecelError(input) === null; } function formatTelecel(input) { const d = normalizeTelecel(input); return d.length === 9 ? `+245 ${d.slice(0,2)} ${d.slice(2,5)} ${d.slice(5,7)} ${d.slice(7)}` : input; } /* ── Catalogue: Internet, Voz, Combo ── */ const BUNDLE_CATEGORIES = [ { id: "internet", label: "Internet", Icon: IconGlobe }, { id: "voz", label: "Voz", Icon: IconPhone }, { id: "combo", label: "Combo", Icon: IconBolt }, ]; const BUNDLES = [ { id: "net100", cat: "internet", kind: "Internet", title: "Internet Diário", vol: "70", unit: "MB", price: 100, ttVol: "140 MB", validity: "24 horas", tag: "bestseller", Icon: IconGlobe, includes: [{ Icon: IconGlobe, h: "70 MB de internet", s: "140 MB se pagares com TeleTaku" }] }, { id: "net1000", cat: "internet", kind: "Internet", title: "Internet Semanal", vol: "1,3", unit: "GB", price: 1000, ttVol: "3 GB", validity: "7 dias", tag: "recommended", Icon: IconGlobe, includes: [{ Icon: IconGlobe, h: "1,3 GB de internet", s: "3 GB se pagares com TeleTaku" }] }, { id: "voz200", cat: "voz", kind: "Voz", title: "Voz Ilimitada 24h", vol: "∞", unit: "MIN", price: 200, ttPrice: 150, validity: "24 horas", Icon: IconPhone, includes: [{ Icon: IconPhone, h: "Chamadas ilimitadas", s: "Para todas as redes" }] }, { id: "livre1000", cat: "combo", family: "Tele Livre", kind: "Combo", title: "Tele Livre 1.000", vol: "1", unit: "GB", price: 1000, minutes: 100, validity: "3 dias", Icon: IconBolt, includes: [{ Icon: IconPhone, h: "100 minutos", s: "Chamadas para todas as redes" }, { Icon: IconGlobe, h: "1 GB de internet", s: "Navegação livre" }] }, { id: "livre1500", cat: "combo", family: "Tele Livre", kind: "Combo", title: "Tele Livre 1.500", vol: "1,5", unit: "GB", price: 1500, minutes: 150, validity: "3 dias", Icon: IconBolt, includes: [{ Icon: IconPhone, h: "150 minutos", s: "Chamadas para todas as redes" }, { Icon: IconGlobe, h: "1,5 GB de internet", s: "Navegação livre" }] }, { id: "boss5000", cat: "combo", family: "Tele Boss", kind: "Combo", title: "Tele Boss 5.000", vol: "15", unit: "GB", price: 5000, calls: true, daily: "2,1 GB/dia", validity: "15 dias", tag: "hot", Icon: IconBolt, includes: [{ Icon: IconPhone, h: "Chamadas ilimitadas", s: "Para todas as redes" }, { Icon: IconGlobe, h: "15 GB de internet", s: "2,1 GB por dia" }] }, { id: "boss10000", cat: "combo", family: "Tele Boss", kind: "Combo", title: "Tele Boss 10.000", vol: "50", unit: "GB", price: 10000, calls: true, daily: "1,6 GB/dia", validity: "15 dias", tag: "bestvalue", Icon: IconBolt, includes: [{ Icon: IconPhone, h: "Chamadas ilimitadas", s: "Para todas as redes" }, { Icon: IconGlobe, h: "50 GB de internet", s: "1,6 GB por dia" }] }, ]; BUNDLES.forEach(b => { b.sub = b.cat === "internet" ? `Válido ${b.validity}` : b.cat === "voz" ? `Todas as redes · ${b.validity}` : b.calls ? `Chamadas ilimitadas · ${b.validity}` : `+${b.minutes} MIN · ${b.validity}`; b.perk = b.ttVol ? `${b.ttVol} com TeleTaku` : b.ttPrice ? `${fmtXof(b.ttPrice)} XOF com TeleTaku` : null; }); const UPSELL = { net100: "net1000", livre1000: "livre1500", boss5000: "boss10000", voz200: "livre1000" }; function getBundle(id) { return BUNDLES.find(b => b.id === id); } function bundlesByCat(cat) { return BUNDLES.filter(b => b.cat === cat); } function effective(b, method) { const tt = method === "teletaku"; return { price: tt && b.ttPrice ? b.ttPrice : b.price, vol: tt && b.ttVol ? b.ttVol : `${b.vol} ${b.unit}`.trim() }; } /* ── Payment sources for bundles: main balance or TeleTaku only ── */ const PAY_SOURCES = [ { id: "main", label: "Saldo principal", balance: 4520, logo: "main" }, { id: "teletaku", label: "TeleTaku", balance: 8450, logo: "telecel-money" }, ]; /* ── Shared widgets ── */ function PhoneInput({ value, onChange, autoFocus, onPick }) { const [touched, setTouched] = useState(false); const err = telecelError(value); const showErr = touched && normalizeTelecel(value).length > 0 && err; const ok = !err; return (