Skip to content

Commit de9bf36

Browse files
authored
Merge pull request #511 from zenithexe/fixing-download-pdf-option
fixed the download-pdf option issue
2 parents 7154708 + 3ce7439 commit de9bf36

File tree

7 files changed

+173
-23
lines changed

7 files changed

+173
-23
lines changed

apps/web/app/pdf/[...pdfId]/page.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
1515
redirect("/tracks/oAjvkeRNZThPMxZf4aX5");
1616
}
1717
const [problemDetails, trackDetails] = await Promise.all([getProblem(problemId || null), getTrack(trackId)]);
18-
1918
if (!problemId) {
2019
return <RedirectToLastSolved trackId={trackId} />;
2120
}
@@ -28,20 +27,20 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
2827
}
2928
if (trackDetails && problemDetails) {
3029
return (
31-
<div>
32-
{trackDetails?.problems.map((problem, i) => (
33-
<LessonView
34-
isPdfRequested={true}
35-
track={trackDetails}
36-
problem={{
37-
...problemDetails,
38-
notionRecordMap: notionRecordMaps[i],
39-
}}
40-
key={i}
41-
/>
42-
))}
43-
<Print />
44-
</div>
30+
<div>
31+
{trackDetails?.problems.map((problem, i) => (
32+
<LessonView
33+
isPdfRequested={true}
34+
track={trackDetails}
35+
problem={{
36+
...problemDetails,
37+
notionRecordMap: notionRecordMaps[i],
38+
}}
39+
key={i}
40+
/>
41+
))}
42+
<Print />
43+
</div>
4544
);
4645
}
4746
}

apps/web/app/tracks/[...trackIds]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default async function TrackComponent({ params }: { params: { trackIds: s
5353
<ScrollToTopWrapper>
5454
<LessonView
5555
showAppBar
56+
showPagination
5657
track={trackDetails}
5758
problem={{
5859
...problemDetails,

apps/web/components/Blog.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ export const Blog = ({
99
problem,
1010
track,
1111
showAppBar,
12+
showPagination,
1213
isPdfRequested,
13-
problemIndex
14+
problemIndex,
1415
}: {
1516
problem: Problem & { notionRecordMap: any };
1617
track: Track & { problems: Problem[] };
1718
showAppBar: Boolean;
19+
showPagination: Boolean;
1820
isPdfRequested?: Boolean;
19-
problemIndex: number
21+
problemIndex: number;
2022
}) => {
2123
const mounted = useMountStatus();
2224

@@ -27,12 +29,14 @@ export const Blog = ({
2729
}
2830

2931
return (
30-
<div>
31-
{showAppBar && <BlogAppbar problem={problem} track={track} problemIndex={problemIndex}/>}
32+
<div className="break-after-page">
33+
{showAppBar && <BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />}
3234
<NotionRenderer recordMap={problem.notionRecordMap} />
33-
<div className="justify-center pt-2">
34-
<Pagination allProblems={track.problems} track={track} problemIndex={problemIndex} />
35-
</div>
35+
{showPagination && (
36+
<div className="justify-center pt-2">
37+
<Pagination allProblems={track.problems} track={track} problemIndex={problemIndex} />
38+
</div>
39+
)}
3640
</div>
3741
);
3842
};

apps/web/components/LessonView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const LessonView = async ({
3636
problem,
3737
track,
3838
showAppBar,
39+
showPagination,
3940
isPdfRequested,
4041
}: {
4142
problem: Problem & { notionRecordMap: any } & {
@@ -48,6 +49,7 @@ export const LessonView = async ({
4849
};
4950
track: Track & { problems: Problem[] };
5051
showAppBar?: Boolean;
52+
showPagination?:Boolean;
5153
isPdfRequested?: Boolean;
5254
}) => {
5355
const session = await getServerSession(authOptions);
@@ -81,6 +83,7 @@ export const LessonView = async ({
8183
problem={problem}
8284
track={track}
8385
showAppBar={!!showAppBar}
86+
showPagination={!!showPagination}
8487
isPdfRequested={isPdfRequested}
8588
problemIndex={problemIndex}
8689
/>

apps/web/components/PageToggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Link from "next/link";
77

88
export function PageToggle({ allProblems, track }: { allProblems: Problem[]; track: Track & { problems: Problem[] } }) {
99
const { trackIds }: { trackIds: string[] } = useParams();
10-
const currentTrack = trackIds.join("/");
10+
const currentTrack = trackIds?.join("/");
1111

1212
return (
1313
<DropdownMenu>

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "dailycode",
33
"private": true,
4+
"prisma": {
5+
"seed": "ts-node packages\\db\\prisma\\seed.ts"
6+
},
47
"scripts": {
58
"build": "turbo build",
69
"dev": "turbo dev",

0 commit comments

Comments
 (0)