Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
feat(page:user): display problem solved VS user submissions with donu…
Browse files Browse the repository at this point in the history
…t chart

  ## what
  - display problem solved VS user submissions with donut chart

  ## how
  - fetch the data using react-query hook `useFetchUserSubmissionAttempted`
  - display the data using Rechart donut chart

  ## why
  - to display user solved problems VS user submissions

  ## where
  - ./src/app/users/[username]/page.tsx

  ## usage
  • Loading branch information
Clumsy-Coder committed Jan 15, 2024
1 parent 25bda0e commit e2689d5
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/app/users/[username]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { userSchema } from "@/schema";
import SubmissionVerdictChart from "@/components/charts/ProblemVerdictChart";
import {
useFetchUserSubmissionAttempted,
useFetchUserSubmissionLanguage,
useFetchUserSubmissionOvertime,
useFetchUserSubmissions,
useFetchUserSubmissionVerdict,
} from "@/hooks";
import {
SubmissionLangType,
SubmissionSovledVsAttempted,
SubmissionsOvertimeLineChartType,
UserSubmission,
UserSubmissionBarChartType,
Expand All @@ -23,6 +25,7 @@ import { DataTable } from "@/components/ui/data-table";
import { columns } from "@/app/users/[username]/components/data-table/submissionColumns";
import SubmissionLanguageRadarChart from "@/components/charts/SubmissionLanguageRadarChart";
import SubmissionsOvertimeChart from "@/components/charts/SubmissionsOvertimeChart";
import SolvedVsAttemptedDonutChart from "@/components/charts/SolvedVsAttemptedDonutChart";

type Props = {
params: z.infer<typeof userSchema>;
Expand Down Expand Up @@ -57,13 +60,20 @@ const UserPage = ({ params }: Props) => {
data: userSubmissionOvertimeData,
error: userSubmissionOvertimeError,
} = useFetchUserSubmissionOvertime(params.username);

const {
isLoading: userSubmissionAttemptedIsLoading,
isSuccess: userSubmissionAttemptedIsSuccess,
isError: userSubmissionAttemptedIsError,
data: userSubmissionAttemptedData,
error: userSubmissionAttemptedError,
} = useFetchUserSubmissionAttempted(params.username);

if (
userSubmissionIsLoading ||
userSubmissionVerdictIsLoading ||
userSubmissionLanguageIsLoading ||
userSubmissionOvertimeIsLoading
userSubmissionOvertimeIsLoading ||
userSubmissionAttemptedIsLoading
) {
return <div>Loading {params.username}</div>;
}
Expand Down Expand Up @@ -134,6 +144,19 @@ const UserPage = ({ params }: Props) => {
</CardContent>
</Card>
</div>
{/* Problem solved vs attempted with donut chart */}
<div className="w-full">
<Card>
<CardHeader>
<CardTitle>Solved problems vs Problem submissions</CardTitle>
</CardHeader>
<CardContent className="h-[400px]">
<SolvedVsAttemptedDonutChart
data={userSubmissionAttemptedData as SubmissionSovledVsAttempted[]}
/>
</CardContent>
</Card>
</div>
</div>
<div className="flex flex-col gap-4">
<div>
Expand Down

0 comments on commit e2689d5

Please sign in to comment.