Skip to content

Commit a5ed257

Browse files
committed
fix(academy): type safety fixes — null metadata fallbacks, returning() guard, exhaustive union, empty catch
1 parent 3e9c587 commit a5ed257

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

apps/sim/app/academy/(catalog)/certificate/[certificateNumber]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export async function generateMetadata({ params }: CertificatePageProps): Promis
1616
const certificate = await fetchCertificate(certificateNumber)
1717
if (!certificate) return { title: 'Certificate Not Found' }
1818
return {
19-
title: `${certificate.metadata?.courseTitle} — Certificate`,
20-
description: `Verified certificate of completion awarded to ${certificate.metadata?.recipientName}.`,
19+
title: `${certificate.metadata?.courseTitle ?? 'Certificate'} — Certificate`,
20+
description: `Verified certificate of completion awarded to ${certificate.metadata?.recipientName ?? 'a recipient'}.`,
2121
}
2222
}
2323

apps/sim/app/academy/[courseSlug]/[lessonSlug]/components/lesson-quiz.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ function scoreQuiz(questions: QuizQuestion[], answers: Answers, passingScore: nu
3131
correct =
3232
selected.length === q.correctIndices.length &&
3333
selected.every((v) => q.correctIndices.includes(v))
34+
} else {
35+
const _exhaustive: never = q
36+
void _exhaustive
3437
}
3538
return { correct, explanation: 'explanation' in q ? q.explanation : undefined }
3639
})

apps/sim/app/academy/components/lesson-video.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function resolveEmbedUrl(url: string): string | null {
4747
}
4848

4949
return null
50-
} catch {
50+
} catch (_e: unknown) {
5151
return null
5252
}
5353
}

apps/sim/app/api/academy/certificates/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export async function POST(req: NextRequest) {
115115
})
116116
.returning()
117117

118+
if (!certificate) {
119+
return NextResponse.json({ error: 'Failed to issue certificate' }, { status: 500 })
120+
}
121+
118122
logger.info('Certificate issued', {
119123
userId: session.user.id,
120124
courseId,

0 commit comments

Comments
 (0)