Files
nextstep/src/lib/db/workspace-access.ts
Gemini Agent a32c609830 Initial commit: Next Step health management app
A calm, reliable app to help manage appointments, medications, and notes
for chemo patients and their families.

Features:
- Today dashboard with next appointment and medications due
- Medication tracking with multiple schedule types (fixed times, interval, weekdays, PRN)
- One-tap dose logging with 5-minute undo window
- Questions for doctor tracking
- Family sharing with workspace model and invite links
- Offline-first with IndexedDB and sync
- Docker Compose deployment with Tailscale Funnel support

Tech stack:
- Next.js 14 (App Router) + TypeScript + Tailwind CSS
- PostgreSQL + Prisma
- Argon2 password hashing + session cookies
- Dexie.js for IndexedDB

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 23:16:45 +00:00

25 lines
635 B
TypeScript

import { prisma } from './prisma'
import type { WorkspaceRole } from '@prisma/client'
export async function checkWorkspaceAccess(
workspaceId: string,
userId: string,
requiredRoles: WorkspaceRole[] = ['OWNER', 'EDITOR', 'VIEWER']
): Promise<{ role: WorkspaceRole } | null> {
const member = await prisma.workspaceMember.findUnique({
where: {
workspaceId_userId: { workspaceId, userId },
},
})
if (!member || !requiredRoles.includes(member.role)) {
return null
}
return { role: member.role }
}
export function canEdit(role: WorkspaceRole): boolean {
return role === 'OWNER' || role === 'EDITOR'
}