v1.2.0: Symbol-Verwaltung, SOMA-Admin, Light Mode Farbsystem, Onboarding-Tour, Credit-Link
This commit is contained in:
@@ -55,6 +55,9 @@ import {
|
||||
X,
|
||||
BookOpen,
|
||||
Download,
|
||||
AlertTriangle,
|
||||
GripVertical,
|
||||
LayoutGrid,
|
||||
} from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import { TenantDetailDialog } from '@/components/admin/tenant-detail-dialog'
|
||||
@@ -223,6 +226,19 @@ export default function AdminPage() {
|
||||
// Hose Settings (Tenant Admin)
|
||||
const [isHoseSettingsOpen, setIsHoseSettingsOpen] = useState(false)
|
||||
|
||||
// SOMA Templates (Tenant Admin)
|
||||
const [somaTemplates, setSomaTemplates] = useState<{ id: string; label: string; sortOrder: number; isActive: boolean }[]>([])
|
||||
const [newSomaLabel, setNewSomaLabel] = useState('')
|
||||
const [somaLoading, setSomaLoading] = useState(false)
|
||||
|
||||
// Symbol Management (Tenant Admin)
|
||||
const [tenantSymbols, setTenantSymbols] = useState<{ id: string; name: string; fileKey: string; mimeType: string; iconType: string; categoryId: string | null; categoryName: string; isActive: boolean }[]>([])
|
||||
const [symbolSearch, setSymbolSearch] = useState('')
|
||||
const [symbolCatFilter, setSymbolCatFilter] = useState('all')
|
||||
const [symbolViewTab, setSymbolViewTab] = useState<'library' | 'active'>('library')
|
||||
const [selectedSymbolIds, setSelectedSymbolIds] = useState<Set<string>>(new Set())
|
||||
const [symbolsLoading, setSymbolsLoading] = useState(false)
|
||||
|
||||
// Redirect to login if not authenticated, or to app if not admin
|
||||
useEffect(() => {
|
||||
if (authLoading) return
|
||||
@@ -246,6 +262,38 @@ export default function AdminPage() {
|
||||
.catch(() => {})
|
||||
}, [tenant?.id])
|
||||
|
||||
// Load SOMA templates (TENANT_ADMIN)
|
||||
const fetchSomaTemplates = async () => {
|
||||
setSomaLoading(true)
|
||||
try {
|
||||
const res = await fetch('/api/tenant/soma-templates')
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
setSomaTemplates(data.templates || [])
|
||||
}
|
||||
} catch {}
|
||||
setSomaLoading(false)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (user?.role === 'TENANT_ADMIN') fetchSomaTemplates()
|
||||
}, [user?.role])
|
||||
|
||||
// Load tenant symbols (TENANT_ADMIN)
|
||||
const fetchTenantSymbols = async () => {
|
||||
setSymbolsLoading(true)
|
||||
try {
|
||||
const res = await fetch('/api/tenant/symbols')
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
setTenantSymbols(data.symbols || [])
|
||||
}
|
||||
} catch {}
|
||||
setSymbolsLoading(false)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (user?.role === 'TENANT_ADMIN') fetchTenantSymbols()
|
||||
}, [user?.role])
|
||||
|
||||
// Load global dictionary (SERVER_ADMIN)
|
||||
const fetchGlobalDict = async () => {
|
||||
try {
|
||||
@@ -742,7 +790,7 @@ export default function AdminPage() {
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
) : user?.role === 'TENANT_ADMIN' ? (
|
||||
<TabsList className="grid w-full grid-cols-6 max-w-3xl">
|
||||
<TabsList className="grid w-full grid-cols-7 max-w-4xl">
|
||||
<TabsTrigger value="users" className="gap-2">
|
||||
<Users className="w-4 h-4" />
|
||||
Benutzer
|
||||
@@ -767,66 +815,225 @@ export default function AdminPage() {
|
||||
<Layers className="w-4 h-4" />
|
||||
Kategorien
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="soma" className="gap-2">
|
||||
<AlertTriangle className="w-4 h-4" />
|
||||
SOMA
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
) : null}
|
||||
|
||||
{/* ===== ICONS TAB ===== */}
|
||||
<TabsContent value="icons" className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<Select value={selectedCategory} onValueChange={setSelectedCategory}>
|
||||
<SelectTrigger className="w-[200px]">
|
||||
<SelectValue placeholder="Kategorie filtern" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">Alle Kategorien</SelectItem>
|
||||
{categories.map(cat => (
|
||||
<SelectItem key={cat.id} value={cat.id}>{cat.name}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<span className="text-sm text-muted-foreground">{filteredIcons.length} Symbol(e)</span>
|
||||
</div>
|
||||
<Button onClick={() => setIsUploadDialogOpen(true)}>
|
||||
<Upload className="w-4 h-4 mr-2" />
|
||||
Icons hochladen
|
||||
</Button>
|
||||
</div>
|
||||
{user?.role === 'TENANT_ADMIN' ? (() => {
|
||||
// --- Tenant Symbol Management UI ---
|
||||
const symbolCategories = [...new Set(tenantSymbols.map(s => s.categoryName))].sort()
|
||||
const viewSymbols = tenantSymbols
|
||||
.filter(s => symbolViewTab === 'active' ? s.isActive : true)
|
||||
.filter(s => symbolCatFilter === 'all' || s.categoryName === symbolCatFilter)
|
||||
.filter(s => !symbolSearch || s.name.toLowerCase().includes(symbolSearch.toLowerCase()))
|
||||
const grouped = viewSymbols.reduce<Record<string, typeof viewSymbols>>((acc, s) => {
|
||||
const key = s.categoryName
|
||||
if (!acc[key]) acc[key] = []
|
||||
acc[key].push(s)
|
||||
return acc
|
||||
}, {})
|
||||
const toggleSelect = (id: string) => {
|
||||
setSelectedSymbolIds(prev => {
|
||||
const next = new Set(prev)
|
||||
next.has(id) ? next.delete(id) : next.add(id)
|
||||
return next
|
||||
})
|
||||
}
|
||||
const bulkUpdate = async (ids: string[], isActive: boolean) => {
|
||||
try {
|
||||
await fetch('/api/tenant/symbols', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ updates: ids.map(iconId => ({ iconId, isActive })) }),
|
||||
})
|
||||
setSelectedSymbolIds(new Set())
|
||||
fetchTenantSymbols()
|
||||
toast({ title: isActive ? 'Symbole aktiviert' : 'Symbole deaktiviert' })
|
||||
} catch {}
|
||||
}
|
||||
|
||||
{filteredIcons.length === 0 ? (
|
||||
<div className="border-2 border-dashed rounded-lg p-12 text-center">
|
||||
<Image className="w-12 h-12 mx-auto text-muted-foreground mb-4" />
|
||||
<h3 className="font-medium text-lg mb-2">Keine Symbole vorhanden</h3>
|
||||
<p className="text-muted-foreground mb-4">Laden Sie eigene Symbole hoch (PNG, SVG, JPEG)</p>
|
||||
<Button onClick={() => setIsUploadDialogOpen(true)}>
|
||||
<Upload className="w-4 h-4 mr-2" />
|
||||
Jetzt hochladen
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-4">
|
||||
{filteredIcons.map(icon => (
|
||||
<div key={icon.id} className={`relative group border rounded-lg p-3 transition-all hover:shadow-md ${!icon.isActive ? 'opacity-50' : ''}`}>
|
||||
<div className="aspect-square flex items-center justify-center mb-2 bg-muted rounded">
|
||||
<img src={`/api/icons/${icon.id}/image`} alt={icon.name} className="w-12 h-12 object-contain" />
|
||||
</div>
|
||||
<p className="text-xs text-center truncate font-medium" title={icon.name}>{icon.name}</p>
|
||||
<p className="text-[10px] text-center text-muted-foreground truncate">{icon.category.name}</p>
|
||||
{icon.isSystem && <p className="text-[10px] text-center text-blue-500">System</p>}
|
||||
<div className="absolute inset-0 bg-background/80 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1 rounded-lg">
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => handleEditIcon(icon)}>
|
||||
<Pencil className="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => handleToggleIconActive(icon)}>
|
||||
{icon.isActive ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" onClick={() => handleDeleteIcon(icon.id)}>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
return (
|
||||
<>
|
||||
{/* Header: View tabs + search + filter */}
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="flex rounded-lg border overflow-hidden">
|
||||
<button
|
||||
className={`px-3 py-1.5 text-sm font-medium transition-colors ${symbolViewTab === 'library' ? 'bg-primary text-primary-foreground' : 'hover:bg-muted'}`}
|
||||
onClick={() => { setSymbolViewTab('library'); setSelectedSymbolIds(new Set()) }}
|
||||
>
|
||||
<LayoutGrid className="w-3.5 h-3.5 inline mr-1.5" />Bibliothek
|
||||
</button>
|
||||
<button
|
||||
className={`px-3 py-1.5 text-sm font-medium transition-colors ${symbolViewTab === 'active' ? 'bg-primary text-primary-foreground' : 'hover:bg-muted'}`}
|
||||
onClick={() => { setSymbolViewTab('active'); setSelectedSymbolIds(new Set()) }}
|
||||
>
|
||||
<Eye className="w-3.5 h-3.5 inline mr-1.5" />Aktive
|
||||
</button>
|
||||
</div>
|
||||
<Input
|
||||
placeholder="Symbole suchen..."
|
||||
value={symbolSearch}
|
||||
onChange={e => setSymbolSearch(e.target.value)}
|
||||
className="w-48"
|
||||
/>
|
||||
<Select value={symbolCatFilter} onValueChange={setSymbolCatFilter}>
|
||||
<SelectTrigger className="w-[180px]">
|
||||
<SelectValue placeholder="Kategorie" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">Alle Kategorien</SelectItem>
|
||||
{symbolCategories.map(cat => (
|
||||
<SelectItem key={cat} value={cat}>{cat}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<span className="text-sm text-muted-foreground ml-auto">
|
||||
{tenantSymbols.filter(s => s.isActive).length} aktiv / {tenantSymbols.length} gesamt
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Bulk category action */}
|
||||
{symbolCatFilter !== 'all' && (
|
||||
<div className="flex gap-2">
|
||||
<Button size="sm" variant="outline" onClick={() => {
|
||||
const ids = tenantSymbols.filter(s => s.categoryName === symbolCatFilter).map(s => s.id)
|
||||
bulkUpdate(ids, true)
|
||||
}}>
|
||||
<Eye className="w-3.5 h-3.5 mr-1" /> Alle «{symbolCatFilter}» aktivieren
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => {
|
||||
const ids = tenantSymbols.filter(s => s.categoryName === symbolCatFilter).map(s => s.id)
|
||||
bulkUpdate(ids, false)
|
||||
}}>
|
||||
<EyeOff className="w-3.5 h-3.5 mr-1" /> Alle «{symbolCatFilter}» deaktivieren
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Selection action bar */}
|
||||
{selectedSymbolIds.size > 0 && (
|
||||
<div className="flex items-center gap-3 bg-foreground text-background px-4 py-2.5 rounded-lg">
|
||||
<span className="text-sm font-medium">{selectedSymbolIds.size} ausgewählt</span>
|
||||
<Button size="sm" variant="secondary" onClick={() => bulkUpdate([...selectedSymbolIds], true)}>
|
||||
<Eye className="w-3.5 h-3.5 mr-1" /> Aktivieren
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" onClick={() => bulkUpdate([...selectedSymbolIds], false)}>
|
||||
<EyeOff className="w-3.5 h-3.5 mr-1" /> Deaktivieren
|
||||
</Button>
|
||||
<button className="ml-auto text-sm opacity-70 hover:opacity-100" onClick={() => setSelectedSymbolIds(new Set())}>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Symbol grid grouped by category */}
|
||||
{symbolsLoading ? (
|
||||
<div className="flex items-center gap-2 py-8 justify-center text-muted-foreground">
|
||||
<Loader2 className="w-5 h-5 animate-spin" /> Symbole laden...
|
||||
</div>
|
||||
) : viewSymbols.length === 0 ? (
|
||||
<div className="border-2 border-dashed rounded-lg p-12 text-center text-muted-foreground">
|
||||
{symbolViewTab === 'active' ? 'Keine aktiven Symbole.' : 'Keine Symbole gefunden.'}
|
||||
</div>
|
||||
) : (
|
||||
Object.entries(grouped).sort(([a], [b]) => a.localeCompare(b)).map(([catName, syms]) => (
|
||||
<div key={catName}>
|
||||
<h4 className="font-semibold text-sm mb-2 flex items-center gap-2">
|
||||
{catName}
|
||||
<span className="text-xs text-muted-foreground font-normal">({syms.length})</span>
|
||||
</h4>
|
||||
<div className="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10 gap-2 mb-4">
|
||||
{syms.map(sym => {
|
||||
const selected = selectedSymbolIds.has(sym.id)
|
||||
return (
|
||||
<div
|
||||
key={sym.id}
|
||||
onClick={() => toggleSelect(sym.id)}
|
||||
className={`relative cursor-pointer border-2 rounded-lg p-2 transition-all hover:shadow-sm ${
|
||||
selected ? 'border-blue-500 bg-blue-50 dark:bg-blue-950/30' :
|
||||
sym.isActive ? 'border-transparent hover:border-border' : 'border-transparent opacity-40'
|
||||
}`}
|
||||
>
|
||||
<div className="aspect-square flex items-center justify-center mb-1 bg-muted/50 rounded">
|
||||
<img src={`/api/icons/${sym.id}/image`} alt={sym.name} className="w-10 h-10 object-contain" />
|
||||
</div>
|
||||
<p className="text-[10px] text-center truncate" title={sym.name}>{sym.name}</p>
|
||||
{/* Status dot */}
|
||||
<div className={`absolute top-1.5 right-1.5 w-2 h-2 rounded-full ${sym.isActive ? 'bg-green-500' : 'bg-gray-300'}`} />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</>
|
||||
)
|
||||
})() : (
|
||||
/* --- SERVER_ADMIN: existing icon management --- */
|
||||
<>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<Select value={selectedCategory} onValueChange={setSelectedCategory}>
|
||||
<SelectTrigger className="w-[200px]">
|
||||
<SelectValue placeholder="Kategorie filtern" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">Alle Kategorien</SelectItem>
|
||||
{categories.map(cat => (
|
||||
<SelectItem key={cat.id} value={cat.id}>{cat.name}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<span className="text-sm text-muted-foreground">{filteredIcons.length} Symbol(e)</span>
|
||||
</div>
|
||||
<Button onClick={() => setIsUploadDialogOpen(true)}>
|
||||
<Upload className="w-4 h-4 mr-2" />
|
||||
Icons hochladen
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{filteredIcons.length === 0 ? (
|
||||
<div className="border-2 border-dashed rounded-lg p-12 text-center">
|
||||
<Image className="w-12 h-12 mx-auto text-muted-foreground mb-4" />
|
||||
<h3 className="font-medium text-lg mb-2">Keine Symbole vorhanden</h3>
|
||||
<p className="text-muted-foreground mb-4">Laden Sie eigene Symbole hoch (PNG, SVG, JPEG)</p>
|
||||
<Button onClick={() => setIsUploadDialogOpen(true)}>
|
||||
<Upload className="w-4 h-4 mr-2" />
|
||||
Jetzt hochladen
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-4">
|
||||
{filteredIcons.map(icon => (
|
||||
<div key={icon.id} className={`relative group border rounded-lg p-3 transition-all hover:shadow-md ${!icon.isActive ? 'opacity-50' : ''}`}>
|
||||
<div className="aspect-square flex items-center justify-center mb-2 bg-muted rounded">
|
||||
<img src={`/api/icons/${icon.id}/image`} alt={icon.name} className="w-12 h-12 object-contain" />
|
||||
</div>
|
||||
<p className="text-xs text-center truncate font-medium" title={icon.name}>{icon.name}</p>
|
||||
<p className="text-[10px] text-center text-muted-foreground truncate">{icon.category.name}</p>
|
||||
{icon.isSystem && <p className="text-[10px] text-center text-blue-500">System</p>}
|
||||
<div className="absolute inset-0 bg-background/80 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1 rounded-lg">
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => handleEditIcon(icon)}>
|
||||
<Pencil className="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => handleToggleIconActive(icon)}>
|
||||
{icon.isActive ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" onClick={() => handleDeleteIcon(icon.id)}>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
@@ -1623,6 +1830,14 @@ export default function AdminPage() {
|
||||
Zur Spendenseite
|
||||
</a>
|
||||
</Button>
|
||||
<div className="mt-6 pt-4 border-t">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
mit ♥ von Pepe —{' '}
|
||||
<a href="/" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">
|
||||
Über mich & Lageplan
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="border rounded-lg p-6">
|
||||
<h3 className="font-semibold text-lg mb-4">Dein Mandant</h3>
|
||||
@@ -1644,6 +1859,130 @@ export default function AdminPage() {
|
||||
</TabsContent>
|
||||
)}
|
||||
|
||||
{/* ===== SOMA TAB (TENANT_ADMIN) ===== */}
|
||||
{user?.role === 'TENANT_ADMIN' && (
|
||||
<TabsContent value="soma" className="space-y-6">
|
||||
<div className="border rounded-lg p-6">
|
||||
<h3 className="font-semibold text-lg mb-2 flex items-center gap-2">
|
||||
<AlertTriangle className="w-5 h-5 text-red-600" />
|
||||
SOMA-Checkliste verwalten
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground mb-4">
|
||||
Definiere die Sofortmassnahmen (SOMA), die bei jedem neuen Einsatz als Checkliste erscheinen.
|
||||
Bestehende Einsätze werden nicht verändert.
|
||||
</p>
|
||||
|
||||
{somaLoading ? (
|
||||
<div className="flex items-center gap-2 py-4 text-muted-foreground">
|
||||
<Loader2 className="w-4 h-4 animate-spin" /> Laden...
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{/* Template list */}
|
||||
<div className="border rounded-lg divide-y">
|
||||
{somaTemplates.length === 0 ? (
|
||||
<div className="px-4 py-6 text-center text-muted-foreground text-sm">
|
||||
Keine SOMA-Vorlagen definiert. Neue Einsätze starten ohne Checkliste.
|
||||
</div>
|
||||
) : somaTemplates.map((tpl, idx) => (
|
||||
<div key={tpl.id} className={`flex items-center gap-3 px-4 py-2.5 ${!tpl.isActive ? 'opacity-50' : ''}`}>
|
||||
<GripVertical className="w-4 h-4 text-muted-foreground/40 shrink-0" />
|
||||
<span className="text-sm font-medium flex-1">{tpl.label}</span>
|
||||
<span className="text-xs text-muted-foreground">#{idx + 1}</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 px-2"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await fetch('/api/tenant/soma-templates', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ updates: [{ id: tpl.id, isActive: !tpl.isActive }] }),
|
||||
})
|
||||
fetchSomaTemplates()
|
||||
} catch {}
|
||||
}}
|
||||
>
|
||||
{tpl.isActive ? <Eye className="w-3.5 h-3.5" /> : <EyeOff className="w-3.5 h-3.5" />}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 px-2 text-destructive hover:text-destructive"
|
||||
onClick={async () => {
|
||||
if (!confirm(`"${tpl.label}" wirklich löschen?`)) return
|
||||
try {
|
||||
await fetch('/api/tenant/soma-templates', {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ id: tpl.id }),
|
||||
})
|
||||
fetchSomaTemplates()
|
||||
toast({ title: 'SOMA-Vorlage gelöscht' })
|
||||
} catch {}
|
||||
}}
|
||||
>
|
||||
<Trash2 className="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Add new */}
|
||||
<div className="flex gap-2 mt-4">
|
||||
<Input
|
||||
placeholder="Neue Sofortmassnahme..."
|
||||
value={newSomaLabel}
|
||||
onChange={e => setNewSomaLabel(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter' && newSomaLabel.trim()) {
|
||||
e.preventDefault()
|
||||
;(async () => {
|
||||
try {
|
||||
await fetch('/api/tenant/soma-templates', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ label: newSomaLabel.trim(), sortOrder: somaTemplates.length }),
|
||||
})
|
||||
setNewSomaLabel('')
|
||||
fetchSomaTemplates()
|
||||
toast({ title: 'SOMA-Vorlage hinzugefügt' })
|
||||
} catch {}
|
||||
})()
|
||||
}
|
||||
}}
|
||||
className="flex-1"
|
||||
/>
|
||||
<Button
|
||||
disabled={!newSomaLabel.trim()}
|
||||
onClick={async () => {
|
||||
try {
|
||||
await fetch('/api/tenant/soma-templates', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ label: newSomaLabel.trim(), sortOrder: somaTemplates.length }),
|
||||
})
|
||||
setNewSomaLabel('')
|
||||
fetchSomaTemplates()
|
||||
toast({ title: 'SOMA-Vorlage hinzugefügt' })
|
||||
} catch {}
|
||||
}}
|
||||
>
|
||||
<Plus className="w-4 h-4 mr-1" /> Hinzufügen
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground mt-3">
|
||||
{somaTemplates.filter(t => t.isActive).length} aktiv / {somaTemplates.length} gesamt —
|
||||
Nur aktive Vorlagen erscheinen bei neuen Einsätzen.
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
)}
|
||||
|
||||
{/* Upgrades tab removed — plan management simplified */}
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user