diff --git a/src/app/about/hooks/useAboutData.ts b/src/app/about/hooks/useAboutData.ts new file mode 100644 index 0000000..d955b12 --- /dev/null +++ b/src/app/about/hooks/useAboutData.ts @@ -0,0 +1,11 @@ +import { useQuery } from "@tanstack/react-query"; +import { AboutService } from "../service/Service"; + +export const useAboutData = () => { + return useQuery({ + queryKey: ["about-us"], + queryFn: AboutService.getAboutUs, + staleTime: 5 * 60 * 1000, // 5 دقیقه + gcTime: 10 * 60 * 1000, // 10 دقیقه + }); +}; diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx new file mode 100644 index 0000000..44a9da9 --- /dev/null +++ b/src/app/about/page.tsx @@ -0,0 +1,77 @@ +'use client' + +import Layout from '@/hoc/Layout' +import { NextPage } from 'next' +import { useAboutData } from './hooks/useAboutData' +import PageLoading from '@/components/PageLoading' +import Image from 'next/image' + +const AboutPage: NextPage = () => { + const { data, isLoading, error } = useAboutData() + + if (isLoading) { + return + } + + if (error) { + return ( + +
+

خطا در دریافت اطلاعات

+
+
+ ) + } + + const aboutData = data?.results?.aboutUs || [] + + return ( + +
+ {/* عنوان اصلی */} +
+

+ درباره ی ما +

+
+ + {/* بخش‌های محتوا */} +
+ {aboutData.map((item) => ( +
+ {/* تصویر در سمت چپ */} +
+ {item.title} +
+ + {/* محتوای متنی در سمت راست */} +
+ {/* عنوان بخش */} +

+ {item.title} +

+ + {/* توضیحات */} +

+ {item.description} +

+
+
+ ))} +
+
+
+ ) +} + +export default AboutPage \ No newline at end of file diff --git a/src/app/about/service/Service.ts b/src/app/about/service/Service.ts new file mode 100644 index 0000000..1f9c010 --- /dev/null +++ b/src/app/about/service/Service.ts @@ -0,0 +1,25 @@ +import axiosInstance from "@/config/axios"; + +export interface AboutUsItem { + _id: string; + title: string; + description: string; + imageUrl: string; + createdAt: string; + updatedAt: string; +} + +export interface AboutUsResponse { + status: number; + success: boolean; + results: { + aboutUs: AboutUsItem[]; + }; +} + +export class AboutService { + static async getAboutUs(): Promise { + const response = await axiosInstance.get("/about-us"); + return response.data; + } +}