diff --git a/src/assets/logo-1.webp b/src/assets/logo-1.webp new file mode 100644 index 0000000..4b283d7 Binary files /dev/null and b/src/assets/logo-1.webp differ diff --git a/src/assets/logo.webp b/src/assets/logo.webp index 4b283d7..913e7ee 100644 Binary files a/src/assets/logo.webp and b/src/assets/logo.webp differ diff --git a/src/assets/logo2.webp b/src/assets/logo2.webp deleted file mode 100644 index f0433c3..0000000 Binary files a/src/assets/logo2.webp and /dev/null differ diff --git a/src/islands/jambox/JamboxAddonsModalCompact.jsx b/src/islands/jambox/JamboxAddonsModalCompact.jsx index f0b7e83..ea75747 100644 --- a/src/islands/jambox/JamboxAddonsModalCompact.jsx +++ b/src/islands/jambox/JamboxAddonsModalCompact.jsx @@ -412,6 +412,137 @@ export default function JamboxAddonsModal({ ); }; + // --------- + const LS_KEY = "fuz_offer_config_v1"; + +function buildOfferPayload() { + const phone = selectedPhoneId + ? phonePlans.find((p) => String(p.id) === String(selectedPhoneId)) + : null; + + const decoder = selectedDecoderId + ? decodersList.find((d) => String(d.id) === String(selectedDecoderId)) + : null; + + const tvChosen = tvAddonsVisible + .map((a) => { + const qty = Number(selectedQty[a.id] || 0); + if (qty <= 0) return null; + + const termPricing = hasTvTermPricing(a, pkg); + const term = tvTerm[a.id] || "12m"; + const unit = getAddonUnitPrice(a, pkg, termPricing ? term : null); + + return { + id: a.id, + nazwa: a.nazwa, + qty, + term: termPricing ? term : null, + unit, + }; + }) + .filter(Boolean); + + const addonsChosen = addonsList + .map((a) => { + const qty = Number(selectedQty[a.id] || 0); + if (qty <= 0) return null; + + const unit = getAddonUnitPrice(a, pkg, null); + return { id: a.id, nazwa: a.nazwa, qty, unit }; + }) + .filter(Boolean); + + return { + createdAt: new Date().toISOString(), + pkg: { id: pkg?.id ?? null, name: pkg?.name ?? "", price: basePrice }, + phone: phone ? { id: phone.id, name: phone.name, price: phone.price_monthly } : null, + decoder: decoder ? { id: decoder.id, name: decoder.nazwa, price: decoder.cena } : null, + tvAddons: tvChosen, + addons: addonsChosen, + totals: { + base: basePrice, + phone: phonePrice, + decoder: decoderPrice, + tv: tvAddonsPrice, + addons: addonsOnlyPrice, + total: totalMonthly, + currencyLabel: cenaOpis, + }, + }; +} + +function saveOfferToLocalStorage() { + try { + const payload = buildOfferPayload(); + localStorage.setItem(LS_KEY, JSON.stringify(payload)); + } catch {} +} + +//-- dopisane +function moneyWithLabel(v) { + return `${money(v)} ${cenaOpis}`; +} + +function buildOfferMessage(payload) { + const lines = []; + + // nagłówek + lines.push(`Wybrana oferta: ${payload?.pkg?.name || "—"}`); + lines.push(""); + + // ✅ WSZYSTKIE linie jak w podsumowaniu + lines.push(`Pakiet: ${moneyWithLabel(payload?.totals?.base ?? 0)}`); + lines.push(`Telefon: ${payload?.phone ? moneyWithLabel(payload.totals.phone) : "—"}`); + lines.push(`Dekoder: ${payload?.decoder ? moneyWithLabel(payload.totals.decoder) : "—"}`); + lines.push(`Dodatki TV: ${payload?.tvAddons?.length ? moneyWithLabel(payload.totals.tv) : "—"}`); + lines.push(`Dodatkowe usługi: ${payload?.addons?.length ? moneyWithLabel(payload.totals.addons) : "—"}`); + lines.push(`Łącznie: ${moneyWithLabel(payload?.totals?.total ?? 0)}`); + + // szczegóły (pozycje) + if (payload?.phone) { + lines.push(""); + lines.push(`Telefon: ${payload.phone.name} (${moneyWithLabel(payload.phone.price)})`); + } + + if (payload?.decoder) { + lines.push(""); + lines.push(`Dekoder: ${payload.decoder.name} (${moneyWithLabel(payload.decoder.price)})`); + } + + if (Array.isArray(payload?.tvAddons) && payload.tvAddons.length) { + lines.push(""); + lines.push("Pakiety dodatkowe TV:"); + for (const it of payload.tvAddons) { + const termTxt = it.term ? `, ${it.term}` : ""; + lines.push( + `- ${it.nazwa} x${it.qty}${termTxt} @ ${moneyWithLabel(it.unit)}` + ); + } + } + + if (Array.isArray(payload?.addons) && payload.addons.length) { + lines.push(""); + lines.push("Dodatkowe usługi:"); + for (const it of payload.addons) { + lines.push(`- ${it.nazwa} x${it.qty} @ ${moneyWithLabel(it.unit)}`); + } + } + + return lines.join("\n"); +} + +function saveOfferToLocalStorage() { + try { + const payload = buildOfferPayload(); + payload.message = buildOfferMessage(payload); // ✅ gotowy tekst + localStorage.setItem(LS_KEY, JSON.stringify(payload)); + } catch {} +} + + + // --------- + return (
+ + saveOfferToLocalStorage()} +> + Wyślij zapytanie z tym wyborem + + diff --git a/src/pages/kontakt/index.astro b/src/pages/kontakt/index.astro index c71ffba..47af885 100644 --- a/src/pages/kontakt/index.astro +++ b/src/pages/kontakt/index.astro @@ -113,6 +113,8 @@ const form = data.form; + + @@ -177,6 +179,67 @@ const form = data.form; setTimeout(() => toast.classList.remove("visible"), 3000); } + + // ---------- + const LS_KEY = "fuz_offer_config_v1"; + +function formatOfferSummary(o) { + if (!o || !o.pkg) return ""; + + const lines = []; + lines.push(`Wybrana oferta: ${o.pkg.name} (${o.totals?.base ?? 0} ${o.totals?.currencyLabel ?? ""})`); + + if (o.decoder) lines.push(`Dekoder: ${o.decoder.name} (+${o.decoder.price} ${o.totals?.currencyLabel ?? ""})`); + if (o.phone) lines.push(`Telefon: ${o.phone.name} (+${o.phone.price} ${o.totals?.currencyLabel ?? ""})`); + + if (Array.isArray(o.tvAddons) && o.tvAddons.length) { + lines.push("Pakiety TV:"); + o.tvAddons.forEach((x) => { + const term = x.term ? `, ${x.term}` : ""; + lines.push(`- ${x.nazwa} x${x.qty} (${x.unit} ${o.totals?.currencyLabel ?? ""}${term})`); + }); + } + + if (Array.isArray(o.addons) && o.addons.length) { + lines.push("Dodatki:"); + o.addons.forEach((x) => + lines.push(`- ${x.nazwa} x${x.qty} (${x.unit} ${o.totals?.currencyLabel ?? ""})`), + ); + } + + lines.push(`RAZEM: ${o.totals?.total ?? 0} ${o.totals?.currencyLabel ?? ""}`); + return lines.join("\n"); +} + +function hydrateOfferIntoForm() { + try { + const raw = localStorage.getItem(LS_KEY); + if (!raw) return; + + const payload = JSON.parse(raw); + const msg = document.querySelector('textarea[name="message"]'); + const subject = document.querySelector('input[name="subject"]'); + + const offerText = + typeof payload?.message === "string" && payload.message.trim() + ? payload.message + : null; + + if (!offerText) return; + + if (subject && !subject.value) { + subject.value = `Zapytanie: ${payload?.pkg?.name || "Oferta"}`; + } + + if (msg) { + msg.value = (msg.value ? msg.value + "\n\n" : "") + offerText; + } + } catch {} +} + +hydrateOfferIntoForm(); + + // ---------- });