-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vishal
authored and
vishal
committed
Jul 25, 2024
1 parent
f469346
commit d5383ee
Showing
4 changed files
with
132 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
Card, | ||
CardHeader, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
CardFooter, | ||
} from "./ui/card"; | ||
import { getProblems } from "../controllers/problem"; | ||
import { PrimaryButton } from "./LinkButton"; | ||
|
||
export async function PopularProblems() { | ||
const problems = await getProblems(); | ||
|
||
return ( | ||
<section className="bg-white dark:bg-gray-900 py-8 md:py-12 min-h-screen"> | ||
<div className="container mx-auto px-4 md:px-6"> | ||
<div className="mb-6"> | ||
<h2 className="text-2xl font-bold mb-2">Popular Problems</h2> | ||
<p className="text-gray-500 dark:text-gray-400"> | ||
Check out the most popular programming problems on algoearth. | ||
</p> | ||
</div> | ||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> | ||
{problems.map((problem) => ( | ||
<ProblemCard problem={problem} key={problem.id} /> | ||
))} | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
function ProblemCard({ problem }: { problem: any }) { | ||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>{problem.title}</CardTitle> | ||
<CardDescription>Easy problem for beginners</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="flex items-center justify-between"> | ||
<div> | ||
<p className="text-gray-500 dark:text-gray-400">Difficulty</p> | ||
<p>{problem.difficulty}</p> | ||
</div> | ||
<div> | ||
<p className="text-gray-500 dark:text-gray-400">Submissions</p> | ||
<p>{problem.solved}</p> | ||
</div> | ||
</div> | ||
</CardContent> | ||
<CardFooter> | ||
<PrimaryButton href={`/problem/${problem.id}`}> | ||
View Problem | ||
</PrimaryButton> | ||
</CardFooter> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,61 @@ | ||
import { | ||
Card, | ||
CardHeader, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
CardFooter, | ||
} from "./ui/card"; | ||
import { getProblems } from "../controllers/problem"; | ||
import { PrimaryButton } from "./LinkButton"; | ||
Card, | ||
CardHeader, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
CardFooter, | ||
} from "./ui/card"; | ||
import { getAllProblems, getProblems } from "../controllers/problem"; | ||
import { PrimaryButton } from "./LinkButton"; | ||
|
||
export async function Problems() { | ||
const problems = await getAllProblems(); | ||
|
||
export async function Problems() { | ||
const problems = await getProblems(); | ||
|
||
return ( | ||
<section className="bg-white dark:bg-gray-900 py-8 md:py-12 min-h-screen"> | ||
<div className="container mx-auto px-4 md:px-6"> | ||
<div className="mb-6"> | ||
<h2 className="text-2xl font-bold mb-2">Popular Problems</h2> | ||
<p className="text-gray-500 dark:text-gray-400"> | ||
Check out the most popular programming problems on algoearth. | ||
</p> | ||
</div> | ||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> | ||
{problems.map((problem) => ( | ||
<ProblemCard problem={problem} key={problem.id} /> | ||
))} | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
function ProblemCard({ problem }: { problem: any }) { | ||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>{problem.title}</CardTitle> | ||
<CardDescription>Easy problem for beginners</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="flex items-center justify-between"> | ||
<div> | ||
<p className="text-gray-500 dark:text-gray-400">Difficulty</p> | ||
<p>{problem.difficulty}</p> | ||
return ( | ||
<section className="bg-white dark:bg-gray-900 py-8 md:py-12 min-h-screen"> | ||
<div className="container mx-auto px-4 md:px-6"> | ||
<div className="mb-6"> | ||
<h2 className="text-2xl font-bold mb-2">Popular Problems</h2> | ||
<p className="text-gray-500 dark:text-gray-400"> | ||
Check out the most popular programming problems on algoearth. | ||
</p> | ||
</div> | ||
<div> | ||
<p className="text-gray-500 dark:text-gray-400">Submissions</p> | ||
<p>{problem.solved}</p> | ||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> | ||
{problems.map((problem) => ( | ||
<ProblemCard problem={problem} key={problem.id} /> | ||
))} | ||
</div> | ||
</div> | ||
</CardContent> | ||
<CardFooter> | ||
<PrimaryButton href={`/problem/${problem.id}`}> | ||
View Problem | ||
</PrimaryButton> | ||
</CardFooter> | ||
</Card> | ||
); | ||
} | ||
</section> | ||
); | ||
} | ||
|
||
function ProblemCard({ problem }: { problem: any }) { | ||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>{problem.title}</CardTitle> | ||
<CardDescription>Easy problem for beginners</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="flex items-center justify-between"> | ||
<div> | ||
<p className="text-gray-500 dark:text-gray-400">Difficulty</p> | ||
<p>{problem.difficulty}</p> | ||
</div> | ||
<div> | ||
<p className="text-gray-500 dark:text-gray-400">Submissions</p> | ||
<p>{problem.solved}</p> | ||
</div> | ||
</div> | ||
</CardContent> | ||
<CardFooter> | ||
<PrimaryButton href={`/problem/${problem.id}`}> | ||
View Problem | ||
</PrimaryButton> | ||
</CardFooter> | ||
</Card> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters