• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cartesi / rollups-explorer / 8976881860

06 May 2024 10:58PM CUT coverage: 95.576%. Remained the same
8976881860

Pull #161

github

dandheedge
chore(packages/decoder): fix prettier path
Pull Request #161: #156 Voucher content decoding

499 of 600 branches covered (83.17%)

Branch coverage included in aggregate %.

6457 of 6678 relevant lines covered (96.69%)

21.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.3
/apps/web/src/hooks/usePaginationParams.tsx
1
import { usePathname, useRouter, useSearchParams } from "next/navigation";
1✔
2
import { pathOr } from "ramda";
1✔
3
import { useCallback, useMemo } from "react";
1✔
4
import { useQueryParams } from "./useQueryParams";
1✔
5

1✔
6
export const limitBounds = {
1✔
7
    "10": 10,
1✔
8
    "20": 20,
1✔
9
    "30": 30,
1✔
10
} as const;
1✔
11

1✔
12
export type LimitBound = (typeof limitBounds)[keyof typeof limitBounds];
1✔
13

1✔
14
export type UsePaginationReturn = [
1✔
15
    { limit: LimitBound; page: number },
1✔
16
    (page: number, limit: LimitBound) => void,
1✔
17
];
1✔
18

1✔
19
export const usePaginationParams = (): UsePaginationReturn => {
1✔
20
    const searchParams = useSearchParams();
×
21
    const router = useRouter();
×
22
    const pathName = usePathname();
×
23
    const { query } = useQueryParams();
×
24
    const urlSearchParams = new URLSearchParams(searchParams);
×
25
    const pg = parseInt(urlSearchParams.get("pg") ?? "");
×
26
    const lt = urlSearchParams.get("lt") ?? limitBounds[10];
×
27
    const limit = pathOr(limitBounds[10], [lt], limitBounds);
×
28
    const page = isNaN(pg) ? 1 : pg;
×
29
    const updateParams = useCallback(
×
30
        (page: number, limit: number): void => {
×
31
            const urlSearchParams = new URLSearchParams({
×
32
                query: query.toString(),
×
33
                pg: page.toString(),
×
34
                lt: limit.toString(),
×
35
            });
×
36
            router.push(`${pathName}?${urlSearchParams.toString()}`, {
×
37
                scroll: false,
×
38
            });
×
39
        },
×
40
        [query, router, pathName],
×
41
    );
×
42
    return useMemo(
×
43
        () => [{ page, limit }, updateParams],
×
44
        [limit, page, updateParams],
×
45
    );
×
46
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc