Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d1aeccd

Browse files
Handled paid question page
1 parent 575bb49 commit d1aeccd

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

‎src/app/page.jsx‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ export default function Home() {
3636
icon={<BsSearch />}
3737
onChange={(event) => setSearchTerm(event.target.value)}
3838
/>
39-
<Link href={`/questions/${Math.floor(Math.random() * data.length)}`}>
40-
<Tooltip content="Pick a question at random">
41-
<IconButton variant="outlined" color="gray">
42-
<FaRandom />
43-
</IconButton>
44-
</Tooltip>
45-
</Link>
39+
{data && (
40+
<Link
41+
href={`/questions/${Math.floor(Math.random() * data.length)}`}
42+
>
43+
<Tooltip content="Pick a question at random">
44+
<IconButton variant="outlined" color="gray">
45+
<FaRandom />
46+
</IconButton>
47+
</Tooltip>
48+
</Link>
49+
)}
4650
</div>
4751
{isLoading ? (
4852
<p className="text-center p-10">Loading...</p>

‎src/app/questions/[qid]/page.jsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ export default async function QuestionsPage({ params: { qid } }) {
2525
difficulty={data[0]["difficulty"]}
2626
similarQuestions={similarQuestions}
2727
topicTags={data[0]["topicTags"]}
28+
paidOnly={data[0]["paidOnly"]}
2829
/>
29-
<SolutionWrapper
30-
solutions={data[0].solutions}
31-
codeStub={data[0].Code}
32-
/>
30+
{!data[0]["paidOnly"] && (
31+
<SolutionWrapper
32+
solutions={data[0].solutions}
33+
codeStub={data[0].Code}
34+
/>
35+
)}
3336
</div>
3437
)}
3538
</div>

‎src/components/QuestionBody.jsx‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const QuestionBody = ({
1111
body,
1212
similarQuestions,
1313
topicTags,
14+
paidOnly,
1415
}) => {
1516
return (
1617
<div className="w-full overflow-y-scroll mb-10 pr-2">
@@ -32,11 +33,20 @@ export const QuestionBody = ({
3233
}`}
3334
/>
3435
</div>
35-
<div className="mb-10">{ReactHtmlParser(body)}</div>
36-
<QuestionBodyAccordian
37-
similarQuestions={similarQuestions}
38-
topicTags={topicTags}
39-
/>
36+
{!paidOnly ? (
37+
<>
38+
<div className="mb-10">{ReactHtmlParser(body)}</div>
39+
<QuestionBodyAccordian
40+
similarQuestions={similarQuestions}
41+
topicTags={topicTags}
42+
/>
43+
</>
44+
) : (
45+
<p className="text-center py-10">
46+
This question is not available as it is for paid customers of Leetcode
47+
only.
48+
</p>
49+
)}
4050
</div>
4151
);
4252
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /