Funktionen-Reiter: Abschaltgrund und Löschdatum des Terminplaners
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78bc99a73b
commit
6f0371283e
3 files changed
+58
-2
No files matched your search
@@ -4,7 +4,7 @@ import { FaCheck, FaCopy, FaSpinner } from 'react-icons/fa6'
|
||||
import { Card, Badge, Button, EmptyState } from '../ui'
|
||||
import { copyText } from '../CopyableCredential'
|
||||
import { getFunktionen, setFeature } from '../../lib/teamApi'
|
||||
import { FUNKTIONEN, ZUSTAND, funktionOf, aktionen, mergeFunktion, siteKeyOf } from '../../lib/funktionenView'
|
||||
import { FUNKTIONEN, ZUSTAND, funktionOf, aktionen, mergeFunktion, siteKeyOf, abgeschaltetText } from '../../lib/funktionenView'
|
||||
import '../../styles/admin-areas.css'
|
||||
|
||||
// Reiter "Funktionen": News-Pinnwand und Terminplaner je Projekt an/aus wie im frueheren Admin-Panel (Kundenliste, Zeile "Funktionen")
|
||||
@@ -94,6 +94,7 @@ export default function CustomerFunktionen({ customerId }) {
|
||||
<span>{f.label}</span>
|
||||
<span>
|
||||
<Badge tone={tone}>{label}</Badge>
|
||||
{abgeschaltetText(feature) && <><br /><span className="area-muted">{abgeschaltetText(feature)}</span></>}
|
||||
{feature.adminNote && <><br /><span className="area-muted" title={feature.adminNote}>{short(feature.adminNote)}</span></>}
|
||||
{siteKeyOf(feature, f.key) && <><br /><SiteKey value={siteKeyOf(feature, f.key)} /></>}
|
||||
</span>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Kunden-Reiter "Funktionen": Register der Funktionen je Projekt (News, Terminplaner), Aktionen je Zustand und
|
||||
// Einarbeiten der Portal-Antwort. Rein, unter Node testbar.
|
||||
|
||||
import { fmtYmd } from './format'
|
||||
|
||||
/** Funktionen in Anzeigereihenfolge; key = Schluessel im Portal (features[key], POST /funktionen/:customerId/:key). */
|
||||
export const FUNKTIONEN = [
|
||||
{
|
||||
@@ -30,6 +32,25 @@ export const ZUSTAND = {
|
||||
disabled: ['muted', 'Abgeschaltet'],
|
||||
}
|
||||
|
||||
/** Abschaltgrund (Portal: features[key].disabledReason) -> Zusatz hinter "Abgeschaltet"; unbekannte Gruende gelten als "ohne Grund". */
|
||||
const ABGESCHALTET_GRUND = {
|
||||
abo_ende: ' (Abo beendet)',
|
||||
abo_ende_vor_einrichtung: ' (Abo endete vor Einrichtung, Erstattung prüfen)',
|
||||
team: ' (Team)',
|
||||
kunde_geloescht: ' (Kunde gelöscht)',
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeile unter dem Abzeichen "Abgeschaltet": Grund und, falls das Portal ein Loeschdatum nennt (feature.loeschungAm, Berliner
|
||||
* Kalendertag; nur Terminplaner), "Löschung am TT.MM.JJJJ". Ausserhalb von "disabled" ''.
|
||||
*/
|
||||
export function abgeschaltetText(feature) {
|
||||
if (feature?.state !== 'disabled') return ''
|
||||
const grund = Object.prototype.hasOwnProperty.call(ABGESCHALTET_GRUND, feature.disabledReason) ? ABGESCHALTET_GRUND[feature.disabledReason] : ''
|
||||
const loeschung = feature.loeschungAm ? `, Löschung am ${fmtYmd(feature.loeschungAm)}` : ''
|
||||
return `Abgeschaltet${grund}${loeschung}`
|
||||
}
|
||||
|
||||
/** Ansicht einer Funktion im Projekt (Portal: project.features[key]); ohne Eintrag gilt "off". */
|
||||
export const funktionOf = (project, key) => project?.features?.[key] || { state: 'off' }
|
||||
|
||||
|
||||
Reference in new issue
Block a user