MCPcopy Create free account
hub / github.com/code100x/daily-code / CustomPagination

Function CustomPagination

apps/web/components/CustomPagination.tsx:7–77  ·  view source on GitHub ↗
({
  isAtHeader = false,
  problemIndex,
  track,
}: {
  allProblems: Problem[];
  isAtHeader?: boolean;
  problemIndex: number;
  track: Track & { problems: Problem[] };
})

Source from the content-addressed store, hash-verified

5import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
6
7const CustomPagination = ({
8 isAtHeader = false,
9 problemIndex,
10 track,
11}: {
12 allProblems: Problem[];
13 isAtHeader?: boolean;
14 problemIndex: number;
15 track: Track & { problems: Problem[] };
16}) => {
17 return (
18 <div className="flex items-center justify-center space-x-2">
19 <PageToggle allProblems={track.problems} isAtHeader track={track} />
20 <Link
21 prefetch
22 href={problemIndex !== 0 ? `/tracks/${track.id}/${track.problems[problemIndex - 1]!.id}` : ``}
23 style={{ cursor: problemIndex !== 0 ? "pointer" : "not-allowed" }}
24 >
25 <Button
26 variant="outline"
27 className="ml-2 hidden bg-black text-white md:flex"
28 disabled={problemIndex !== 0 ? false : true}
29 >
30 <div className="pr-2">
31 <ChevronLeftIcon />
32 </div>
33 <span className={isAtHeader ? "hidden lg:block" : ""}>Prev</span>
34 </Button>
35 <Button
36 variant="outline"
37 className="block bg-black text-white md:hidden"
38 disabled={problemIndex !== 0 ? false : true}
39 >
40 <div>
41 <ChevronLeftIcon />
42 </div>
43 </Button>
44 </Link>
45
46 <Link
47 prefetch={true}
48 href={
49 problemIndex + 1 === track.problems.length
50 ? ``
51 : `/tracks/${track.id}/${track.problems[problemIndex + 1]!.id}`
52 }
53 style={{ cursor: problemIndex + 1 !== track.problems.length ? "pointer" : "not-allowed" }}
54 >
55 <Button
56 variant="outline"
57 className="hidden bg-black text-white md:flex"
58 disabled={problemIndex + 1 !== track.problems.length ? false : true}
59 >
60 <span className={isAtHeader ? "hidden lg:block" : ""}>Next</span>
61 <div className="pl-2">
62 <ChevronRightIcon />
63 </div>
64 </Button>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected