MCPcopy Create free account
hub / github.com/code100x/daily-code / TrackComponent

Function TrackComponent

apps/web/app/pdf/[...pdfId]/page.tsx:13–57  ·  view source on GitHub ↗
({ params }: { params: { pdfId: string[] } })

Source from the content-addressed store, hash-verified

11
12export default async function TrackComponent({ params }: { params: { pdfId: string[] } }) {
13 const trackId: string = params.pdfId[0] || "";
14 const problemId = params.pdfId[1];
15 let notionRecordMaps: any[] = [];
16 const session = await getServerSession(authOptions);
17 if (trackId === "43XrfL4n0LgSnTkSB4rO") {
18 redirect("/tracks/oAjvkeRNZThPMxZf4aX5");
19 }
20 const [problemDetails, trackDetails] = await Promise.all([getProblem(problemId || null), getTrack(trackId)]);
21
22 if (!problemId) {
23 return <RedirectToLastSolved trackId={trackId} />;
24 }
25
26 if (problemDetails?.notionDocId && trackDetails?.problems) {
27 notionRecordMaps = await Promise.all(
28 trackDetails.problems.map(
29 async (problem: any) => fetchNotionPage(notion, (await getProblem(problem.id))?.notionDocId!)
30 )
31 );
32 }
33
34 if (!session?.user) {
35 const downloadUrl = `/pdf/${trackId}/${problemId}`;
36 return redirect("/auth?redirectUrl=" + encodeURIComponent(downloadUrl));
37 }
38 if (trackDetails && problemDetails) {
39 return (
40 <div>
41 {trackDetails?.problems.map((problem: any, i: number) => (
42 <LessonView
43 isPdfRequested
44 track={trackDetails}
45 problem={{
46 ...problemDetails,
47 notionRecordMap: notionRecordMaps[i],
48 }}
49 key={i}
50 />
51 ))}
52 <Print />
53 </div>
54 );
55 }
56}

Callers

nothing calls this directly

Calls 3

getProblemFunction · 0.90
getTrackFunction · 0.90
fetchNotionPageFunction · 0.90

Tested by

no test coverage detected