refactor: Add explicit types for workspace and project member checks

This commit is contained in:
Yusuf İpek
2026-02-07 17:28:46 +03:00
parent d01c2247b5
commit 49c3ac61ea
7 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ export default async function WorkspacesPage() {
{/* Workspaces Grid */} {/* Workspaces Grid */}
{workspaces.length > 0 ? ( {workspaces.length > 0 ? (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3"> <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}`}> <Link key={workspace.id} href={`/workspaces/${workspace.id}`}>
<Card className="h-full transition-colors hover:bg-accent/50 cursor-pointer"> <Card className="h-full transition-colors hover:bg-accent/50 cursor-pointer">
<CardHeader> <CardHeader>
+1 -1
View File
@@ -83,7 +83,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
// Check access // Check access
const isPublic = project.visibility === ProjectVisibility.PUBLIC; const isPublic = project.visibility === ProjectVisibility.PUBLIC;
const isOwner = session?.user?.id === project.ownerId; 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 // Check workspace membership
let isWorkspaceMember = false; let isWorkspaceMember = false;
@@ -106,7 +106,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
const nextVersionNumber = (video.versions[0]?.versionNumber || 0) + 1; const nextVersionNumber = (video.versions[0]?.versionNumber || 0) + 1;
// Use transaction to handle active flag // 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, deactivate all other versions
if (setActive) { if (setActive) {
await tx.videoVersion.updateMany({ await tx.videoVersion.updateMany({
+1 -1
View File
@@ -65,7 +65,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
// Check access // Check access
const isOwner = session?.user?.id === workspace.ownerId; 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) { if (!isOwner && !isMember) {
return apiErrors.forbidden('Access denied'); return apiErrors.forbidden('Access denied');
+3 -3
View File
@@ -45,7 +45,7 @@ export async function collectVideoVoiceUrls(videoId: string): Promise<string[]>
}, },
select: { voiceUrl: true }, 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 }, 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 }, 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[];
} }
/** /**
+1
View File
@@ -9,6 +9,7 @@
"start": "next start", "start": "next start",
"lint": "eslint", "lint": "eslint",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"postinstall": "prisma generate",
"db:generate": "prisma generate", "db:generate": "prisma generate",
"db:push": "prisma db push", "db:push": "prisma db push",
"db:migrate": "prisma migrate deploy", "db:migrate": "prisma migrate deploy",
+1 -1
View File
@@ -30,5 +30,5 @@
".next/dev/types/**/*.ts", ".next/dev/types/**/*.ts",
"**/*.mts" "**/*.mts"
], ],
"exclude": ["node_modules"] "exclude": ["node_modules", "prisma/seed.ts"]
} }