- PRD: vollständige Produktspezifikation (5 Module, Scope, Akzeptanzkriterien) - ARCHITECTURE: Tech Stack, Ordnerstruktur, Multi-Tenancy, Push, Kosten - DATABASE_SCHEMA: Vollständiges SQL-Schema mit RLS Policies und Views - USER_STORIES: 40+ Stories nach Rolle (Admin, Mitglied, Azubi, Obermeister) - PERSONAS: 5 detaillierte Nutzerprofile mit Alltag, Zitaten und Erwartungen - BUSINESS_MODEL: Preistabellen, Unit Economics, Revenue-Projektionen, Distribution - ROADMAP: 6 Phasen, Sprint-Planung, Meilensteine und KPIs - COMPETITIVE_ANALYSIS: Wettbewerbsmatrix, USPs, Preispositionierung - API_DESIGN: Supabase Query Patterns, Edge Functions, Realtime Subscriptions - ONBOARDING_FLOWS: 7 User Flows von Setup bis Fehlerfall - GTM_STRATEGY: 3-Phasen-Vertrieb, Outreach-Sequenz, Einwandbehandlung - AZUBI_MODULE: Video-Feed, 1-Click-Apply, Chat, Berichtsheft, Quiz - DSGVO_KONZEPT: Rechtsgrundlagen, TOMs, AVV, Minderjährige, Incident Response - FEATURES_BACKLOG: 72 Features nach MoSCoW + Technische Schulden Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
90 lines
2.3 KiB
TypeScript
90 lines
2.3 KiB
TypeScript
import { z } from 'zod'
|
|
import { router, adminProcedure, publicProcedure } from '../trpc'
|
|
|
|
export const organizationsRouter = router({
|
|
/**
|
|
* Get own organization details
|
|
*/
|
|
me: adminProcedure.query(async ({ ctx }) => {
|
|
const org = await ctx.prisma.organization.findUniqueOrThrow({
|
|
where: { id: ctx.orgId },
|
|
})
|
|
return org
|
|
}),
|
|
|
|
/**
|
|
* Update org settings (admin only)
|
|
*/
|
|
update: adminProcedure
|
|
.input(
|
|
z.object({
|
|
name: z.string().min(3).optional(),
|
|
contactEmail: z.string().email().optional(),
|
|
primaryColor: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional(),
|
|
})
|
|
)
|
|
.mutation(async ({ ctx, input }) => {
|
|
const org = await ctx.prisma.organization.update({
|
|
where: { id: ctx.orgId },
|
|
data: input,
|
|
})
|
|
return org
|
|
}),
|
|
|
|
/**
|
|
* Accept AVV (Auftragsverarbeitungsvertrag)
|
|
*/
|
|
acceptAvv: adminProcedure.mutation(async ({ ctx }) => {
|
|
const org = await ctx.prisma.organization.update({
|
|
where: { id: ctx.orgId },
|
|
data: {
|
|
avvAccepted: true,
|
|
avvAcceptedAt: new Date(),
|
|
},
|
|
})
|
|
return org
|
|
}),
|
|
|
|
/**
|
|
* Dashboard stats
|
|
*/
|
|
stats: adminProcedure.query(async ({ ctx }) => {
|
|
const now = new Date()
|
|
const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000)
|
|
|
|
const [activeMembers, newsThisWeek, upcomingTermine, activeStellen] =
|
|
await Promise.all([
|
|
ctx.prisma.member.count({
|
|
where: { orgId: ctx.orgId, status: 'aktiv' },
|
|
}),
|
|
ctx.prisma.news.count({
|
|
where: {
|
|
orgId: ctx.orgId,
|
|
publishedAt: { gte: weekAgo, not: null },
|
|
},
|
|
}),
|
|
ctx.prisma.termin.count({
|
|
where: { orgId: ctx.orgId, datum: { gte: now } },
|
|
}),
|
|
ctx.prisma.stelle.count({
|
|
where: { orgId: ctx.orgId, aktiv: true },
|
|
}),
|
|
])
|
|
|
|
return { activeMembers, newsThisWeek, upcomingTermine, activeStellen }
|
|
}),
|
|
|
|
/**
|
|
* Public org info by slug (for mobile onboarding)
|
|
*/
|
|
bySlug: publicProcedure
|
|
.input(z.object({ slug: z.string() }))
|
|
.query(async ({ ctx, input }) => {
|
|
const org = await ctx.prisma.organization.findUnique({
|
|
where: { slug: input.slug },
|
|
select: { id: true, name: true, slug: true, primaryColor: true, logoUrl: true },
|
|
})
|
|
return org
|
|
}),
|
|
})
|