mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
refactor: Add explicit types for workspace and project member checks
This commit is contained in:
@@ -66,7 +66,7 @@ export default async function WorkspacesPage() {
|
||||
{/* Workspaces Grid */}
|
||||
{workspaces.length > 0 ? (
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{workspaces.map((workspace) => (
|
||||
{workspaces.map((workspace: typeof workspaces[number]) => (
|
||||
<Link key={workspace.id} href={`/workspaces/${workspace.id}`}>
|
||||
<Card className="h-full transition-colors hover:bg-accent/50 cursor-pointer">
|
||||
<CardHeader>
|
||||
|
||||
@@ -83,7 +83,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
|
||||
// Check access
|
||||
const isPublic = project.visibility === ProjectVisibility.PUBLIC;
|
||||
const isOwner = session?.user?.id === project.ownerId;
|
||||
const isMember = project.members.some(m => m.userId === session?.user?.id);
|
||||
const isMember = project.members.some((m: { userId: string }) => m.userId === session?.user?.id);
|
||||
|
||||
// Check workspace membership
|
||||
let isWorkspaceMember = false;
|
||||
|
||||
@@ -106,7 +106,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
||||
const nextVersionNumber = (video.versions[0]?.versionNumber || 0) + 1;
|
||||
|
||||
// Use transaction to handle active flag
|
||||
const version = await db.$transaction(async (tx) => {
|
||||
const version = await db.$transaction(async (tx: Parameters<Parameters<typeof db.$transaction>[0]>[0]) => {
|
||||
// If setActive, deactivate all other versions
|
||||
if (setActive) {
|
||||
await tx.videoVersion.updateMany({
|
||||
|
||||
@@ -65,7 +65,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
|
||||
|
||||
// Check access
|
||||
const isOwner = session?.user?.id === workspace.ownerId;
|
||||
const isMember = workspace.members.some(m => m.userId === session?.user?.id);
|
||||
const isMember = workspace.members.some((m: { userId: string }) => m.userId === session?.user?.id);
|
||||
|
||||
if (!isOwner && !isMember) {
|
||||
return apiErrors.forbidden('Access denied');
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@ export async function collectVideoVoiceUrls(videoId: string): Promise<string[]>
|
||||
},
|
||||
select: { voiceUrl: true },
|
||||
});
|
||||
return comments.map((c) => c.voiceUrl).filter(Boolean) as string[];
|
||||
return comments.map((c: { voiceUrl: string | null }) => c.voiceUrl).filter(Boolean) as string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ export async function collectProjectVoiceUrls(projectId: string): Promise<string
|
||||
},
|
||||
select: { voiceUrl: true },
|
||||
});
|
||||
return comments.map((c) => c.voiceUrl).filter(Boolean) as string[];
|
||||
return comments.map((c: { voiceUrl: string | null }) => c.voiceUrl).filter(Boolean) as string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ export async function collectWorkspaceVoiceUrls(workspaceId: string): Promise<st
|
||||
},
|
||||
select: { voiceUrl: true },
|
||||
});
|
||||
return comments.map((c) => c.voiceUrl).filter(Boolean) as string[];
|
||||
return comments.map((c: { voiceUrl: string | null }) => c.voiceUrl).filter(Boolean) as string[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"start": "next start",
|
||||
"lint": "eslint",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"postinstall": "prisma generate",
|
||||
"db:generate": "prisma generate",
|
||||
"db:push": "prisma db push",
|
||||
"db:migrate": "prisma migrate deploy",
|
||||
|
||||
+1
-1
@@ -30,5 +30,5 @@
|
||||
".next/dev/types/**/*.ts",
|
||||
"**/*.mts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["node_modules", "prisma/seed.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user