data?.results?.banners?.[1]?.linkUrl && window.open(data.results.banners[1].linkUrl, '_blank')}>
-
+
+
+
+
-
data?.results?.banners?.[2]?.linkUrl && window.open(data.results.banners[2].linkUrl, '_blank')}>
-
+
+
+
+
-
data?.results?.banners?.[0]?.linkUrl && window.open(data.results.banners[0].linkUrl, '_blank')}>
-
+
+
+
+
)
diff --git a/src/app/home/components/Banners4.tsx b/src/app/home/components/Banners4.tsx
index aa23669..1cf0cf0 100644
--- a/src/app/home/components/Banners4.tsx
+++ b/src/app/home/components/Banners4.tsx
@@ -2,6 +2,7 @@
import { FC } from 'react'
import { useGetLanding } from '../hooks/useHomeData'
import Image from 'next/image'
+import Link from 'next/link'
const Banners4: FC = () => {
const { data } = useGetLanding()
@@ -9,20 +10,28 @@ const Banners4: FC = () => {
return (
diff --git a/src/app/home/components/Carousel.tsx b/src/app/home/components/Carousel.tsx
index b3b408f..7b92cb0 100644
--- a/src/app/home/components/Carousel.tsx
+++ b/src/app/home/components/Carousel.tsx
@@ -3,6 +3,7 @@ import { FC, useState, useEffect } from 'react'
import { Swiper, SwiperSlide } from 'swiper/react';
import { Pagination } from 'swiper/modules';
import Image from 'next/image';
+import Link from 'next/link';
import { useGetLanding } from '../hooks/useHomeData';
const Carousel: FC = () => {
@@ -32,17 +33,25 @@ const Carousel: FC = () => {
{sliders.map((slider) => (
- slider.linkUrl && window.open(slider.linkUrl, '_blank')}
- >
-
-
+ {slider.linkUrl ? (
+
+
+
+ ) : (
+
+
+
+ )}
))}
diff --git a/src/app/home/components/HotOffer.tsx b/src/app/home/components/HotOffer.tsx
index ac69b9f..849f197 100644
--- a/src/app/home/components/HotOffer.tsx
+++ b/src/app/home/components/HotOffer.tsx
@@ -4,9 +4,19 @@ import ProductCard from '@/components/ProductCard'
import Image from 'next/image'
import { Swiper, SwiperSlide } from 'swiper/react'
import { SHOP_CONFIG } from '@/config/const'
+import { useGetLanding } from '../hooks/useHomeData'
const HotOffer: FC = () => {
+
+ const { data } = useGetLanding()
+
+ const incredibleOffers = data?.results?.incredibleOffers || []
+
+ if (!incredibleOffers.length) {
+ return null
+ }
+
return (
@@ -41,18 +51,11 @@ const HotOffer: FC = () => {
},
}}
>
-
-
-
-
-
-
-
-
-
-
-
-
+ {incredibleOffers.map((product) => (
+
+
+
+ ))}
diff --git a/src/app/privacy/service/Service.ts b/src/app/privacy/service/Service.ts
index 0595d78..4bf86e4 100644
--- a/src/app/privacy/service/Service.ts
+++ b/src/app/privacy/service/Service.ts
@@ -1,6 +1,15 @@
import axios from "@/config/axios";
+import { SiteSettingResponse } from "@/app/privacy/types/Types";
-export const getSiteSetting = async (name: string) => {
- const { data } = await axios.get(`/site-setting?name=${name}`);
+export const getSiteSetting = async (
+ name: string
+): Promise
=> {
+ const params = new URLSearchParams();
+ if (name !== "all") {
+ params.append("name", name);
+ }
+ const { data } = await axios.get(
+ `/site-setting${params.toString() ? `?${params.toString()}` : ""}`
+ );
return data;
};
diff --git a/src/app/privacy/types/Types.ts b/src/app/privacy/types/Types.ts
new file mode 100644
index 0000000..7c49064
--- /dev/null
+++ b/src/app/privacy/types/Types.ts
@@ -0,0 +1,39 @@
+export interface DownloadAppDetail {
+ pic: string;
+ url: string;
+ _id: string;
+ id: string;
+}
+
+export interface SocialMediaLink {
+ icon: string;
+ url: string;
+ _id: string;
+ id: string;
+}
+
+export interface SiteSetting {
+ _id: string;
+ siteLogo: string;
+ footerDescription: string;
+ footerAddress: string;
+ footerEmail: string;
+ footerPhone: string;
+ downloadAppDetails: DownloadAppDetail[];
+ socialMediaLinks: SocialMediaLink[];
+ shipmentContent: string;
+ faqContent: string;
+ policyContent: string;
+ returnRulesContent: string;
+ jobsContent: string;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface SiteSettingResponse {
+ status: number;
+ success: boolean;
+ results: {
+ siteSetting: SiteSetting;
+ };
+}
diff --git a/src/app/product/components/BaseInformation.tsx b/src/app/product/components/BaseInformation.tsx
index 1bf8cfe..03a1c37 100644
--- a/src/app/product/components/BaseInformation.tsx
+++ b/src/app/product/components/BaseInformation.tsx
@@ -1,21 +1,34 @@
'use client'
import { Star1 } from 'iconsax-react'
-import { FC, useEffect } from 'react'
-import { Product } from '@/types/product.types'
+import { FC, useEffect, useMemo } from 'react'
+import { Product, Review } from '@/types/product.types'
import Image from 'next/image'
import { clx } from '@/helpers/utils'
import { useProductStore } from '../store/Store'
interface BaseInformationProps {
product: Product
+ reviews?: Review[]
}
-const BaseInformation: FC = ({ product }) => {
+const BaseInformation: FC = ({ product, reviews = [] }) => {
const { setVariantId, variantId } = useProductStore()
const brand = product.brand
+ // محاسبه میانگین امتیاز و تعداد دیدگاهها
+ const { averageRating, reviewsCount } = useMemo(() => {
+ if (!reviews.length) {
+ return { averageRating: 0, reviewsCount: 0 }
+ }
+ const totalRating = reviews.reduce((sum, review) => sum + review.rating, 0)
+ return {
+ averageRating: Number((totalRating / reviews.length).toFixed(1)),
+ reviewsCount: reviews.length
+ }
+ }, [reviews])
+
// تابع برای انتخاب variant
const handleVariantSelect = (variantId: string) => {
setVariantId(variantId)
@@ -43,14 +56,28 @@ const BaseInformation: FC = ({ product }) => {
{brand.title_fa}
-
+ {
+ const reviewsSection = document.getElementById('reviews-section')
+ reviewsSection?.scrollIntoView({ behavior: 'smooth', block: 'start' })
+ }}
+ className='flex items-center gap-1 hover:opacity-80 transition-opacity cursor-pointer'
+ >
- 3.5
-
+
+ {reviewsCount > 0 ? `${averageRating} امتیاز` : '۰ امتیاز'}
+
+
-
- 8 دیدگاه
-
+ {
+ const reviewsSection = document.getElementById('reviews-section')
+ reviewsSection?.scrollIntoView({ behavior: 'smooth', block: 'start' })
+ }}
+ className='text-primary text-xs sm:text-sm hover:underline'
+ >
+ {reviewsCount} دیدگاه
+
{/* نمایش variant ها */}
diff --git a/src/app/product/components/Reviews.tsx b/src/app/product/components/Reviews.tsx
index 7bbe9cb..3df9bb3 100644
--- a/src/app/product/components/Reviews.tsx
+++ b/src/app/product/components/Reviews.tsx
@@ -33,7 +33,7 @@ const Reviews: FC