-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Feat(371) - Disabled tracks after second page #394
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,12 @@ | ||
| import { getServerSession } from "next-auth"; | ||
| import { Landing } from "../screens/Landing"; | ||
| import { authOptions } from "../lib/auth"; | ||
| import { redirect } from "next/navigation"; | ||
|
|
||
| export default async function Page(): Promise<JSX.Element> { | ||
| const session = await getServerSession(authOptions); | ||
|
|
||
| if (!session?.user) { | ||
| return redirect("/auth"); | ||
| } | ||
|
|
||
| return ( | ||
| <main> | ||
| <Landing /> | ||
| </main> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,34 +3,47 @@ import { NotionRenderer as NotionRendererLib } from "react-notion-x"; | |
| // import { Code } from "react-notion-x/build/third-party/code"; | ||
| import CodeBlock from "./CodeBlock"; | ||
| import { useTheme } from "next-themes"; | ||
| import { useSession } from "next-auth/react"; | ||
| import RedirectToLoginCard from "./RedirectToLoginCard"; | ||
|
|
||
| // Week-4-1-647987d9b1894c54ba5c822978377910 | ||
| export const NotionRenderer = ({ recordMap }: { recordMap: any }) => { | ||
| const { resolvedTheme } = useTheme(); | ||
| const session = useSession(); | ||
| const isAuthenticated = session.status === 'authenticated' && session.data !== null; | ||
| const storedProblemIndex = localStorage.getItem('problemIndex'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NotionRenderer isn't the only renderer we have
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I missed that scenario. Mb. I can try implementing similar functionality in LessionView.tsx and pass a variable (trackVisible) to the components(Blog, CodeRenderer, MCQRenderer). That would be a better way of doing this for now and if and when new components are added |
||
| const number = storedProblemIndex !== null ? parseInt(storedProblemIndex) : 1; | ||
| const isPageNumberGreaterThanTwo = !isNaN(number) && number > 2; | ||
|
|
||
| return ( | ||
| <div className="w-full"> | ||
| <style> | ||
| {` | ||
| .notion-header { | ||
| display: none !important; | ||
| } | ||
| let contentToRender; | ||
| if (isPageNumberGreaterThanTwo && !isAuthenticated) { | ||
| contentToRender = <RedirectToLoginCard />; | ||
| } else { | ||
| contentToRender = ( | ||
| <div className="w-full"> | ||
| <style> | ||
| {` | ||
| .notion-header { | ||
| display: none !important; | ||
| } | ||
|
|
||
| .notion-page: { | ||
| padding: 0px !important; | ||
| } | ||
| `} | ||
| </style> | ||
| <div className="rounded-full"> | ||
| <NotionRendererLib | ||
| components={{ | ||
| Code: CodeBlock, | ||
| }} | ||
| recordMap={recordMap} | ||
| fullPage={true} | ||
| darkMode={resolvedTheme === "dark"} | ||
| /> | ||
| .notion-page: { | ||
| padding: 0px !important; | ||
| } | ||
| `} | ||
| </style> | ||
| <div className="rounded-full"> | ||
| <NotionRendererLib | ||
| components={{ | ||
| Code: CodeBlock, | ||
| }} | ||
| recordMap={recordMap} | ||
| fullPage={true} | ||
| darkMode={resolvedTheme === "dark"} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
| ); | ||
| } | ||
| return <>{contentToRender}</>; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why here?
Also why localStorage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured we could use problemIndex in other places so why not have it on hand in the parent component i.e BlogAppbar.