building errors fixed

This commit is contained in:
parsa aghaei 2024-10-14 16:21:14 +03:30
parent 3f231d2c47
commit 19ff490836
5 changed files with 52 additions and 14 deletions

View File

@ -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(

View File

@ -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`;

View File

@ -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);

View File

@ -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 (

View File

@ -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;
};