v1.3.1: Fix symbol loading, DEL key, SOMA/Pendenzen in rapport, improved onboarding, org settings tab, logo upload

This commit is contained in:
Pepe Ziberi
2026-02-25 22:28:10 +01:00
parent 5917fa88ad
commit 708bdf6be0
17 changed files with 570 additions and 55 deletions

View File

@@ -17,9 +17,13 @@ export async function GET(req: NextRequest) {
id: true,
name: true,
slug: true,
description: true,
contactEmail: true,
contactPhone: true,
address: true,
logoUrl: true,
plan: true,
subscriptionStatus: true,
contactEmail: true,
privacyAccepted: true,
privacyAcceptedAt: true,
adminAccessAccepted: true,
@@ -39,3 +43,35 @@ export async function GET(req: NextRequest) {
return NextResponse.json({ error: 'Serverfehler' }, { status: 500 })
}
}
export async function PATCH(req: NextRequest) {
try {
const user = await getSession()
if (!user) return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 401 })
if (user.role !== 'TENANT_ADMIN') return NextResponse.json({ error: 'Nur Admin' }, { status: 403 })
if (!user.tenantId) return NextResponse.json({ error: 'Kein Mandant' }, { status: 400 })
const body = await req.json()
const { name, description, contactEmail, contactPhone, address } = body
if (!name || !name.trim()) {
return NextResponse.json({ error: 'Name darf nicht leer sein' }, { status: 400 })
}
const updated = await (prisma as any).tenant.update({
where: { id: user.tenantId },
data: {
name: name.trim(),
description: description || null,
contactEmail: contactEmail || null,
contactPhone: contactPhone || null,
address: address || null,
},
})
return NextResponse.json({ tenant: updated })
} catch (error: any) {
console.error('[Tenant Info PATCH] Error:', error?.message)
return NextResponse.json({ error: 'Serverfehler' }, { status: 500 })
}
}

View File

@@ -0,0 +1,77 @@
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/db'
import { getSession } from '@/lib/auth'
import { uploadFile, deleteFile } from '@/lib/minio'
export async function POST(req: NextRequest) {
try {
const user = await getSession()
if (!user || user.role !== 'TENANT_ADMIN') {
return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 403 })
}
if (!user.tenantId) {
return NextResponse.json({ error: 'Kein Mandant' }, { status: 400 })
}
const formData = await req.formData()
const file = formData.get('logo') as File
if (!file) {
return NextResponse.json({ error: 'Keine Datei hochgeladen' }, { status: 400 })
}
const validTypes = ['image/png', 'image/jpeg', 'image/svg+xml', 'image/webp']
if (!validTypes.includes(file.type)) {
return NextResponse.json({ error: 'Ungültiges Dateiformat. Erlaubt: PNG, JPEG, SVG, WebP' }, { status: 400 })
}
if (file.size > 2 * 1024 * 1024) {
return NextResponse.json({ error: 'Datei zu gross (max. 2 MB)' }, { status: 400 })
}
const buffer = Buffer.from(await file.arrayBuffer())
const ext = file.name.split('.').pop() || 'png'
const fileKey = `logos/tenant-${user.tenantId}.${ext}`
await uploadFile(fileKey, buffer, file.type)
const logoServeUrl = `/api/admin/tenants/${user.tenantId}/logo/serve`
await (prisma as any).tenant.update({
where: { id: user.tenantId },
data: { logoFileKey: fileKey, logoUrl: logoServeUrl },
})
return NextResponse.json({ logoUrl: logoServeUrl })
} catch (error) {
console.error('Tenant logo upload error:', error)
return NextResponse.json({ error: 'Upload fehlgeschlagen' }, { status: 500 })
}
}
export async function DELETE(req: NextRequest) {
try {
const user = await getSession()
if (!user || user.role !== 'TENANT_ADMIN') {
return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 403 })
}
if (!user.tenantId) {
return NextResponse.json({ error: 'Kein Mandant' }, { status: 400 })
}
const tenant = await (prisma as any).tenant.findUnique({ where: { id: user.tenantId } })
if (tenant?.logoFileKey) {
try {
await deleteFile(tenant.logoFileKey)
} catch {}
}
await (prisma as any).tenant.update({
where: { id: user.tenantId },
data: { logoUrl: null, logoFileKey: null },
})
return NextResponse.json({ success: true })
} catch (error) {
console.error('Tenant logo delete error:', error)
return NextResponse.json({ error: 'Löschen fehlgeschlagen' }, { status: 500 })
}
}