diff --git a/src/components/ProblemViewLayout.tsx b/src/components/ProblemViewLayout.tsx index 46866b7..c495479 100644 --- a/src/components/ProblemViewLayout.tsx +++ b/src/components/ProblemViewLayout.tsx @@ -14,7 +14,7 @@ import TestcasesGradingIndicator from "./TestcasesGradingIndicator"; import { Button } from "./shadcn/Button"; import { Combobox } from "./shadcn/Combobox"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "./shadcn/Resizable"; -import DifficultyBadge from "./DifficultyBadge"; +import { Separator } from "./shadcn/Seperator"; export type OnSubmitProblemViewLayoutCallback = { setGrading: React.Dispatch> @@ -115,14 +115,17 @@ const ProblemViewLayout = ({

-
+ {/*
Difficulty

-
+
*/} +
+ +
{problem && ( )}
diff --git a/src/components/Tables/ProblemTables/MyProblemsTable.tsx b/src/components/Tables/ProblemTables/MyProblemsTable.tsx index 862ecf9..c460852 100644 --- a/src/components/Tables/ProblemTables/MyProblemsTable.tsx +++ b/src/components/Tables/ProblemTables/MyProblemsTable.tsx @@ -1,12 +1,12 @@ import { ColumnDef } from "@tanstack/react-table"; import { - Check, - FileSpreadsheet, - MoreHorizontal, - Tally4, - Tally5, - Timer, - X + Check, + FileSpreadsheet, + MoreHorizontal, + Tally4, + Tally5, + Timer, + X, } from "lucide-react"; import { Link } from "react-router-dom"; import { ProgrammingLanguageOptions } from "../../../constants/ProgrammingLanguage"; @@ -16,12 +16,18 @@ import { readableDateFormat } from "../../../utilities/ReadableDateFormat"; import MyProblemDropdown from "../../Dropdowns/MyProblemDropdown"; import { DataTable } from "../Prototype/DataTable"; import DataTableSortableLayout from "../Prototype/DataTableSortableLayout"; +import { HoverCard, HoverCardContent, HoverCardTrigger } from "../../shadcn/HoverCard"; +import { Badge } from "../../shadcn/Badge"; const columns: ColumnDef[] = [ { accessorKey: "title", - header: ({column})=>( - column.toggleSorting(column.getIsSorted() === "asc")}> + header: ({ column }) => ( + + column.toggleSorting(column.getIsSorted() === "asc") + } + > Title ), @@ -39,15 +45,19 @@ const columns: ColumnDef[] = [ { accessorKey: "creator", - header: ({column})=>( - column.toggleSorting(column.getIsSorted() === "asc")}> + header: ({ column }) => ( + + column.toggleSorting(column.getIsSorted() === "asc") + } + > Author ), cell: ({ row }) => { return (
- {row.original.creator.username} + {row.original.creator.username}
); }, @@ -75,10 +85,7 @@ const columns: ColumnDef[] = [ }, { accessorKey: "source_code", - header: () =>
- - Source Code -
, + header: () =>
Source Code
, cell: ({ row }) => { return (
@@ -123,19 +130,57 @@ const columns: ColumnDef[] = [ header: () =>
Allowed Languages
, cell: ({ row }) => (
- {row.original.allowed_languages.split(",").map((lang) => ( - - { - ProgrammingLanguageOptions.find( - (option) => option.value === lang - )?.badge - } - - ))} +
+ {row.original.allowed_languages + .split(",") + .slice(0, 2) + .map((lang) => ( + + { + ProgrammingLanguageOptions.find( + (option) => option.value === lang + )?.badge + } + + ))} + + {row.original.allowed_languages.split(",").length > 2 && ( + + + + + ...{" "} + {row.original.allowed_languages.split( + "," + ).length - 2}{" "} + more + + + +
+ {row.original.allowed_languages + .split(",") + .map((lang) => ( +
+ { + ProgrammingLanguageOptions.find( + (option) => + option.value === + lang + )?.badge + } +
+ ))} +
+
+
+
+ )} +
), }, - // Temporary hide this column + // Temporary hide this column // { // accessorKey: "difficulty", // header: ({ column }) => ( @@ -152,10 +197,13 @@ const columns: ColumnDef[] = [ { accessorKey: "updated_date", header: ({ column }) => ( - column.toggleSorting(column.getIsSorted() === "asc")}> + + column.toggleSorting(column.getIsSorted() === "asc") + } + > Updated Date - ), cell: ({ row }) => (
@@ -179,11 +227,7 @@ const columns: ColumnDef[] = [ // }, { accessorKey: "action", - header: () => ( -
- Action -
- ), + header: () =>
Action
, cell: ({ row }) => (
diff --git a/src/components/Tables/ProblemTables/PublicProblemsTable.tsx b/src/components/Tables/ProblemTables/PublicProblemsTable.tsx index a5668ef..c05eb35 100644 --- a/src/components/Tables/ProblemTables/PublicProblemsTable.tsx +++ b/src/components/Tables/ProblemTables/PublicProblemsTable.tsx @@ -1,132 +1,192 @@ import { ColumnDef } from "@tanstack/react-table"; -import { - FileSpreadsheet, - Puzzle -} from "lucide-react"; +import { FileSpreadsheet, Puzzle } from "lucide-react"; import { Link, useParams } from "react-router-dom"; import { ProgrammingLanguageOptions } from "../../../constants/ProgrammingLanguage"; -import { - ProblemPopulateAccountAndSubmissionPopulateSubmissionTestcasesSecureModel -} from "../../../types/models/Problem.model"; -import { readableDateFormat } from "../../../utilities/ReadableDateFormat"; -import { DataTable } from "../Prototype/DataTable"; +import { ProblemPopulateAccountAndSubmissionPopulateSubmissionTestcasesSecureModel } from "../../../types/models/Problem.model"; import TestcasesGradingIndicator from "../../TestcasesGradingIndicator"; +import { Badge } from "../../shadcn/Badge"; import { Button } from "../../shadcn/Button"; -import DifficultyBadge from "../../DifficultyBadge"; - - +import { + HoverCard, + HoverCardContent, + HoverCardTrigger, +} from "../../shadcn/HoverCard"; +import { DataTable } from "../Prototype/DataTable"; const PublicProblemsTable = ({ problems, }: { problems: ProblemPopulateAccountAndSubmissionPopulateSubmissionTestcasesSecureModel[]; }) => { - - const {courseId} = useParams() + const { courseId } = useParams(); const columns: ColumnDef[] = - [ - { - accessorKey: "title", - header: "Title", - cell: ({ row }) => { - console.log(row.original.allowed_languages); + [ + { + accessorKey: "title", + header: "Title", + cell: ({ row }) => { + console.log(row.original.allowed_languages); - return ( -
- - - {row.original.title} - -
- ); + return ( +
+ + + {row.original.title} + +
+ ); + }, }, - }, - { - accessorKey: "author", - header: "Author", - cell: ({ row }) => ( -
- {row.original.creator.username} -
- ), - }, - { - accessorKey: "allowed_languages", - header: "Allowed Languages", - cell: ({ row }) => ( -
- {row.original.allowed_languages.split(",").map((lang) => ( - - { - ProgrammingLanguageOptions.find( - (option) => option.value === lang - )?.badge + { + accessorKey: "allowed_languages", + header: () => ( +
Allowed Languages
+ ), + cell: ({ row }) => ( +
+
+ {row.original.allowed_languages + .split(",") + .slice(0, 2) + .map((lang) => ( + + { + ProgrammingLanguageOptions.find( + (option) => + option.value === lang + )?.badge + } + + ))} + + {row.original.allowed_languages.split(",") + .length === 3 && ( + + { + ProgrammingLanguageOptions.find( + (option) => + option.value === + row.original.allowed_languages.split( + "," + )[2] + )?.badge + } + + )} + + {row.original.allowed_languages.split(",").length > + 3 && ( + + + + + ...{" "} + {row.original.allowed_languages.split( + "," + ).length - 2}{" "} + more + + + +
+ {row.original.allowed_languages + .split(",") + .map((lang) => ( +
+ { + ProgrammingLanguageOptions.find( + (option) => + option.value === + lang + )?.badge + } +
+ ))} +
+
+
+
+ )} +
+
+ ), + }, + { + accessorKey: "best_submissions", + header: "Best Submissions", + cell: ({ row }) => ( +
+ - ))} -
- ), - }, - { - accessorKey: "best_submissions", - header: "Best Submissions", - cell: ({ row }) => ( -
- -
- ), - }, + sizeX={1.5} + sizeY={3} + /> +
+ ), + }, - { - accessorKey: "difficulty", - header: "Difficulty", - cell: ({ row }) => ( - - ), - }, + { + accessorKey: "author", + header: "Author", + cell: ({ row }) => ( +
+ {row.original.creator.username} +
+ ), + }, - { - accessorKey: "updated_date", - header: "Updated Date", - cell: ({ row }) => ( -
- {readableDateFormat(row.original.updated_date)} -
- ), - }, + // { + // accessorKey: "difficulty", + // header: "Difficulty", + // cell: ({ row }) => ( + // + // ), + // }, - { - accessorKey: "action", - header: "", - cell: ({ row }) => ( -
- - - -
- ), - }, - ]; + + +
+ ), + }, + ]; return (
diff --git a/src/views/ExploreProblems.tsx b/src/views/ExploreProblems.tsx index fdcda80..f0d1bb5 100644 --- a/src/views/ExploreProblems.tsx +++ b/src/views/ExploreProblems.tsx @@ -20,12 +20,12 @@ const ExploreProblems = () => { console.log('prob',response.data.problems) setProblems(response.data.problems); }); - }, []); + }, [accountId]); return (
-

Explore Public Problems

+

Explore Problems

{/* {problems.map((problem) => (