Skip to content

Commit

Permalink
Merge branch 'main' of github.com:code100x/daily-code
Browse files Browse the repository at this point in the history
  • Loading branch information
hkirat committed Aug 30, 2024
2 parents 9e8d7cc + ebd1d22 commit e087f2c
Show file tree
Hide file tree
Showing 16 changed files with 419 additions and 198 deletions.
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

0 comments on commit e087f2c

Please sign in to comment.