api project

This commit is contained in:
zahravaziri
2025-06-10 17:30:21 +03:30
parent 3e9143f32c
commit ab37893d1b
11 changed files with 172 additions and 278 deletions
+23 -6
View File
@@ -1,21 +1,38 @@
import { IProjectCardProps } from '@/app/api/projects/data';
import images from '@/assets/images/images';
import InnerPageBanner from '@/components/layout/innerPages/banner';
import ProjectsGrid from '@/components/pages/project/ProjectGrid';
import ProjectsGridView from '@/components/pages/project/projectGridView';
import { IPageParams } from '@/models/layout';
import { getProjects } from '@/services/projects';
import { getTranslations } from 'next-intl/server';
export default async function Projects({ params }: { params: IPageParams }) {
export default async function ProjectsPage({
params,
}: {
params: IPageParams;
}) {
const { locale } = await params;
const t = await getTranslations({ locale });
const projects: IProjectCardProps[] = await getProjects();
console.log(projects, 'proj');
return (
<main className="flex flex-col items-center justify-between">
<main>
<InnerPageBanner
title={t('pages_projects_title')}
imageSrc={images.blogBanner.src}
imageSrc={images.aboutBanner.src}
/>
<ProjectsGrid />
<div className="container-fluid mx-auto my-24">
<ProjectsGridView />
{/* <div className="grid w-full grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3">
{projects?.map((project, index) => (
<>
yyy {project.title}
<ProjectsGrid key={index} {...project} />
</>
))}
</div> */}
</div>
</main>
);
}
-118
View File
@@ -1,118 +0,0 @@
export const productCategories = [
{
id: '1',
title: 'Ghazaghi',
fa_title: 'قزاقی',
icon: 'categoryGhazaghi',
typesCount: 22,
priceTypeTitle: 'Economy',
fa_priceTypeTitle: 'اقتصادی',
bestForTitle: 'Best For Interior Part',
fa_bestForTitle: 'Best For Interior Part',
fa_description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
},
{
id: '2',
title: 'Ghermez',
fa_title: 'قرمز',
icon: 'categoryGhermez',
typesCount: 12,
priceTypeTitle: 'Luxury',
fa_priceTypeTitle: 'لاکچری',
bestForTitle: 'Best For Exterior Part',
fa_bestForTitle: 'Best For Exterior Part',
fa_description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
},
{
id: '3',
title: 'oryZard',
fa_title: 'زرد',
icon: 'categoryZard',
typesCount: 11,
priceTypeTitle: 'Economy',
fa_priceTypeTitle: 'اقتصادی',
bestForTitle: 'Best For Facing',
fa_bestForTitle: 'Best For Facing',
fa_description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
},
{
id: '40',
title: 'Semirom',
fa_title: 'سمیرم',
icon: 'categorySemirom',
typesCount: 40,
priceTypeTitle: 'Economy',
fa_priceTypeTitle: 'اقتصادی',
bestForTitle: 'Best For Building',
fa_bestForTitle: 'Best For Building',
fa_description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
description: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`,
},
] as APIProductCategoryEntity[];
interface APIProductCategoryEntity {
id: string;
title: string;
fa_title?: string;
icon: string;
typesCount: number;
priceTypeTitle: string;
fa_priceTypeTitle?: string;
bestForTitle: string;
fa_bestForTitle?: string;
fa_description?: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`;
description?: `Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features
Facing bricks, also known as face bricks or veneer bricks, are specially designed for visible areas of a building, primarily the exterior facades, but also for interior walls where aesthetics are important. Unlike common bricks which are often covered by plaster or other materials, facing bricks are chosen for their visual appeal and ability to withstand environmental conditions.
Facing Bricks: Characteristics and Features`;
}
-51
View File
@@ -1,51 +0,0 @@
import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { productCategories } from './data';
export async function GET(request: Request) {
let data = productCategories;
const cookieStore = await cookies();
const lang = (await cookieStore).get('lang')?.value || 'fa';
if (lang === 'fa') {
data = productCategories.map(
({
id,
title,
fa_title,
icon,
typesCount,
priceTypeTitle,
fa_priceTypeTitle,
bestForTitle,
fa_bestForTitle,
description,
fa_description,
}) => {
if (lang === 'fa') {
return {
id,
icon,
typesCount,
title: fa_title || title,
priceTypeTitle: fa_priceTypeTitle || priceTypeTitle,
bestForTitle: fa_bestForTitle || bestForTitle,
description: fa_description || description,
};
}
return {
id,
icon,
typesCount,
title,
priceTypeTitle,
bestForTitle,
description,
};
},
);
}
return NextResponse.json({ data: productCategories });
}
+54
View File
@@ -0,0 +1,54 @@
import images from '@/assets/images/images';
export interface IProjectCardProps {
id:string;
title: string;
fa_title?: string;
imageSrc: string;
link: string;
}
export const projects = [
{
id:'1',
title: 'Sustainable Practices Reducing Waste in Industrial Production',
fa_title: 'روش‌های پایدار برای کاهش ضایعات در تولید صنعتی',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
id:'2',
title: 'Advanced Robotics Revolutionizing Industrial Workflows',
fa_title: 'رباتیک پیشرفته و تحول فرآیندهای صنعتی',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
id:'3',
title: 'Top Benefits of the Robotics in Manufacturing',
fa_title: 'مزایای اصلی استفاده از رباتیک در تولید',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
id:'4',
title: 'Leveraging Data Analytics for Smarter Production',
fa_title: 'استفاده از تحلیل داده برای تولید هوشمندتر',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
id:'5',
title: 'Reducing Operational Costs Through Automation',
fa_title: 'کاهش هزینه‌ها با اتوماسیون',
imageSrc: '/images/post5.jpg',
link: '#',
},
{
id:'6',
title: 'The Advantages of Customized Manufacturing Solutions',
fa_title: 'مزایای راه‌حل‌های سفارشی‌سازی در تولید',
imageSrc: '/images/post6.jpg',
link: '#',
},
] as IProjectCardProps[]
+41
View File
@@ -0,0 +1,41 @@
import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { projects } from './data';
export async function GET(request: Request) {
let data = projects;
const cookieStore = await cookies();
const lang = (await cookieStore).get('lang')?.value || 'fa';
if (lang === 'fa') {
data = projects.map(
({
id,
title,
fa_title,
imageSrc,
link,
}) => {
if (lang === 'fa') {
return {
id,
title: fa_title || title,
imageSrc,
link,
};
}
return {
id,
title,
imageSrc,
link,
};
},
);
}
return NextResponse.json({ data: projects });
}
+10 -43
View File
@@ -1,65 +1,32 @@
import images from '@/assets/images/images';
import SectionTitle from '@/components/layout/sectionTitle';
import { getProductCategories } from '@/services/products';
import Link from 'next/link';
import routeFactory from '@/assets/constants/routeFactory';
import { getTranslations } from 'next-intl/server';
import { TLocales } from '@/models/layout';
import { getProjectCategories } from '@/services/projects';
import { getProjects } from '@/services/projects';
import { IProjectCardProps } from '../project/project';
import ProjectsGrid from '../project/ProjectGrid';
interface Props {
locale: TLocales;
}
export default async function HomePageProjects({ locale }: Props) {
const t = await getTranslations({ locale });
// const projectCategories: IProjectCardProps[] = await getProjectCategories();
const routes = routeFactory(t, locale);
const projects: IProjectCardProps[] = await getProjects();
return (
<div className="w-full">
<div
className={`relative w-full bg-white bg-cover bg-fixed bg-center bg-no-repeat pt-28 pb-48`}
// style={{ backgroundImage: `url(${images.homeProductBack.src})` }}
className={`relative w-full bg-white bg-cover bg-fixed bg-center bg-no-repeat pt-28`}
>
<div className="absolute inset-0 z-10 bg-black opacity-50" />
<div className="relative z-20 container mx-auto grid grid-cols-2 gap-28">
<SectionTitle
title={t('pages_product_categories_title')}
description={t('com_home_products_title')}
reverseColor
title={t('pages_projects_title')}
description={t('com_home_projects_title')}
description_bold={t('com_home_projects_title_bold')}
/>
<h4 className="pt-10 text-base font-extralight tracking-normal text-white">
{t('com_home_products_description')}
<h4 className="pt-10 text-base font-extralight tracking-normal">
{t('com_home_projects_description')}
</h4>
</div>
</div>
<div className="relative top-[-100px] z-20 container mx-auto w-full">
{/* <div className="grid grid-cols-1 gap-8 rounded-4xl bg-gray-50 py-10 shadow-2xl md:grid-cols-2 lg:grid-cols-4">
{projectCategories.map((category, index) => (
<Link
href={'#'}
key={index}
// href={routes.products.route(index)}
>
<div
className={`flex flex-col items-center justify-center gap-4 p-6 text-center ${index ? 'border-s-[1px] border-gray-100' : ''}`}
>
<h3 className="text-xl font-bold text-gray-500">
{category.title}
</h3>
{/* <p className="text-lg font-light text-gray-400">
{t('com_products_category_types_count', {
count: category.typesCount,
})}
</p>
</div>
</Link>
))}
</div>*/}
<ProjectsGrid projects={projects?.slice(-4)} />
</div>
</div>
);
+3 -36
View File
@@ -1,42 +1,9 @@
import images from '@/assets/images/images';
import Image from 'next/image';
import Link from 'next/link';
import { IProjectCardProps } from './project';
import { getProjects } from '@/services/projects';
const projects = [
{
title: 'Sustainable Practices Reducing Waste in Industrial Production',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
title: 'Advanced Robotics Revolutionizing Industrial Workflows',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
title: 'Top Benefits of the Robotics in Manufacturing',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
title: 'Leveraging Data Analytics for Smarter Production',
imageSrc: images.projectImg_1.src,
link: '#',
},
{
title: 'Reducing Operational Costs Through Automation',
imageSrc: '/images/post5.jpg',
link: '#',
},
{
title: 'The Advantages of Customized Manufacturing Solutions',
imageSrc: '/images/post6.jpg',
link: '#',
},
] as IProjectCardProps[];
export default function ProjectsGrid() {
export default async function ProjectsGrid({ projects }) {
return (
<div className="container mx-auto grid grid-cols-1 gap-6 px-4 py-14 md:grid-cols-2 md:py-28">
{projects.map((project, index) => (
@@ -45,7 +12,7 @@ export default function ProjectsGrid() {
key={index}
className="overflow-hidden bg-white"
>
<div className="relative aspect-[1.09] w-full overflow-hidden rounded-4xl">
<div className="relative aspect-[1.4] w-full overflow-hidden rounded-4xl">
<Image
src={project.imageSrc}
alt={project.title}
@@ -0,0 +1,14 @@
import { getProjects } from '@/services/projects';
import { IProjectCardProps } from './project';
import ProjectsGrid from './ProjectGrid';
export default async function ProjectsGridView() {
const projects: IProjectCardProps[] = await getProjects();
return (
<>
<ProjectsGrid projects={projects} />
{/* <Pagination {...pagination} onPageChange={fetchPage} /> */}
</>
);
}
+17 -24
View File
@@ -5,36 +5,29 @@ import api from '@/lib/axios';
import { IResponse } from '@/models/response';
import { cookies } from 'next/headers';
export async function getProjectCategories() {
export async function getProjects() {
const cookiesStore = await cookies();
return api
.get('/project_categories', {
.get('/projects', {
headers: {
Cookie: cookiesStore.toString(),
},
})
.then(({ data }) => {
return Promise.resolve(data.data);
})
.then(({ data }) => Promise.resolve(data.data))
.catch((error) => Promise.reject(error));
}
export async function getProjects(
categoryId: string,
page = 1,
): Promise<IResponse<IProjectCardProps[]>> {
const cookiesStore = await cookies();
return api
.get(`/project_categories/${categoryId}/projects`, {
headers: {
Cookie: cookiesStore.toString(),
},
params: { page },
})
.then(({ data }) => {
return Promise.resolve(data);
})
.catch((error) => Promise.reject(error));
}
// export async function getProjectById(
// projectId: string,
// ): Promise<IProjectCardProps> {
// const cookiesStore = await cookies();
// return api
// .get(`/projects/${projectId}`, {
// headers: {
// Cookie: cookiesStore.toString(),
// },
// })
// .then(({ data }) => Promise.resolve(data.data))
// .catch((error) => Promise.reject(error));
// }