Buchungskalender: Abgleich – art monteurzimmer, Zurückziehen-409 mit Meldung, Tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54442a4682
commit
f01e6def59
2 files changed
+32
-4
No files matched your search
@@ -6,11 +6,13 @@
|
||||
import { allgemeinerFehler, datumText, feld, h, hakenFeld, request, setzeFehler, zeigeFehler } from './shop-dom.js'
|
||||
import { fehlerFuerFormular } from './buchungen-fehler.js'
|
||||
|
||||
export const ARTEN = [['ferienwohnung', 'Ferienwohnung oder Ferienhaus'], ['monteur', 'Monteurwohnung'], ['pension', 'Pension oder Gästezimmer'], ['sonstiges', 'Sonstiges']]
|
||||
export const ARTEN = [['ferienwohnung', 'Ferienwohnung oder Ferienhaus'], ['monteurzimmer', 'Monteurwohnung'], ['pension', 'Pension oder Gästezimmer'], ['sonstiges', 'Sonstiges']]
|
||||
export const PORTALE = [['booking', 'Booking.com'], ['airbnb', 'Airbnb']]
|
||||
export const KALENDER_PREIS = '199 €'
|
||||
|
||||
const text = (wert) => (typeof wert === 'string' ? wert : '')
|
||||
/** Der Server liest 'monteur' als Alias, gibt es aber in der Anfrage so zurueck; die Auswahl kennt nur 'monteurzimmer'. */
|
||||
const artWert = (a) => (a === 'monteur' ? 'monteurzimmer' : a)
|
||||
const labelVon = (liste, key) => liste.find(([k]) => k === key)?.[1] || ''
|
||||
const enc = encodeURIComponent
|
||||
|
||||
@@ -19,7 +21,7 @@ export function anfrageListe(a) {
|
||||
const s = a && typeof a === 'object' ? a : {}
|
||||
const portale = (Array.isArray(s.portale) ? s.portale : []).map((p) => labelVon(PORTALE, p)).filter(Boolean).join(', ')
|
||||
const zeilen = [
|
||||
['Art der Unterkunft', labelVon(ARTEN, s.art)],
|
||||
['Art der Unterkunft', labelVon(ARTEN, artWert(s.art))],
|
||||
['Anzahl Einheiten', Number.isInteger(s.einheiten) ? String(s.einheiten) : ''],
|
||||
['Portale', portale || 'keine'],
|
||||
['Nachricht', text(s.nachricht)],
|
||||
@@ -31,7 +33,7 @@ export function anfrageListe(a) {
|
||||
export function renderAnfrageFormular(root, { projectId, vorgabe = null, preis = KALENDER_PREIS, nachSenden } = {}) {
|
||||
const v = vorgabe && typeof vorgabe === 'object' ? vorgabe : {}
|
||||
const art = h('select', null, [h('option', { value: '' }, 'Bitte wählen …'), ...ARTEN.map(([w, n]) => h('option', { value: w }, n))])
|
||||
art.value = ARTEN.some(([k]) => k === v.art) ? v.art : ''
|
||||
art.value = ARTEN.some(([k]) => k === artWert(v.art)) ? artWert(v.art) : ''
|
||||
const einheiten = h('input', { type: 'text', inputmode: 'numeric', maxlength: 3, autocomplete: 'off' })
|
||||
einheiten.value = Number.isInteger(v.einheiten) ? String(v.einheiten) : ''
|
||||
const portale = PORTALE.map(([wert]) => {
|
||||
@@ -116,7 +118,7 @@ export function anfrageKarte(ansicht, { projectId, neu, neuLaden } = {}) {
|
||||
return
|
||||
} catch (err) {
|
||||
meldung.textContent = err.message
|
||||
if (err?.status === 409 && typeof neuLaden === 'function') { try { await neuLaden() } catch { /* Meldung bleibt */ } return }
|
||||
if (err?.status === 409 && typeof neuLaden === 'function') { try { await neuLaden({ meldung: err.message }) } catch { /* Meldung bleibt */ } return }
|
||||
}
|
||||
aktion.disabled = false
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user