building errors fixed
This commit is contained in:
parent
3f231d2c47
commit
19ff490836
@ -9,7 +9,6 @@ import Pagination from "../components/pagination/pagination";
|
||||
import NoDataFounded from "../components/no-data-founded/noDataFounded";
|
||||
|
||||
export default async function Categories({
|
||||
params,
|
||||
searchParams,
|
||||
}: categoryPropsType) {
|
||||
const CategoriesData: CategoriesListType = await fetch(
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
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`;
|
||||
|
||||
@ -32,7 +32,6 @@ const Pagination: React.FC<PaginationProps> = ({ meta, baseUrl }) => {
|
||||
};
|
||||
|
||||
const renderPageNumbers = (): (JSX.Element | string)[] => {
|
||||
const pages: JSX.Element[] = [];
|
||||
const delta = 1; // تعداد صفحات اطراف صفحه فعلی که نمایش داده شوند
|
||||
const range: number[] = [];
|
||||
const rangeWithDots: (number | string)[] = [];
|
||||
@ -48,7 +47,7 @@ const Pagination: React.FC<PaginationProps> = ({ meta, baseUrl }) => {
|
||||
}
|
||||
}
|
||||
|
||||
for (let i of range) {
|
||||
for (const i of range) {
|
||||
if (previous) {
|
||||
if (i - previous === 2) {
|
||||
rangeWithDots.push(previous + 1);
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import { FilteredPostsPagepropsType, PostType } from "@/app/types/types";
|
||||
import {
|
||||
FilteredPostsDataType,
|
||||
FilteredPostsPagepropsType,
|
||||
PostType,
|
||||
} from "@/app/types/types";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import NoDataFounded from "../../components/no-data-founded/noDataFounded";
|
||||
@ -23,7 +27,7 @@ export default async function FilteredPosts({
|
||||
filteredPostApiUrl = "";
|
||||
}
|
||||
|
||||
let FilteredPostsData: { data: PostType[]; link: any; meta: any };
|
||||
let FilteredPostsData: FilteredPostsDataType;
|
||||
|
||||
if (filteredPostApiUrl !== "") {
|
||||
FilteredPostsData = await fetch(
|
||||
@ -33,7 +37,20 @@ export default async function FilteredPosts({
|
||||
},
|
||||
).then((res) => res.json());
|
||||
} else {
|
||||
FilteredPostsData = { data: [], meta: null, link: null };
|
||||
FilteredPostsData = {
|
||||
data: [],
|
||||
links: {
|
||||
first: "",
|
||||
last: "",
|
||||
prev: null,
|
||||
next: "",
|
||||
},
|
||||
meta: {
|
||||
total: 0,
|
||||
last_page: 0,
|
||||
current_page: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -21,8 +21,8 @@ export type CategoryType = {
|
||||
|
||||
export type CategoriesListType = {
|
||||
data: CategoryType[];
|
||||
meta: any;
|
||||
links: any;
|
||||
meta: MetaType;
|
||||
links: LinksType;
|
||||
};
|
||||
|
||||
// تعریف نوع Tag
|
||||
@ -54,12 +54,12 @@ export type PostType = {
|
||||
|
||||
export type categorySlugPropsType = {
|
||||
params: { categorySlug: string };
|
||||
searchParams: any;
|
||||
searchParams: SearchParams;
|
||||
};
|
||||
|
||||
export type categoryPropsType = {
|
||||
params: { categorySlug: string };
|
||||
searchParams: any;
|
||||
searchParams: SearchParams;
|
||||
};
|
||||
|
||||
export type PaginationType = {
|
||||
@ -74,13 +74,18 @@ export type PaginationType = {
|
||||
export type CategoryDataType = {
|
||||
category: CategoryType;
|
||||
posts: PostType[];
|
||||
meta: any;
|
||||
links: any;
|
||||
meta: MetaType;
|
||||
links: LinksType;
|
||||
};
|
||||
|
||||
export type FilteredPostsPagepropsType = {
|
||||
params: { filter: string };
|
||||
searchParams: any;
|
||||
searchParams: SearchParams;
|
||||
};
|
||||
|
||||
export type SearchParams = {
|
||||
per_page: string;
|
||||
page: string;
|
||||
};
|
||||
|
||||
export type PostSlugPagepropsType = {
|
||||
@ -91,3 +96,22 @@ export type PostSlugPagePostType = {
|
||||
post: PostType;
|
||||
related_posts: PostType[];
|
||||
};
|
||||
|
||||
export type MetaType = {
|
||||
total: number;
|
||||
last_page: number;
|
||||
current_page: number;
|
||||
};
|
||||
|
||||
export type LinksType = {
|
||||
first: string;
|
||||
last: string;
|
||||
prev: null | string;
|
||||
next: string;
|
||||
};
|
||||
|
||||
export type FilteredPostsDataType = {
|
||||
data: [];
|
||||
links: LinksType;
|
||||
meta: MetaType;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user