diff --git a/public/images/no-data-founded/1.jpg b/public/images/no-data-founded/1.jpg
new file mode 100644
index 0000000..8fbba56
Binary files /dev/null and b/public/images/no-data-founded/1.jpg differ
diff --git a/public/images/no-data-founded/2.jpg b/public/images/no-data-founded/2.jpg
new file mode 100644
index 0000000..9069540
Binary files /dev/null and b/public/images/no-data-founded/2.jpg differ
diff --git a/public/images/no-data-founded/3.jpg b/public/images/no-data-founded/3.jpg
new file mode 100644
index 0000000..589c693
Binary files /dev/null and b/public/images/no-data-founded/3.jpg differ
diff --git a/public/images/no-data-founded/4.jpg b/public/images/no-data-founded/4.jpg
new file mode 100644
index 0000000..dfb5fd7
Binary files /dev/null and b/public/images/no-data-founded/4.jpg differ
diff --git a/public/images/no-data-founded/5.jpg b/public/images/no-data-founded/5.jpg
new file mode 100644
index 0000000..2eb2373
Binary files /dev/null and b/public/images/no-data-founded/5.jpg differ
diff --git a/public/images/no-data-founded/6.jpg b/public/images/no-data-founded/6.jpg
new file mode 100644
index 0000000..465c2ff
Binary files /dev/null and b/public/images/no-data-founded/6.jpg differ
diff --git a/src/app/(routes)/blog/[...notFound]/page.tsx b/src/app/(routes)/blog/[...notFound]/page.tsx
index 0c63367..23563b0 100644
--- a/src/app/(routes)/blog/[...notFound]/page.tsx
+++ b/src/app/(routes)/blog/[...notFound]/page.tsx
@@ -11,7 +11,7 @@ export default function NotFound({ params }: PropsType) {
const imageUrl = `/images/404/${Math.floor(Math.random() * 5) + 1}.jpg`;
return (
-
+
-
- {CategoriesData.data.map((category: CategoryType) => (
-
-
-
-
- {category.name}
-
-
- {category.short_description}
-
+
+ {CategoriesData.data.length > 0 ? (
+ CategoriesData.data.map((category: CategoryType) => (
+
+
+
+
+ {category.name}
+
+
+ {category.short_description}
+
+
-
- ))}
+ ))
+ ) : (
+
+ )}
+ {CategoriesData.data.length > 0 &&
+ CategoriesData.meta.last_page > 1 && (
+
+ )}
);
diff --git a/src/app/(routes)/blog/components/no-data-founded/noDataFounded.tsx b/src/app/(routes)/blog/components/no-data-founded/noDataFounded.tsx
new file mode 100644
index 0000000..8e3d368
--- /dev/null
+++ b/src/app/(routes)/blog/components/no-data-founded/noDataFounded.tsx
@@ -0,0 +1,19 @@
+import Image from "next/image";
+import Link from "next/link";
+
+export default function NoDataFounded() {
+ const imageUrl = `/images/no-data-founded/${Math.floor(Math.random() * 6) + 1}.jpg`;
+
+ return (
+
+
+
No Data founded!
+
+ );
+}
diff --git a/src/app/(routes)/blog/components/pagination/pagination.tsx b/src/app/(routes)/blog/components/pagination/pagination.tsx
new file mode 100644
index 0000000..163cc92
--- /dev/null
+++ b/src/app/(routes)/blog/components/pagination/pagination.tsx
@@ -0,0 +1,140 @@
+// components/Pagination.tsx
+"use client";
+
+import Link from "next/link";
+import { useSearchParams } from "next/navigation";
+import React from "react";
+
+interface Meta {
+ current_page: number;
+ last_page: number;
+ total: number; // اضافه کردن total برای بررسی وجود داده
+}
+
+interface PaginationProps {
+ meta: Meta;
+}
+
+const Pagination: React.FC = ({ meta }) => {
+ const { current_page, last_page, total } = meta;
+ const searchParams = useSearchParams();
+
+ // اگر هیچ دادهای وجود نداشته باشد یا تنها یک صفحه باشد، کامپوننت را رندر نکن
+ if (total === 0 || last_page <= 1) {
+ return null;
+ }
+
+ const generatePageLink = (page: number): string => {
+ const params = new URLSearchParams(searchParams.toString());
+ params.set("page", page.toString());
+ return `/blog/categories?${params.toString()}`;
+ };
+
+ const renderPageNumbers = (): (JSX.Element | string)[] => {
+ const pages: JSX.Element[] = [];
+ const delta = 1; // تعداد صفحات اطراف صفحه فعلی که نمایش داده شوند
+ const range: number[] = [];
+ const rangeWithDots: (number | string)[] = [];
+ let previous: number | undefined;
+
+ for (let i = 1; i <= last_page; i++) {
+ if (
+ i === 1 ||
+ i === last_page ||
+ (i >= current_page - delta && i <= current_page + delta)
+ ) {
+ range.push(i);
+ }
+ }
+
+ for (let i of range) {
+ if (previous) {
+ if (i - previous === 2) {
+ rangeWithDots.push(previous + 1);
+ } else if (i - previous > 2) {
+ rangeWithDots.push("...");
+ }
+ }
+ rangeWithDots.push(i);
+ previous = i;
+ }
+
+ return rangeWithDots.map((page, index) => {
+ if (page === "...") {
+ return (
+
+ ...
+
+ );
+ } else {
+ return (
+
+ {page}
+
+ );
+ }
+ });
+ };
+
+ return (
+
+ {/* First Page */}
+ {current_page > 1 && (
+
+ First
+
+ )}
+
+ {/* Previous Page */}
+ {current_page > 1 && (
+
+ {"<"}
+
+ )}
+
+ {/* Page Numbers */}
+ {renderPageNumbers()}
+
+ {/* Next Page */}
+ {current_page < last_page && (
+
+ {">"}
+
+ )}
+
+ {/* Last Page */}
+ {current_page < last_page && (
+
+ Last
+
+ )}
+
+ );
+};
+
+export default Pagination;
diff --git a/src/app/types/types.ts b/src/app/types/types.ts
index 466059f..6167afb 100644
--- a/src/app/types/types.ts
+++ b/src/app/types/types.ts
@@ -19,7 +19,11 @@ export type CategoryType = {
updated_at: string;
};
-export type CategoriesListType = { data: CategoryType[] };
+export type CategoriesListType = {
+ data: CategoryType[];
+ meta: any;
+ links: any;
+};
// تعریف نوع Tag
export type TagType = {
@@ -52,6 +56,11 @@ export type categorySlugPropsType = {
params: { categorySlug: string };
};
+export type categoryPropsType = {
+ params: { categorySlug: string };
+ searchParams: any;
+};
+
export type PaginationType = {
total: number;
per_page: number;