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

Commit

Permalink
style(page:user): format code
Browse files Browse the repository at this point in the history
  ## what
  - format code

  ## how

  ## why

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

  ## usage
  • Loading branch information
Clumsy-Coder committed Jan 14, 2024
1 parent 21f3ffe commit 30b9241
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/app/users/[username]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import Error from "@/components/error";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { userSchema } from "@/schema";
import SubmissionVerdictChart from "@/components/charts/ProblemVerdictChart";
import { useFetchUserSubmissions, useFetchUserSubmissionVerdict } from "@/hooks";
import {
useFetchUserSubmissions,
useFetchUserSubmissionVerdict,
} from "@/hooks";
import { UserSubmission, UserSubmissionBarChartType } from "@/types";
import { DataTable } from "@/components/ui/data-table";
import { columns } from "@/app/users/[username]/components/data-table/submissionColumns";
Expand All @@ -32,18 +35,17 @@ const UserPage = ({ params }: Props) => {
error: userSubmissionVerdictError,
} = useFetchUserSubmissionVerdict(params.username);


if (userSubmissionIsLoading || userSubmissionVerdictIsLoading) {
return <div>Loading {params.username}</div>;
}

if(userSubmissionIsError) {
if (userSubmissionIsError) {
type ErrorMessage = {
message: string;
}
};

const status = (userSubmissionError as AxiosError<ErrorMessage>).response?.status
const message = (userSubmissionError as AxiosError<ErrorMessage>).response?.data.message
const status = (userSubmissionError as AxiosError<ErrorMessage>).response?.status;
const message = (userSubmissionError as AxiosError<ErrorMessage>).response?.data.message;

return (
<Error
Expand All @@ -60,7 +62,9 @@ const UserPage = ({ params }: Props) => {
return (
<section>
<div>
<h1 className="text-3xl">{userSubmissionData?.name} ({params.username})</h1>
<h1 className="text-3xl">
{userSubmissionData?.name} ({params.username})
</h1>
</div>
<div className="grid lg:grid-cols-2 gap-4 mb-4 mt-4">
<div className="w-full">
Expand All @@ -69,7 +73,9 @@ const UserPage = ({ params }: Props) => {
<CardTitle>Submission Verdicts</CardTitle>
</CardHeader>
<CardContent className="h-[400px]">
<SubmissionVerdictChart data={userSubmissionVerdictData as UserSubmissionBarChartType[]} />
<SubmissionVerdictChart
data={userSubmissionVerdictData as UserSubmissionBarChartType[]}
/>
</CardContent>
</Card>
</div>
Expand All @@ -78,12 +84,16 @@ const UserPage = ({ params }: Props) => {
<div>
<div>
<h1 className="text-3xl mb-4 mt-6">Submissions</h1>
<DataTable columns={columns} data={( userSubmissionData as UserSubmission ).subs} height={400} />
<DataTable
columns={columns}
data={(userSubmissionData as UserSubmission).subs}
height={400}
/>
</div>
</div>
</div>
</section>
)
);
};

export default UserPage;

0 comments on commit 30b9241

Please sign in to comment.