-
+
-
+
{" "}
-
+
-
ثانیه
+
ثانیه
);
};
-export default TimerDown;
+export default TimerDownBlog;
diff --git a/components/TimerDownBlog/TimerDown.jsx b/components/TimerDownBlog/TimerDown.jsx
new file mode 100644
index 0000000..445da7c
--- /dev/null
+++ b/components/TimerDownBlog/TimerDown.jsx
@@ -0,0 +1,103 @@
+"use client";
+import Link from "next/link";
+import PersianNumber from "plugins/PersianNumber";
+import { useEffect, useState } from "react";
+
+const TimerDown = () => {
+ const [timeRemaining, setTimeRemaining] = useState({
+ days: 0,
+ hours: 0,
+ minutes: 0,
+ seconds: 0,
+ milliseconds: 0,
+ });
+
+ useEffect(() => {
+ const calculateTimeRemaining = () => {
+ // Get current date and time
+ const now = new Date();
+
+ // Calculate yesterday's date
+ const yesterday = new Date(now);
+ yesterday.setDate(now.getDate() - 1);
+ yesterday.setHours(23, 59, 0, 0); // Set time to 23:59:00
+
+ // Calculate tomorrow's date
+ const tomorrow = new Date(now);
+ tomorrow.setDate(now.getDate() + 1);
+ tomorrow.setHours(23, 59, 0, 0); // Set time to 23:59:00
+
+ // Calculate time difference
+ const difference = tomorrow - now;
+
+ // Convert time difference to days, hours, minutes, seconds, and milliseconds
+ const days = Math.floor(difference / (1000 * 60 * 60 * 24));
+ const hours = Math.floor(
+ (difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
+ );
+ const minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
+ const seconds = Math.floor((difference % (1000 * 60)) / 1000);
+ const milliseconds = difference % 1000;
+
+ // Update state
+ setTimeRemaining({ days, hours, minutes, seconds, milliseconds });
+ };
+
+ // Call calculateTimeRemaining once to set initial state
+ calculateTimeRemaining();
+
+ // Update time remaining every second
+ const intervalId = setInterval(calculateTimeRemaining, 1000);
+
+ // Clean up interval on component unmount
+ return () => clearInterval(intervalId);
+ }, []);
+
+ return (
+
+
+
+
+
+
+
+ {" "}
+
+
+
+
ثانیه
+
+
+
+ );
+};
+
+export default TimerDown;
diff --git a/package-lock.json b/package-lock.json
index a5c26e7..699a249 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4649,6 +4649,30 @@
}
}
},
+ "node_modules/react-spring-bottom-sheet/node_modules/react-dom": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
+ "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
+ "peer": true,
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "scheduler": "^0.20.2"
+ },
+ "peerDependencies": {
+ "react": "17.0.2"
+ }
+ },
+ "node_modules/react-spring-bottom-sheet/node_modules/scheduler": {
+ "version": "0.20.2",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
+ "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
+ "peer": true,
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ }
+ },
"node_modules/react-toastify": {
"version": "9.1.3",
"resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.3.tgz",
@@ -5547,6 +5571,20 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/typescript": {
+ "version": "5.4.5",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
+ "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
+ "dev": true,
+ "peer": true,
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=14.17"
+ }
+ },
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
diff --git a/src/app/603413.txt b/src/app/603413.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/app/blogs/[...id]/page.jsx b/src/app/blogs/[...id]/page.jsx
index 2d76191..5aec8fa 100644
--- a/src/app/blogs/[...id]/page.jsx
+++ b/src/app/blogs/[...id]/page.jsx
@@ -2,7 +2,9 @@ import BlogData from "@comp/Blog/BlogData/page";
import React from "react";
async function getData(id) {
- const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/blog/${id}`);
+ const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/blog/${id}`, {
+ cache: "no-cache",
+ });
const post = await res.json();
return post;
}
diff --git a/src/app/blogs/page.jsx b/src/app/blogs/page.jsx
index 5179a43..8afeb6a 100644
--- a/src/app/blogs/page.jsx
+++ b/src/app/blogs/page.jsx
@@ -11,13 +11,18 @@ async function getData(sParams) {
const res = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/blog?` +
- new URLSearchParams({ ...query })
+ new URLSearchParams({ ...query }),
+ {
+ cache: "no-cache",
+ }
// ?page=${params.page ?? 0}
// { cache: "no-cache" }
);
const post = await res.json();
//
+ console.log("post", post);
+
return post;
}
diff --git a/src/app/categories/[...id]/page.jsx b/src/app/categories/[...id]/page.jsx
index cb78cf4..b78aebe 100644
--- a/src/app/categories/[...id]/page.jsx
+++ b/src/app/categories/[...id]/page.jsx
@@ -63,7 +63,10 @@ const fetchProducts = async (categoryId, searchParams) => {
const res = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/product?` +
new URLSearchParams({ ...query }) +
- brandIdsQuery
+ brandIdsQuery,
+ {
+ cache: "no-cache",
+ }
);
if (!res.ok) return [];
const products = await res.json();
diff --git a/src/app/page.jsx b/src/app/page.jsx
index 95cda91..b4e05a9 100644
--- a/src/app/page.jsx
+++ b/src/app/page.jsx
@@ -7,41 +7,21 @@ import HeroSection from "@comp/LandingPage/HeroSection/page";
import HomeSection from "@comp/LandingPage/HomeSection/page";
import SurpriseSection from "@comp/LandingPage/SurpriseSection/page";
import Navbar from "@comp/Navbar/page";
+import AppContext from "@ctx/AppContext";
import Head from "next/head";
-import { useEffect, useState } from "react";
+import { useContext, useEffect, useState } from "react";
export default function Page() {
- const [specialOfferData, setSpecialOfferData] = useState([]);
- const [cosmeticData, setCosmeticData] = useState([]);
- const [HomeCosmeticData, setHomeCosmeticData] = useState([]);
- const fetchSpecialOffer = async () => {
- const res = await fetch(
- `${process.env.NEXT_PUBLIC_API_URL}/product?page=0&specialOffer=true`
- );
- const specialOffer = await res.json();
- setSpecialOfferData(specialOffer);
- };
+ const CTX = useContext(AppContext);
- const fetchCosmetic = async () => {
- const res = await fetch(
- `${process.env.NEXT_PUBLIC_API_URL}/product?page=0&categoryId=553af942-7a14-4757-9a03-a3ebec6c865a`
- );
- const Cosmetic = await res.json();
- setCosmeticData(Cosmetic);
- };
-
- const fetchHomeCosmetic = async () => {
- const res = await fetch(
- `${process.env.NEXT_PUBLIC_API_URL}/product?page=0&categoryId=effe5d98-d4b7-47e1-9bfb-4d3c77ab3347`
- );
- const HomeCosmetic = await res.json();
- setHomeCosmeticData(HomeCosmetic);
- };
+ const specialOfferData = CTX.state.specialOfferData;
+ const cosmeticData = CTX.state.cosmeticData;
+ const HomeCosmeticData = CTX.state.HomeCosmeticData;
useEffect(() => {
- fetchSpecialOffer();
- fetchCosmetic();
- fetchHomeCosmetic();
+ CTX.fetchSpecialOffer();
+ CTX.fetchCosmetic();
+ CTX.fetchHomeCosmetic();
}, []);
return (
<>
diff --git a/src/app/products/[...id]/page.jsx b/src/app/products/[...id]/page.jsx
index 1f35c20..523ac1a 100644
--- a/src/app/products/[...id]/page.jsx
+++ b/src/app/products/[...id]/page.jsx
@@ -1,8 +1,11 @@
import ProductData from "@comp/AppsComponent/ProductData/page";
async function getData(id) {
- const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/product/${id}`);
+ const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/product/${id}`, {
+ cache: "no-cache",
+ });
const post = await res.json();
+ console.log("object11", post);
return post;
}