From 878a530bd7ad08eecd4f9238b2f10782516312c5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Oct 2026 07:05:44 +0000 Subject: [PATCH] Terminplaner: Warnung im Dialog, wenn K16 mit den Unterlagen nicht rausging Co-Authored-By: Claude Opus 5.5 --- src/components/customer/CustomerFunktionen.jsx | 8 ++++---- src/lib/funktionenView.js | 6 ++++++ tests/unit/funktionenView.test.mjs | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/customer/CustomerFunktionen.jsx b/src/components/customer/CustomerFunktionen.jsx index 7ea749f..b8bb5e9 100644 --- a/src/components/customer/CustomerFunktionen.jsx +++ b/src/components/customer/CustomerFunktionen.jsx @@ -6,7 +6,7 @@ import { copyText } from '../CopyableCredential' import { getFunktionen, setFeature, getTermineAnleitung } from '../../lib/teamApi' import { FUNKTIONEN, ZUSTAND, AKTION_LABEL, funktionOf, aktionen, mergeFunktion, siteKeyOf, abgeschaltetText, - hindernisText, panelModell, anleitungOffen, textformNoetig, textformAnsicht, textformBereit, + hindernisText, panelModell, anleitungOffen, textformNoetig, textformAnsicht, textformBereit, speicherStatus, } from '../../lib/funktionenView' import { CHANNELS, channelLabel } from '../../lib/analyseView' import { berlinYmd } from '../../lib/format' @@ -186,17 +186,17 @@ export default function CustomerFunktionen({ customerId }) { setStatus(null) try { const mitTextform = textformNoetig(key, action, termine) - const { projects: changed } = await setFeature(customerId, key, { + const antwort = await setFeature(customerId, key, { projectId, action, note: note.trim(), ...(mitTextform ? { textformDate: textform.date, textformChannel: textform.channel } : {}), }) // Die Antwort enthaelt das ganze Projekt; uebernommen wird nur die geaenderte Funktion - const updated = changed?.[0] + const updated = antwort?.projects?.[0] if (updated) setProjects((list) => mergeFunktion(list, updated.projectId, key, updated)) setConfirm(null) setNote('') setTextform(LEERE_TEXTFORM) - setStatus({ ok: true, text: 'Gespeichert.' }) + setStatus(speicherStatus(antwort)) } catch (err) { setConfirm(null) setStatus({ ok: false, text: err.message }) diff --git a/src/lib/funktionenView.js b/src/lib/funktionenView.js index 1005c64..0d77daa 100644 --- a/src/lib/funktionenView.js +++ b/src/lib/funktionenView.js @@ -223,3 +223,9 @@ export function featureBody({ projectId, action, note, textformDate, textformCha } return body } + +/** K16 (Unterlagen an den Kunden) ging beim Aktivieren nicht raus: Antwort mit warnung: true (Portal, funktionenAdmin). */ +export const K16_WARNUNG = 'Eingeschaltet, aber die E-Mail mit den Unterlagen (K16) ging nicht raus. Bitte die Leistungsbeschreibung und den AVV von Hand an den Kunden senden.' + +/** Statuszeile nach dem Speichern einer Aktion: Warnung statt "Gespeichert.", wenn die Antwort warnung: true traegt. */ +export const speicherStatus = (antwort) => (antwort?.warnung === true ? { ok: false, text: K16_WARNUNG } : { ok: true, text: 'Gespeichert.' }) diff --git a/tests/unit/funktionenView.test.mjs b/tests/unit/funktionenView.test.mjs index 131d6f1..841080b 100644 --- a/tests/unit/funktionenView.test.mjs +++ b/tests/unit/funktionenView.test.mjs @@ -23,6 +23,8 @@ const { textformAnsicht, textformBereit, featureBody, + speicherStatus, + K16_WARNUNG, } = await loadModule('src/lib/funktionenView.js') test('FUNKTIONEN: News und Terminplaner mit den Bestätigungstexten', () => { @@ -460,3 +462,11 @@ test('featureBody: Aktivieren mit Textform trägt Datum und Weg, sonst bleibt de 'halbe Angaben gehen nicht mit', ) }) + +test('speicherStatus: warnung true (K16 nicht gesendet) wird zur Warnung, sonst "Gespeichert."', () => { + assert.deepEqual(speicherStatus({ projects: [], warnung: true }), { ok: false, text: K16_WARNUNG }) + assert.match(K16_WARNUNG, /K16/) + assert.match(K16_WARNUNG, /von Hand/) + assert.deepEqual(speicherStatus({ projects: [] }), { ok: true, text: 'Gespeichert.' }) + assert.deepEqual(speicherStatus(undefined), { ok: true, text: 'Gespeichert.' }) +})