From ab37893d1b0526d8a44dbc0b0b1d3c651e749c61 Mon Sep 17 00:00:00 2001 From: zahravaziri Date: Tue, 10 Jun 2025 17:30:21 +0330 Subject: [PATCH] api project --- messages/en.d.json.ts | 5 + messages/en.json | 5 + src/app/[locale]/projects/page.tsx | 29 ++++- src/app/api/project_categories/data.ts | 118 ------------------ src/app/api/project_categories/route.ts | 51 -------- src/app/api/projects/data.ts | 54 ++++++++ src/app/api/projects/route.ts | 41 ++++++ src/components/pages/home/Projects.tsx | 53 ++------ src/components/pages/project/ProjectGrid.tsx | 39 +----- .../pages/project/projectGridView.tsx | 14 +++ src/services/projects.ts | 41 +++--- 11 files changed, 172 insertions(+), 278 deletions(-) delete mode 100644 src/app/api/project_categories/data.ts delete mode 100644 src/app/api/project_categories/route.ts create mode 100644 src/app/api/projects/data.ts create mode 100644 src/app/api/projects/route.ts create mode 100644 src/components/pages/project/projectGridView.tsx diff --git a/messages/en.d.json.ts b/messages/en.d.json.ts index 8a7fe58..0fc822e 100644 --- a/messages/en.d.json.ts +++ b/messages/en.d.json.ts @@ -32,6 +32,11 @@ declare const messages: { "com_home_products_title": "The Qualified bricks for Your Projects", "com_home_products_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "com_home_projects_title": "Our successful project", + "com_home_projects_title_bold": "initiatives", + "com_home_projects_description": "Our successful project initiatives showcase our commitment to excellence and innovation across various industries.", + + "footer_title": "Industrial Solutions for a Modern World", "footer_description": "We are committed to providing personalized industrial solutions that meet the unique needs of our clients. Our team of experts is dedicated to delivering high-quality products and services that drive success in today’s competitive market.", "footer_slogan": "We are committed to providing personalized industrial solutions.", diff --git a/messages/en.json b/messages/en.json index 3842d17..f819236 100644 --- a/messages/en.json +++ b/messages/en.json @@ -29,6 +29,11 @@ "com_home_products_title": "The Qualified bricks for Your Projects", "com_home_products_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "com_home_projects_title": "Our successful project", + "com_home_projects_title_bold": "initiatives", + "com_home_projects_description": "Our successful project initiatives showcase our commitment to excellence and innovation across various industries.", + + "footer_title": "Industrial Solutions for a Modern World", "footer_description": "We are committed to providing personalized industrial solutions that meet the unique needs of our clients. Our team of experts is dedicated to delivering high-quality products and services that drive success in today’s competitive market.", "footer_slogan": "We are committed to providing personalized industrial solutions.", diff --git a/src/app/[locale]/projects/page.tsx b/src/app/[locale]/projects/page.tsx index 08d9dda..5045cbe 100644 --- a/src/app/[locale]/projects/page.tsx +++ b/src/app/[locale]/projects/page.tsx @@ -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 ( -
+
- - +
+ + {/*
+ {projects?.map((project, index) => ( + <> + yyy {project.title} + + + ))} +
*/} +
); } diff --git a/src/app/api/project_categories/data.ts b/src/app/api/project_categories/data.ts deleted file mode 100644 index bc7c753..0000000 --- a/src/app/api/project_categories/data.ts +++ /dev/null @@ -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`; -} diff --git a/src/app/api/project_categories/route.ts b/src/app/api/project_categories/route.ts deleted file mode 100644 index 4cb1e56..0000000 --- a/src/app/api/project_categories/route.ts +++ /dev/null @@ -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 }); -} diff --git a/src/app/api/projects/data.ts b/src/app/api/projects/data.ts new file mode 100644 index 0000000..ad2d7e9 --- /dev/null +++ b/src/app/api/projects/data.ts @@ -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[] diff --git a/src/app/api/projects/route.ts b/src/app/api/projects/route.ts new file mode 100644 index 0000000..9ee9a70 --- /dev/null +++ b/src/app/api/projects/route.ts @@ -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 }); +} diff --git a/src/components/pages/home/Projects.tsx b/src/components/pages/home/Projects.tsx index 5183947..4143052 100644 --- a/src/components/pages/home/Projects.tsx +++ b/src/components/pages/home/Projects.tsx @@ -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 (
-
-

- {t('com_home_products_description')} +

+ {t('com_home_projects_description')}

-
-
- {/*
- {projectCategories.map((category, index) => ( - -
-

- {category.title} -

- {/*

- {t('com_products_category_types_count', { - count: category.typesCount, - })} -

-
- - ))} -
*/} +
); diff --git a/src/components/pages/project/ProjectGrid.tsx b/src/components/pages/project/ProjectGrid.tsx index ab5ca9b..359671a 100644 --- a/src/components/pages/project/ProjectGrid.tsx +++ b/src/components/pages/project/ProjectGrid.tsx @@ -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 (
{projects.map((project, index) => ( @@ -45,7 +12,7 @@ export default function ProjectsGrid() { key={index} className="overflow-hidden bg-white" > -
+
{project.title} + + {/* */} + + ); +} diff --git a/src/services/projects.ts b/src/services/projects.ts index 9bb20e9..c7594c8 100644 --- a/src/services/projects.ts +++ b/src/services/projects.ts @@ -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> { - 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 { +// const cookiesStore = await cookies(); +// return api +// .get(`/projects/${projectId}`, { +// headers: { +// Cookie: cookiesStore.toString(), +// }, +// }) +// .then(({ data }) => Promise.resolve(data.data)) +// .catch((error) => Promise.reject(error)); +// }