-
+
+
>
);
diff --git a/components/ui/index.ts b/components/ui/index.ts
index d2267337a5..f202f8ffe5 100644
--- a/components/ui/index.ts
+++ b/components/ui/index.ts
@@ -1,7 +1,6 @@
export * from "./alert/Alert";
export * from "./dialog/Dialog";
export * from "./header/Header";
-export * from "./pagination/Pagination";
export * from "./select/Select";
export * from "./sidebar";
export * from "./table/StatusBadge";
diff --git a/components/ui/pagination/Pagination.tsx b/components/ui/pagination/Pagination.tsx
deleted file mode 100644
index e490942398..0000000000
--- a/components/ui/pagination/Pagination.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { usePathname, useSearchParams } from "next/navigation";
-import React from "react";
-
-interface Props {
- totalPages: number;
- currentPage: number;
- nextPage?: string;
-}
-
-export const Pagination = ({ totalPages, currentPage }: Props) => {
- const pathname = usePathname();
- const searchParams = useSearchParams();
- // const currentPage = searchParams["page"] ?? "1";
- const createPageUrl = (pageNumber: number | string) => {
- const params = new URLSearchParams(searchParams);
-
- if (pageNumber === "...") return `${pathname}?${params.toString()}`;
-
- if (+pageNumber <= 0) {
- return `${pathname}`;
- }
- if (+pageNumber > totalPages) {
- return `${pathname}?${params.toString()}`;
- }
- params.set("page", pageNumber.toString());
- return `${pathname}?${params.toString()}`;
- };
-
- console.log(pathname, searchParams, currentPage);
-
- return (
-
- );
-};
diff --git a/lib/utils.ts b/lib/utils.ts
index c3e96dd8df..84a5fe24e3 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -1,6 +1,8 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
+import { MetaDataProps } from "@/types";
+
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
@@ -9,6 +11,14 @@ export const parseStringify = (value: any) => JSON.parse(JSON.stringify(value));
export const convertFileToUrl = (file: File) => URL.createObjectURL(file);
+export const extractPaginationInfo = (metadata: MetaDataProps) => {
+ const currentPage = metadata?.pagination.page ?? "1";
+ const totalPages = metadata?.pagination.pages;
+ const totalEntries = metadata?.pagination.count;
+
+ return { currentPage, totalPages, totalEntries };
+};
+
// FORMAT DATE TIME
export const formatDateTime = (
dateString: Date | string,
diff --git a/types/components.ts b/types/components.ts
index b7b53724e5..1d23c712a9 100644
--- a/types/components.ts
+++ b/types/components.ts
@@ -9,6 +9,12 @@ export type IconProps = {
style?: React.CSSProperties;
};
+export interface searchParamsProps {
+ searchParams: {
+ page?: string;
+ };
+}
+
export interface ProviderProps {
id: string;
type: "providers";
@@ -47,3 +53,12 @@ export interface FindingsProps {
account: string;
};
}
+
+export interface MetaDataProps {
+ pagination: {
+ page: number;
+ pages: number;
+ count: number;
+ };
+ version: string;
+}