Podmiana logo i dodanie przesłania wyborów do formularza kontaktu
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user