v1.2.0: Symbol-Verwaltung, SOMA-Admin, Light Mode Farbsystem, Onboarding-Tour, Credit-Link
This commit is contained in:
@@ -24,10 +24,17 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
|
||||
if (existing.length > 0) {
|
||||
return NextResponse.json(existing)
|
||||
}
|
||||
const templates = await (prisma as any).journalCheckTemplate.findMany({
|
||||
where: { isActive: true },
|
||||
// Prefer tenant-specific templates; fall back to global (tenantId=null) if none exist
|
||||
let templates = await (prisma as any).journalCheckTemplate.findMany({
|
||||
where: { isActive: true, tenantId: user.tenantId || null },
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
})
|
||||
if (templates.length === 0 && user.tenantId) {
|
||||
templates = await (prisma as any).journalCheckTemplate.findMany({
|
||||
where: { isActive: true, tenantId: null },
|
||||
orderBy: { sortOrder: 'asc' },
|
||||
})
|
||||
}
|
||||
const items = await Promise.all(
|
||||
templates.map((tpl: any, i: number) =>
|
||||
(prisma as any).journalCheckItem.create({
|
||||
|
||||
Reference in New Issue
Block a user