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

feat-602: Added leagacy mode button on Blog Page #603

Merged
merged 2 commits into from
Aug 30, 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
7 changes: 4 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"singleQuote": false,
"printWidth":120,
"printWidth": 120,
"bracketSpacing": true,
"tabWidth": 2,
"trailingComma": "es5",
"semi": true
}
"semi": true,
"plugins": ["prettier-plugin-tailwindcss"]
}
32 changes: 17 additions & 15 deletions apps/web/app/pdf/[...pdfId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
if (problemDetails?.notionDocId && trackDetails?.problems) {
// notionRecordMaps = await notion.getPage(problemDetails.notionDocId);
notionRecordMaps = await Promise.all(
trackDetails.problems.map(async (problem: any) => await notion.getPage((await getProblem(problem.id))?.notionDocId!))
trackDetails.problems.map(
async (problem: any) => await notion.getPage((await getProblem(problem.id))?.notionDocId!)
)
);
}

Expand All @@ -36,20 +38,20 @@ export default async function TrackComponent({ params }: { params: { pdfId: stri
}
if (trackDetails && problemDetails) {
return (
<div>
{trackDetails?.problems.map((problem: any, i: number) => (
<LessonView
isPdfRequested={true}
track={trackDetails}
problem={{
...problemDetails,
notionRecordMap: notionRecordMaps[i],
}}
key={i}
/>
))}
<Print />
</div>
<div>
{trackDetails?.problems.map((problem: any, i: number) => (
<LessonView
isPdfRequested
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 @@ -87,6 +87,7 @@ export default async function TrackComponent({ params }: { params: { trackIds: s
return (
<LessonView
showAppBar
showPagination
track={trackDetails}
problem={{
...problemDetails,
Expand Down
45 changes: 33 additions & 12 deletions apps/web/components/Blog.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
"use client";
import { useRecoilValue } from "recoil";

import { Problem, Track } from "@prisma/client";
import { isLegacyViewMode } from "@repo/store";

import { BlogAppbar } from "./BlogAppbar";
import { NotionRenderer } from "./NotionRenderer";
import useMountStatus from "../hooks/useMountStatus";
import TrackTools from "./TrackTools";
import CustomPagination from "./CustomPagination";

export const Blog = ({
problem,
track,
showAppBar,
showPagination,
isPdfRequested,
problemIndex,
}: {
problem: Problem & { notionRecordMap: any };
track: Track & { problems: Problem[] };
showAppBar: Boolean;
isPdfRequested?: Boolean;
showAppBar?: boolean;
showPagination?: boolean;
isPdfRequested?: boolean;
problemIndex: number;
}) => {
const mounted = useMountStatus();
const isLegacyMode = useRecoilValue(isLegacyViewMode);

if (isPdfRequested == undefined || !isPdfRequested) {
if (!mounted) {
return null;
}
}

return (
<div>
<NotionRenderer recordMap={problem.notionRecordMap} />
<div className="fixed top-0 w-full">
<BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />
const renderBlog = () =>
isLegacyMode ? (
<div className="break-after-page">
{showAppBar && <BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />}
<NotionRenderer recordMap={problem.notionRecordMap} />
{showPagination && (
<div className="justify-center pt-2">
<CustomPagination allProblems={track.problems} track={track} problemIndex={problemIndex} />
</div>
)}
</div>
<div className="fixed bottom-0 itemsc-center justify-center mx-auto w-full">
<TrackTools allProblems={track.problems} track={track} problemIndex={problemIndex} />
) : (
<div>
<NotionRenderer recordMap={problem.notionRecordMap} />
<div className="fixed top-0 w-full">
<BlogAppbar problem={problem} track={track} problemIndex={problemIndex} />
</div>
<div className="itemsc-center fixed bottom-0 mx-auto w-full justify-center">
<TrackTools allProblems={track.problems} track={track} problemIndex={problemIndex} />
</div>
</div>
</div>
);
);

return renderBlog();
};

Loading
Loading