diff --git a/package-lock.json b/package-lock.json
index 39ebca5..ecd4ae3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,7 @@
"@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-slot": "^1.2.3",
"@tanstack/react-query": "^5.84.1",
+ "@tanstack/react-query-devtools": "^5.85.5",
"axios": "^1.11.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
@@ -1711,9 +1712,19 @@
}
},
"node_modules/@tanstack/query-core": {
- "version": "5.83.1",
- "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.83.1.tgz",
- "integrity": "sha512-OG69LQgT7jSp+5pPuCfzltq/+7l2xoweggjme9vlbCPa/d7D7zaqv5vN/S82SzSYZ4EDLTxNO1PWrv49RAS64Q==",
+ "version": "5.85.5",
+ "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.85.5.tgz",
+ "integrity": "sha512-KO0WTob4JEApv69iYp1eGvfMSUkgw//IpMnq+//cORBzXf0smyRwPLrUvEe5qtAEGjwZTXrjxg+oJNP/C00t6w==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/tannerlinsley"
+ }
+ },
+ "node_modules/@tanstack/query-devtools": {
+ "version": "5.84.0",
+ "resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.84.0.tgz",
+ "integrity": "sha512-fbF3n+z1rqhvd9EoGp5knHkv3p5B2Zml1yNRjh7sNXklngYI5RVIWUrUjZ1RIcEoscarUb0+bOvIs5x9dwzOXQ==",
"license": "MIT",
"funding": {
"type": "github",
@@ -1721,12 +1732,12 @@
}
},
"node_modules/@tanstack/react-query": {
- "version": "5.84.1",
- "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.84.1.tgz",
- "integrity": "sha512-zo7EUygcWJMQfFNWDSG7CBhy8irje/XY0RDVKKV4IQJAysb+ZJkkJPcnQi+KboyGUgT+SQebRFoTqLuTtfoDLw==",
+ "version": "5.85.5",
+ "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.85.5.tgz",
+ "integrity": "sha512-/X4EFNcnPiSs8wM2v+b6DqS5mmGeuJQvxBglmDxl6ZQb5V26ouD2SJYAcC3VjbNwqhY2zjxVD15rDA5nGbMn3A==",
"license": "MIT",
"dependencies": {
- "@tanstack/query-core": "5.83.1"
+ "@tanstack/query-core": "5.85.5"
},
"funding": {
"type": "github",
@@ -1736,6 +1747,23 @@
"react": "^18 || ^19"
}
},
+ "node_modules/@tanstack/react-query-devtools": {
+ "version": "5.85.5",
+ "resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.85.5.tgz",
+ "integrity": "sha512-6Ol6Q+LxrCZlQR4NoI5181r+ptTwnlPG2t7H9Sp3klxTBhYGunONqcgBn2YKRPsaKiYM8pItpKMdMXMEINntMQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@tanstack/query-devtools": "5.84.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/tannerlinsley"
+ },
+ "peerDependencies": {
+ "@tanstack/react-query": "^5.85.5",
+ "react": "^18 || ^19"
+ }
+ },
"node_modules/@tybys/wasm-util": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.0.tgz",
diff --git a/package.json b/package.json
index b8ae233..179f473 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-slot": "^1.2.3",
"@tanstack/react-query": "^5.84.1",
+ "@tanstack/react-query-devtools": "^5.85.5",
"axios": "^1.11.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
diff --git a/src/app/blogs/[id]/page.tsx b/src/app/blogs/[id]/page.tsx
index e158b37..a632af5 100644
--- a/src/app/blogs/[id]/page.tsx
+++ b/src/app/blogs/[id]/page.tsx
@@ -2,7 +2,7 @@ import Image from 'next/image'
import { Calendar, Eye, User } from 'iconsax-react'
import LastPost from '../components/LastPost'
import { NextPage } from 'next'
-import withLayout from '@/hoc/withLayout'
+import Layout from '@/hoc/Layout'
const BlogDetail: NextPage = () => {
return (
@@ -127,4 +127,10 @@ const BlogDetail: NextPage = () => {
)
}
-export default withLayout(BlogDetail)
\ No newline at end of file
+export default function BlogDetailWithLayout() {
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/app/blogs/page.tsx b/src/app/blogs/page.tsx
index 1423bd5..780e82d 100644
--- a/src/app/blogs/page.tsx
+++ b/src/app/blogs/page.tsx
@@ -1,6 +1,6 @@
import { NextPage } from 'next'
+import Layout from '@/hoc/Layout'
import Categories from './components/Categories'
-import withLayout from '@/hoc/withLayout'
import BlogItem from './components/BlogItem'
import LastPost from './components/LastPost'
@@ -21,4 +21,10 @@ const BlogsPage: NextPage = () => {
)
}
-export default withLayout(BlogsPage)
\ No newline at end of file
+export default function BlogsPageWithLayout() {
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx
index 6bc019f..07d7c40 100644
--- a/src/app/cart/page.tsx
+++ b/src/app/cart/page.tsx
@@ -1,7 +1,7 @@
import { Button } from "@/components/ui/button"
import CartItem from "@/app/cart/components/CartItem"
import CartSummary from "@/components/CartSummary"
-import withLayout from "@/hoc/withLayout"
+import Layout from "@/hoc/Layout"
import { Trash } from "iconsax-react"
import { NextPage } from "next"
@@ -47,4 +47,10 @@ const Cart: NextPage = () => {
)
}
-export default withLayout(Cart)
\ No newline at end of file
+export default function CartWithLayout() {
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/app/cart/payment/page.tsx b/src/app/cart/payment/page.tsx
index 01012ef..c795f1a 100644
--- a/src/app/cart/payment/page.tsx
+++ b/src/app/cart/payment/page.tsx
@@ -1,5 +1,5 @@
import CartSummary from '@/components/CartSummary'
-import withLayout from '@/hoc/withLayout'
+import Layout from '@/hoc/Layout'
import { NextPage } from 'next'
import TitleBack from '../components/TitleBack'
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
@@ -45,4 +45,10 @@ const CartPayment: NextPage = () => {
)
}
-export default withLayout(CartPayment)
\ No newline at end of file
+export default function CartPaymentWithLayout() {
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/app/cart/shipping/page.tsx b/src/app/cart/shipping/page.tsx
index 0aa20ae..aa69588 100644
--- a/src/app/cart/shipping/page.tsx
+++ b/src/app/cart/shipping/page.tsx
@@ -1,5 +1,5 @@
import CartSummary from '@/components/CartSummary'
-import withLayout from '@/hoc/withLayout'
+import Layout from '@/hoc/Layout'
import { NextPage } from 'next'
import CartItem from '../components/CartItem'
import TitleBack from '../components/TitleBack'
@@ -46,4 +46,10 @@ const CartShipping: NextPage = () => {
)
}
-export default withLayout(CartShipping)
\ No newline at end of file
+export default function CartShippingWithLayout() {
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/app/home/components/Carousel.tsx b/src/app/home/components/Carousel.tsx
index 9443cb1..788aaf0 100644
--- a/src/app/home/components/Carousel.tsx
+++ b/src/app/home/components/Carousel.tsx
@@ -2,21 +2,35 @@
import { FC } from 'react'
import { Swiper, SwiperSlide } from 'swiper/react';
import { Pagination } from 'swiper/modules';
+import Image from 'next/image';
+import { useGetLanding } from '../hooks/useHomeData';
const Carousel: FC = () => {
+ const { data } = useGetLanding()
+
+ if (!data?.results?.sliders?.desktop || data.results.sliders.desktop.length === 0) {
+ return (
+
+ );
+ }
+
return (
-
-
- 1
-
-
-
-
- 1
-
-
+ {data.results.sliders.desktop.map((slider) => (
+
+
+
+
+
+ ))}
)
diff --git a/src/app/home/components/LatestProducts.tsx b/src/app/home/components/LatestProducts.tsx
index ca444ad..e3f4c37 100644
--- a/src/app/home/components/LatestProducts.tsx
+++ b/src/app/home/components/LatestProducts.tsx
@@ -1,3 +1,4 @@
+'use client'
import { FC } from 'react'
import {
Carousel,
@@ -7,9 +8,17 @@ import {
CarouselPrevious,
} from "@/components/ui/carousel"
import ProductCard from '@/components/ProductCard'
+import { useGetLanding } from '../hooks/useHomeData'
const NewestProducts: FC = () => {
+
+ const { data: landing } = useGetLanding()
+
+ console.log('landing', landing?.results?.
+ latestProducts);
+
+
return (
جدیدترین محصولات
@@ -25,12 +34,14 @@ const NewestProducts: FC = () => {
}}
className="w-full"
>
-
- {Array.from({ length: 5 }).map((_, index) => (
-
-
-
- ))}
+
+ {
+ landing?.results?.latestProducts?.map((product) => (
+
+
+
+ ))
+ }
diff --git a/src/app/home/hooks/useHomeData.ts b/src/app/home/hooks/useHomeData.ts
new file mode 100644
index 0000000..5214fef
--- /dev/null
+++ b/src/app/home/hooks/useHomeData.ts
@@ -0,0 +1,14 @@
+import { useQuery } from "@tanstack/react-query";
+import * as api from "../service/Service";
+
+export const useGetLanding = () => {
+ return useQuery({
+ queryKey: ["landing"],
+ queryFn: api.getLanding,
+ });
+};
+
+export const getLandingQueryOptions = {
+ queryKey: ["landing"],
+ queryFn: api.getLanding,
+};
diff --git a/src/app/home/service/Service.ts b/src/app/home/service/Service.ts
new file mode 100644
index 0000000..f748b52
--- /dev/null
+++ b/src/app/home/service/Service.ts
@@ -0,0 +1,7 @@
+import axios from "@/config/axios";
+import { ILandingResponse } from "@/types/landing.types";
+
+export const getLanding = async (): Promise => {
+ const { data } = await axios.get("/landing");
+ return data;
+};
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 1361b44..d676530 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -4,6 +4,8 @@ import "../../public/css/fontiran.css";
import 'swiper/css';
import QueryProvider from "@/config/QueryProvider";
import ToastContainer from "@/components/Toast";
+import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
+
export const metadata: Metadata = {
title: "Create Next App",
@@ -21,6 +23,7 @@ export default function RootLayout({
{children}
+