43 lines
1.7 KiB
JavaScript
43 lines
1.7 KiB
JavaScript
import { config } from '../../config.js'
|
|
|
|
/**
|
|
* Terminplaner-Schalter (Funktionsschluessel 'termine'): TERMINE_ENABLED = off (Vorgabe) | pilot | on.
|
|
* Liest config.termine bei jedem Aufruf. Bei off laufen keine Termine-Jobs und keine Termine-Abfragen.
|
|
*/
|
|
|
|
/** 'off' | 'pilot' | 'on'; alles andere (leer, unbekannt) gilt als off. */
|
|
export function termineModus() {
|
|
const mode = config.termine.mode
|
|
return mode === 'pilot' || mode === 'on' ? mode : 'off'
|
|
}
|
|
|
|
export function termineAus() {
|
|
return termineModus() === 'off'
|
|
}
|
|
|
|
/**
|
|
* Darf dieser Kunde den Terminplaner nutzen? pilot = nur Adressen aus TERMINE_PILOT_EMAILS ('*' = alle; eine leere
|
|
* Liste laesst niemanden durch); on = alle Kunden (TP1: pilot ohne E-Mail-Filter); off = niemand.
|
|
*/
|
|
export function termineFuerKunde(email) {
|
|
const modus = termineModus()
|
|
if (modus === 'off') return false
|
|
if (modus === 'on') return true
|
|
const erlaubt = config.termine.pilotEmails
|
|
if (erlaubt.includes('*')) return true
|
|
const adresse = String(email || '').trim().toLowerCase()
|
|
return adresse !== '' && erlaubt.includes(adresse)
|
|
}
|
|
|
|
/**
|
|
* Verlangt die Aktivierung durch das Team (WOMS, ohne Bestellung) die Zustimmung des Kunden in Textform? Nur im Modus on und nur,
|
|
* wenn die Adresse des Kunden nicht in TERMINE_PILOT_EMAILS steht. '*' ist keine Pilotadresse und befreit niemanden. In off und
|
|
* pilot bleibt die Aktivierung wie in TP1 (Pilotbetrieb, Mitarbeiter und Kunde sprechen direkt miteinander).
|
|
*/
|
|
export function termineTextformNoetig(email) {
|
|
if (termineModus() !== 'on') return false
|
|
const adresse = String(email || '').trim().toLowerCase()
|
|
if (adresse === '' || adresse === '*') return true
|
|
return !config.termine.pilotEmails.includes(adresse)
|
|
}
|