Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the download-pdf option issue #511

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions apps/web/app/pdf/[...pdfId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
redirect("/tracks/oAjvkeRNZThPMxZf4aX5");
}
const [problemDetails, trackDetails] = await Promise.all([getProblem(problemId || null), getTrack(trackId)]);

if (!problemId) {
return <RedirectToLastSolved trackId={trackId} />;
}
Expand All @@ -28,20 +27,20 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
}
if (trackDetails && problemDetails) {
return (
<div>
{trackDetails?.problems.map((problem, i) => (
<LessonView
isPdfRequested={true}
track={trackDetails}
problem={{
...problemDetails,
notionRecordMap: notionRecordMaps[i],
}}
key={i}
/>
))}
<Print />
</div>
<div>
{trackDetails?.problems.map((problem, i) => (
<LessonView
isPdfRequested={true}
track={trackDetails}
problem={{
...problemDetails,
notionRecordMap: notionRecordMaps[i],
}}
key={i}
/>
))}
<Print />
</div>
);
}
}
1 change: 1 addition & 0 deletions apps/web/app/tracks/[...trackIds]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default async function TrackComponent({ params }: { params: { trackIds: s
<ScrollToTopWrapper>
<LessonView
showAppBar
showPagination
track={trackDetails}
problem={{
...problemDetails,
Expand Down
18 changes: 11 additions & 7 deletions apps/web/components/Blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ export const Blog = ({
problem,
track,
showAppBar,
showPagination,
isPdfRequested,
problemIndex
problemIndex,
}: {
problem: Problem & { notionRecordMap: any };
track: Track & { problems: Problem[] };
showAppBar: Boolean;
showPagination: Boolean;
isPdfRequested?: Boolean;
problemIndex: number
problemIndex: number;
}) => {
const mounted = useMountStatus();

Expand All @@ -27,12 +29,14 @@ export const Blog = ({
}

return (
<div>
{showAppBar && <BlogAppbar problem={problem} track={track} problemIndex={problemIndex}/>}
<div className="break-after-page">
{showAppBar && <BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />}
<NotionRenderer recordMap={problem.notionRecordMap} />
<div className="justify-center pt-2">
<Pagination allProblems={track.problems} track={track} problemIndex={problemIndex} />
</div>
{showPagination && (
<div className="justify-center pt-2">
<Pagination allProblems={track.problems} track={track} problemIndex={problemIndex} />
</div>
)}
</div>
);
};
3 changes: 3 additions & 0 deletions apps/web/components/LessonView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const LessonView = async ({
problem,
track,
showAppBar,
showPagination,
isPdfRequested,
}: {
problem: Problem & { notionRecordMap: any } & {
Expand All @@ -48,6 +49,7 @@ export const LessonView = async ({
};
track: Track & { problems: Problem[] };
showAppBar?: Boolean;
showPagination?:Boolean;
isPdfRequested?: Boolean;
}) => {
const session = await getServerSession(authOptions);
Expand Down Expand Up @@ -81,6 +83,7 @@ export const LessonView = async ({
problem={problem}
track={track}
showAppBar={!!showAppBar}
showPagination={!!showPagination}
isPdfRequested={isPdfRequested}
problemIndex={problemIndex}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/PageToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Link from "next/link";

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

return (
<DropdownMenu>
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "dailycode",
"private": true,
"prisma": {
"seed": "ts-node packages\\db\\prisma\\seed.ts"
},
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
Expand Down
Loading