Podmiana logo i dodanie przesłania wyborów do formularza kontaktu

This commit is contained in:
dm
2025-12-15 11:57:57 +01:00
parent 6b5a913666
commit f68c9acae2
5 changed files with 204 additions and 0 deletions

View File

@@ -113,6 +113,8 @@ const form = data.form;
</div>
<div id="toast" class="f-toast"></div>
<input type="hidden" name="offerConfig" id="offerConfig" />
</section>
<!-- ReCaptcha v3 -->
@@ -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();
// ----------
});
</script>
</DefaultLayout>