News: im Abo-Modell Einschalten statt Bestellen, Projektwahl über dataset
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6f70a502a
commit
1cabab2826
2 files changed
+118
-6
No files matched your search
+35
-6
@@ -471,10 +471,12 @@ export async function initFunktionen(root) {
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- News --- */
|
||||
export async function initNews(root, { projectId } = {}) {
|
||||
export async function initNews(root, { projectId, einschalten } = {}) {
|
||||
if (!root) return
|
||||
if (projectId) selection.projectId = projectId
|
||||
const { projects = [], setupEstimate = '', consentText = '', features, ustHinweis } = await request('/api/funktionen')
|
||||
const wunsch = projectId || root.dataset?.wunschProjekt || '' // die Kachel legt ihr Projekt im Behälter ab (wie bei Terminplaner, Webshop, Buchungen)
|
||||
if (root.dataset) delete root.dataset.wunschProjekt
|
||||
if (wunsch) selection.projectId = wunsch
|
||||
const { projects = [], setupEstimate = '', consentText = '', features, ustHinweis, modell } = await request('/api/funktionen')
|
||||
if (!projects.length) {
|
||||
root.innerHTML = '<div class="kb-panel kb-empty">Noch keine Website-Projekte zugewiesen.</div>'
|
||||
return
|
||||
@@ -507,11 +509,38 @@ export async function initNews(root, { projectId } = {}) {
|
||||
? '<p class="fn-thanks" role="status">Danke! Sobald die Zahlung da ist, legen wir los.</p>'
|
||||
: ''
|
||||
if (feature.state === 'active') renderEditor(stage, project)
|
||||
else if (isSetup(feature.state)) stage.innerHTML = thanks + statusCard(feature, setupEstimate)
|
||||
else if (isSetup(feature.state)) stage.innerHTML = thanks + statusCard(feature, setupEstimate, modell === 'abo')
|
||||
else if (feature.state === 'disabled') stage.innerHTML = '<div class="kb-panel"><h3>News-Pinnwand ist abgeschaltet</h3><p>Für diese Website ist die Pinnwand im Moment nicht aktiv. <button type="button" class="kb-link" data-view="chat">Schreib uns im Chat</button>, dann klären wir das.</p></div>'
|
||||
else if (modell === 'abo') renderBookingAbo(stage, project, { einschalten, neuLaden: () => initNews(root, { einschalten }) })
|
||||
else renderBooking(stage, project, { setupEstimate, offer: { ...newsOffer(features, consentText), ustHinweis: textOr(ustHinweis, UST_HINWEIS) }, thanks })
|
||||
}
|
||||
|
||||
/**
|
||||
* Abo-Modell (modell === 'abo' in GET /api/funktionen), Zustand off: statt der Buchungsseite nur der Platz, in den der Ablauf des Einschaltens
|
||||
* zeichnet (einschalten aus den Init-Optionen, die Hülle gibt ihn durch). Kein Preis, kein Haken, kein Checkout. onFertig lädt die Pinnwand
|
||||
* einmal neu. Ohne die Funktion oder wenn sie scheitert, steht Text E4 im Platz.
|
||||
*/
|
||||
function renderBookingAbo(stage, project, { einschalten, neuLaden }) {
|
||||
stage.innerHTML = '<div id="news-einschalten"></div>'
|
||||
const platz = stage.querySelector('#news-einschalten')
|
||||
const fehlt = () => { platz.textContent = 'Das Einschalten ist gerade nicht verfügbar. Bitte lade die Seite neu oder schreib uns im Chat.' }
|
||||
if (typeof einschalten !== 'function') {
|
||||
fehlt()
|
||||
return
|
||||
}
|
||||
let fertig = false
|
||||
const onFertig = () => {
|
||||
if (fertig) return
|
||||
fertig = true
|
||||
Promise.resolve().then(neuLaden).catch(() => {})
|
||||
}
|
||||
try {
|
||||
Promise.resolve(einschalten(platz, { key: 'news', projectId: project.projectId, viewAs: false, onFertig })).catch(fehlt)
|
||||
} catch {
|
||||
fehlt()
|
||||
}
|
||||
}
|
||||
|
||||
function renderBooking(stage, project, { setupEstimate, offer, thanks }) {
|
||||
stage.innerHTML = `
|
||||
${thanks}
|
||||
@@ -551,10 +580,10 @@ function renderBooking(stage, project, { setupEstimate, offer, thanks }) {
|
||||
})
|
||||
}
|
||||
|
||||
function statusCard(feature, setupEstimate) {
|
||||
function statusCard(feature, setupEstimate, abo = false) {
|
||||
const rows = [
|
||||
feature.ticketWoid ? `<div><dt>Ticketnummer</dt><dd>#${esc(feature.ticketWoid)}</dd></div>` : '',
|
||||
feature.orderedAt ? `<div><dt>Bestellt am</dt><dd>${esc(fmtDay(feature.orderedAt))}</dd></div>` : '',
|
||||
feature.orderedAt ? `<div><dt>${abo ? 'Eingeschaltet am' : 'Bestellt am'}</dt><dd>${esc(fmtDay(feature.orderedAt))}</dd></div>` : '',
|
||||
setupEstimate ? `<div><dt>Zeiteinschätzung</dt><dd>${esc(setupEstimate)}</dd></div>` : '',
|
||||
].join('')
|
||||
const invoice = safeUrl(feature.invoiceUrl)
|
||||
|
||||
Reference in new issue
Block a user