Podmiana logo i dodanie przesłania wyborów do formularza kontaktu
This commit is contained in:
BIN
src/assets/logo-1.webp
Normal file
BIN
src/assets/logo-1.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB |
@@ -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 (
|
return (
|
||||||
<div class="f-modal-overlay" onClick={onClose}>
|
<div class="f-modal-overlay" onClick={onClose}>
|
||||||
<button
|
<button
|
||||||
@@ -668,7 +799,17 @@ export default function JamboxAddonsModal({
|
|||||||
<div class="f-summary-total">
|
<div class="f-summary-total">
|
||||||
<span>Łącznie</span>
|
<span>Łącznie</span>
|
||||||
<span>{money(totalMonthly)} {cenaOpis}</span>
|
<span>{money(totalMonthly)} {cenaOpis}</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="/kontakt"
|
||||||
|
class="btn btn-primary w-full mt-4"
|
||||||
|
onClick={() => saveOfferToLocalStorage()}
|
||||||
|
>
|
||||||
|
Wyślij zapytanie z tym wyborem
|
||||||
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</SectionAccordion>
|
</SectionAccordion>
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ const form = data.form;
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="toast" class="f-toast"></div>
|
<div id="toast" class="f-toast"></div>
|
||||||
|
|
||||||
|
<input type="hidden" name="offerConfig" id="offerConfig" />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ReCaptcha v3 -->
|
<!-- ReCaptcha v3 -->
|
||||||
@@ -177,6 +179,67 @@ const form = data.form;
|
|||||||
|
|
||||||
setTimeout(() => toast.classList.remove("visible"), 3000);
|
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>
|
</script>
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user