-
-
-
-
-
-
-
-
-
-
- مشاوره رایگان
-
-
-
-
-
-
-
- قیمت تخمین{" "}
-
-
-
-
-
+
+
+ {1 == 2 ? (
+
+ ) : (
+
+
+
setSmallDashboard(!smallDashboard)}
+ >
+
حسین معصومی پور
+
+
+ {smallDashboard && (
+
setSmallDashboard(true)}
+ onMouseLeave={() => setSmallDashboard(false)}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ خروج{" "}
+
+
+
+
+
+
+
+ )}
+
+
+ )}
+
+
+
CTX.setBottomSheetCart(true)}
+ >
+
+
+
+
+
diff --git a/package-lock.json b/package-lock.json
index 669133d..f1db0ab 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,6 +18,7 @@
"react-dom": "^18",
"react-grid-gallery": "^1.0.1-alpha.0",
"react-image-gallery": "^1.3.0",
+ "react-spring-bottom-sheet": "^3.4.1",
"react-toastify": "^9.1.3",
"swiper": "^11.0.5"
},
@@ -228,6 +229,11 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
+ "node_modules/@juggle/resize-observer": {
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.4.0.tgz",
+ "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA=="
+ },
"node_modules/@next/env": {
"version": "14.0.4",
"resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.4.tgz",
@@ -432,6 +438,11 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true
},
+ "node_modules/@types/warning": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.3.tgz",
+ "integrity": "sha512-D1XC7WK8K+zZEveUPY+cf4+kgauk8N4eHr/XIHXGlGYkHLud6hK9lYfZk1ry1TNh798cZUCgb6MqGEG8DkJt6Q=="
+ },
"node_modules/@typescript-eslint/parser": {
"version": "6.14.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.14.0.tgz",
@@ -935,6 +946,11 @@
"readable-stream": "^3.4.0"
}
},
+ "node_modules/body-scroll-lock": {
+ "version": "3.1.5",
+ "resolved": "https://registry.npmjs.org/body-scroll-lock/-/body-scroll-lock-3.1.5.tgz",
+ "integrity": "sha512-Yi1Xaml0EvNA0OYWxXiYNqY24AfWkbA6w5vxE7GWxtKfzIbZM+Qw+aSmkgsbWzbHiy/RCSkUZBplVxTA+E4jJg=="
+ },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -2102,6 +2118,14 @@
"integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==",
"dev": true
},
+ "node_modules/focus-trap": {
+ "version": "6.9.4",
+ "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-6.9.4.tgz",
+ "integrity": "sha512-v2NTsZe2FF59Y+sDykKY+XjqZ0cPfhq/hikWVL88BqLivnNiEffAsac6rP6H45ff9wG9LL5ToiDqrLEP9GX9mw==",
+ "dependencies": {
+ "tabbable": "^5.3.3"
+ }
+ },
"node_modules/follow-redirects": {
"version": "1.15.4",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
@@ -3399,7 +3423,6 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
- "dev": true,
"engines": {
"node": ">=0.10.0"
}
@@ -3870,7 +3893,6 @@
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
- "dev": true,
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
@@ -3988,8 +4010,111 @@
"node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
- "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
- "dev": true
+ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
+ },
+ "node_modules/react-spring": {
+ "version": "8.0.27",
+ "resolved": "https://registry.npmjs.org/react-spring/-/react-spring-8.0.27.tgz",
+ "integrity": "sha512-nDpWBe3ZVezukNRandTeLSPcwwTMjNVu1IDq9qA/AMiUqHuRN4BeSWvKr3eIxxg1vtiYiOLy4FqdfCP5IoP77g==",
+ "dependencies": {
+ "@babel/runtime": "^7.3.1",
+ "prop-types": "^15.5.8"
+ },
+ "peerDependencies": {
+ "react": ">= 16.8.0",
+ "react-dom": ">= 16.8.0"
+ }
+ },
+ "node_modules/react-spring-bottom-sheet": {
+ "version": "3.4.1",
+ "resolved": "https://registry.npmjs.org/react-spring-bottom-sheet/-/react-spring-bottom-sheet-3.4.1.tgz",
+ "integrity": "sha512-yDFqiPMm/fjefjnOe6Q9zxccbCl6HMUKsK5bWgfGHJIj4zmXVKio5d4icQvmOLuwpuCA2pwv4J6nGWS6fUZidQ==",
+ "dependencies": {
+ "@juggle/resize-observer": "^3.2.0",
+ "@reach/portal": "^0.13.0",
+ "@xstate/react": "^1.2.0",
+ "body-scroll-lock": "^3.1.5",
+ "focus-trap": "^6.2.2",
+ "react-spring": "^8.0.27",
+ "react-use-gesture": "^8.0.1",
+ "xstate": "^4.15.1"
+ },
+ "peerDependencies": {
+ "react": "^16.14.0 || 17 || 18"
+ }
+ },
+ "node_modules/react-spring-bottom-sheet/node_modules/@reach/portal": {
+ "version": "0.13.2",
+ "resolved": "https://registry.npmjs.org/@reach/portal/-/portal-0.13.2.tgz",
+ "integrity": "sha512-g74BnCdtuTGthzzHn2cWW+bcyIYb0iIE/yRsm89i8oNzNgpopbkh9UY8TPbhNlys52h7U60s4kpRTmcq+JqsTA==",
+ "dependencies": {
+ "@reach/utils": "0.13.2",
+ "tslib": "^2.1.0"
+ },
+ "peerDependencies": {
+ "react": "^16.8.0 || 17.x",
+ "react-dom": "^16.8.0 || 17.x"
+ }
+ },
+ "node_modules/react-spring-bottom-sheet/node_modules/@reach/portal/node_modules/@reach/utils": {
+ "version": "0.13.2",
+ "resolved": "https://registry.npmjs.org/@reach/utils/-/utils-0.13.2.tgz",
+ "integrity": "sha512-3ir6cN60zvUrwjOJu7C6jec/samqAeyAB12ZADK+qjnmQPdzSYldrFWwDVV5H0WkhbYXR3uh+eImu13hCetNPQ==",
+ "dependencies": {
+ "@types/warning": "^3.0.0",
+ "tslib": "^2.1.0",
+ "warning": "^4.0.3"
+ },
+ "peerDependencies": {
+ "react": "^16.8.0 || 17.x",
+ "react-dom": "^16.8.0 || 17.x"
+ }
+ },
+ "node_modules/react-spring-bottom-sheet/node_modules/@xstate/react": {
+ "version": "1.6.3",
+ "resolved": "https://registry.npmjs.org/@xstate/react/-/react-1.6.3.tgz",
+ "integrity": "sha512-NCUReRHPGvvCvj2yLZUTfR0qVp6+apc8G83oXSjN4rl89ZjyujiKrTff55bze/HrsvCsP/sUJASf2n0nzMF1KQ==",
+ "dependencies": {
+ "use-isomorphic-layout-effect": "^1.0.0",
+ "use-subscription": "^1.3.0"
+ },
+ "peerDependencies": {
+ "@xstate/fsm": "^1.0.0",
+ "react": "^16.8.0 || ^17.0.0",
+ "xstate": "^4.11.0"
+ },
+ "peerDependenciesMeta": {
+ "@xstate/fsm": {
+ "optional": true
+ },
+ "xstate": {
+ "optional": true
+ }
+ }
+ },
+ "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",
@@ -4003,6 +4128,15 @@
"react-dom": ">=16"
}
},
+ "node_modules/react-use-gesture": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/react-use-gesture/-/react-use-gesture-8.0.1.tgz",
+ "integrity": "sha512-CXzUNkulUdgouaAlvAsC5ZVo0fi9KGSBSk81WrE4kOIcJccpANe9zZkAYr5YZZhqpicIFxitsrGVS4wmoMun9A==",
+ "deprecated": "This package is no longer maintained. Please use @use-gesture/react instead",
+ "peerDependencies": {
+ "react": ">= 16.8.0"
+ }
+ },
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
@@ -4591,6 +4725,11 @@
"node": ">= 4.7.0"
}
},
+ "node_modules/tabbable": {
+ "version": "5.3.3",
+ "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-5.3.3.tgz",
+ "integrity": "sha512-QD9qKY3StfbZqWOPLp0++pOrAVb/HbUi5xCc8cUo4XjP19808oaMiDzn0leBY5mCespIBM0CIZePzZjgzR83kA=="
+ },
"node_modules/tailwindcss": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.0.tgz",
@@ -4884,11 +5023,51 @@
"punycode": "^2.1.0"
}
},
+ "node_modules/use-isomorphic-layout-effect": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.2.tgz",
+ "integrity": "sha512-49L8yCO3iGT/ZF9QttjwLF/ZD9Iwto5LnH5LmEdk/6cFmXddqi2ulF0edxTwjj+7mqvpVVGQWvbXZdn32wRSHA==",
+ "peerDependencies": {
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/use-subscription": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/use-subscription/-/use-subscription-1.8.0.tgz",
+ "integrity": "sha512-LISuG0/TmmoDoCRmV5XAqYkd3UCBNM0ML3gGBndze65WITcsExCD3DTvXXTLyNcOC0heFQZzluW88bN/oC1DQQ==",
+ "dependencies": {
+ "use-sync-external-store": "^1.2.0"
+ },
+ "peerDependencies": {
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
+ }
+ },
+ "node_modules/use-sync-external-store": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
+ "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==",
+ "peerDependencies": {
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
+ }
+ },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
+ "node_modules/warning": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
+ "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
+ "dependencies": {
+ "loose-envify": "^1.0.0"
+ }
+ },
"node_modules/watchpack": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
@@ -5019,6 +5198,15 @@
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true
},
+ "node_modules/xstate": {
+ "version": "4.38.3",
+ "resolved": "https://registry.npmjs.org/xstate/-/xstate-4.38.3.tgz",
+ "integrity": "sha512-SH7nAaaPQx57dx6qvfcIgqKRXIh4L0A1iYEqim4s1u7c9VoCgzZc+63FY90AKU4ZzOC2cfJzTnpO4zK7fCUzzw==",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/xstate"
+ }
+ },
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
diff --git a/package.json b/package.json
index fd98654..afd2809 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vesmeh",
- "version": "0.1.0",
+ "version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
@@ -19,6 +19,7 @@
"react-dom": "^18",
"react-grid-gallery": "^1.0.1-alpha.0",
"react-image-gallery": "^1.3.0",
+ "react-spring-bottom-sheet": "^3.4.1",
"react-toastify": "^9.1.3",
"swiper": "^11.0.5"
},
diff --git a/plugins/Loading/page.jsx b/plugins/Loading/page.jsx
index 27708d5..82f6e8c 100644
--- a/plugins/Loading/page.jsx
+++ b/plugins/Loading/page.jsx
@@ -1,8 +1,6 @@
+"use client";
import React, { useContext } from "react";
-
import AppContext from "@ctx/AppContext";
-import gif from "@img/loading.gif";
-import Image from "next/image";
const Loading = ({ rateId }) => {
const CTX = useContext(AppContext);
@@ -17,9 +15,6 @@ const Loading = ({ rateId }) => {
>
>
diff --git a/plugins/bottomSheet/BottomSheetCart.jsx b/plugins/bottomSheet/BottomSheetCart.jsx
new file mode 100644
index 0000000..a4c4945
--- /dev/null
+++ b/plugins/bottomSheet/BottomSheetCart.jsx
@@ -0,0 +1,25 @@
+"use client";
+
+import AppContext from "@ctx/AppContext";
+import React, { useContext } from "react";
+import { BottomSheet } from "react-spring-bottom-sheet";
+import { toast } from "react-toastify";
+
+const BottomSheetCart = (props) => {
+ const CTX = useContext(AppContext);
+
+ return (
+
+ );
+};
+
+export default BottomSheetCart;
diff --git a/src/app/categories/[id]/page.jsx b/src/app/categories/[id]/page.jsx
index 3710fa0..f736038 100644
--- a/src/app/categories/[id]/page.jsx
+++ b/src/app/categories/[id]/page.jsx
@@ -1,412 +1,75 @@
"use client";
-import CardCategories from "@comp/Cards/CardCategories/page";
-import CardSurprise from "@comp/Cards/CardSurprise/page";
import Navbar from "@comp/Navbar/page";
-import PersianNumber from "plugins/PersianNumber";
-import React, { useState } from "react";
-import { Switch } from "@headlessui/react";
-import RangeSlider from "plugins/RangeSlider/page";
+import React, { useContext, useEffect, useState } from "react";
import Footer from "@comp/Footer/page";
-import CardCategoriesMobile from "@comp/Cards/CardCategoriesMobile/page";
+import ListProdocts from "@comp/Category/ListProdocts/page";
+import FilterCategoryMobile from "@comp/Category/Mobile/FilterCategoryMobile/page";
+import FilterCategory from "@comp/Category/FilterCategory/page";
+import ListProductsMobile from "@comp/Category/Mobile/ListProductsMobile/page";
+import PaginationCategoory from "@comp/Category/PaginationCategoory/page";
+import AppContext from "@ctx/AppContext";
-const page = () => {
+export default function page({ params }) {
+ // const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/product?page=0`);
+ // const products = await res.json();
+ const CTX = useContext(AppContext);
const [isChecked, setIsChecked] = useState(false);
+ const [selectedBrands, setSelectedBrands] = useState([]);
+ const [rangePrice, setRangePrice] = useState([1000, 100]);
+ const [isRangePrice, setIsRangePrice] = useState(false);
+ const [sortBy, setSortBy] = useState(null);
- const handleCheckboxChange = () => {
- setIsChecked(!isChecked);
+ const fetchBarnds = async () => {
+ const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/brand`);
+ const brands = await res.json();
+ CTX.setBrands(brands);
};
- const handleRangeChange = (values) => {
- console.log("Range values:", values);
- };
+ useEffect(() => {
+ CTX.fetchProducts(params.id);
+ fetchBarnds();
+ }, []);
return (
<>
-
-
-
-
-
-
-
+
+
>
);
-};
-
-export default page;
+}
diff --git a/src/app/layout.jsx b/src/app/layout.jsx
index cb2d4f7..b5f5a52 100644
--- a/src/app/layout.jsx
+++ b/src/app/layout.jsx
@@ -1,18 +1,138 @@
+"use client";
import "../../style/globals.css";
import "../../style/fontiran.css";
import "swiper/css";
import "react-image-gallery/styles/css/image-gallery.css";
import Chapar from "plugins/Chapar";
+import AppContext from "@ctx/AppContext";
+import { useEffect, useState } from "react";
+import "react-toastify/dist/ReactToastify.css";
+import { ToastContainer } from "react-toastify";
+import Loading from "plugins/Loading/page";
-export const metadata = {
- title: "Create Next App",
- description: "Generated by create next app",
-};
+export default function RootLayout({ children }) {
+ const [cart, setCart] = useState([]);
+ const [products, setProducts] = useState([]);
+ const [navData, setNavData] = useState([]);
+ const [brands, setBrands] = useState([]);
+ const [loading, setLoading] = useState(false);
+ const [closeNavbar, setCloseNavbar] = useState(false);
+ const [bottomSheetCart, setBottomSheetCart] = useState(false);
+
+ const AddItemToCart = (id, persianName, cost) => {
+ console.log("persianName", persianName);
+ setCart((prevCart) => {
+ // Check if the item is already in the cart
+ const existingItem = prevCart.find((item) => item.id === id);
+
+ if (existingItem) {
+ // If the item is already in the cart, update its count
+ return prevCart.map((item) =>
+ item.id === id ? { ...item, count: item.count + 1 } : item
+ );
+ } else {
+ // If the item is not in the cart, add it with a count of 1
+ return [...prevCart, { id, count: 1, persianName, cost }];
+ }
+ });
+ };
+
+ const RemoveItemFromCart = (id) => {
+ setCart((prevCart) => {
+ // Check if the item is already in the cart
+ const existingItem = prevCart.find((item) => item.id === id);
+
+ if (existingItem) {
+ // If the item is already in the cart
+ if (existingItem.count === 1) {
+ // If the item count is 1, remove it from the cart
+ return prevCart.filter((item) => item.id !== id);
+ } else {
+ // If the item count is greater than 1, update its count
+ return prevCart.map((item) =>
+ item.id === id ? { ...item, count: item.count - 1 } : item
+ );
+ }
+ } else {
+ // If the item is not in the cart, do nothing
+ return prevCart;
+ }
+ });
+ };
+
+ const fetchNavData = async (id) => {
+ const res = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/product/category?sortByMain=true`
+ );
+ const post = await res.json();
+ setNavData(post);
+ };
+
+ const fetchProducts = async (
+ id,
+ selectedBrands,
+ isChecked,
+ minPrice,
+ maxPrice,
+ sort,
+ isRangePrice
+ ) => {
+ const brandIds = selectedBrands?.map((brand) => brand.id);
+
+ const queryString = `page=0${id ? `&categoryId=${id}` : ""}${
+ brandIds?.length > 0 ? `&brandIds=${brandIds?.join("&brandIds=")}` : ""
+ }${isChecked ? `&isActive=${isChecked}` : ""}${
+ isRangePrice ? `&minPrice=${minPrice}` : ""
+ }${isRangePrice ? `&maxPrice=${maxPrice}` : ""}${
+ !!sort ? `&sortBy=${sort}` : ""
+ }`;
+
+ const cleanQueryString = decodeURIComponent(
+ queryString.replace(/\%20/g, " ")
+ );
+ const res = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/product?${cleanQueryString}`
+ );
+ const post = await res.json();
+ setProducts(post);
+ };
+
+ useEffect(() => {
+ fetchNavData();
+ }, []);
-export default async function RootLayout({ children }) {
return (
-
- {children}
-
+
+
+
+ {children}
+
+
+
+
+
);
}
diff --git a/src/app/login/page.jsx b/src/app/login/page.jsx
index 101f514..f4449a0 100644
--- a/src/app/login/page.jsx
+++ b/src/app/login/page.jsx
@@ -1,8 +1,118 @@
-import React from "react";
+"use client";
+import React, { useContext, useState } from "react";
import logo from "../../../public/images/logo.png";
import Image from "next/image";
+import Chapar from "plugins/Chapar";
+import { toast } from "react-toastify";
+import PersianNumber from "plugins/PersianNumber";
+import LoginStep from "@comp/Login/LoginStep";
+import VerifyCodeStep from "@comp/Login/VerifyCodeStep";
+import SignUp from "@comp/Login/SignUp";
+import { useRouter } from "next/navigation";
+import AppContext from "@ctx/AppContext";
const Login = () => {
+ const CTX = useContext(AppContext);
+
+ const [phoneNumber, setPhoneNumber] = useState("");
+ const [verifyCode, setVerifyCode] = useState("");
+ const [firstName, setFirstName] = useState("");
+ const [lastName, setLastName] = useState("");
+ const [stepLogin, setStepLogin] = useState(0);
+
+ const router = useRouter();
+
+ const ConfirmPhoneNumber = async () => {
+ CTX.setLoading(true);
+ try {
+ const data = await Chapar.get(
+ `${process.env.NEXT_PUBLIC_API_URL}/auth/verifycode?phoneNumber=${phoneNumber}`
+ );
+ setStepLogin(1);
+ localStorage.removeItem("token");
+ CTX.setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(" اطلاعات را صحیح وارد کنید ", {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ CTX.setLoading(false);
+ }
+ };
+
+ const LoginWhitVerifyCode = async () => {
+ CTX.setLoading(true);
+
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/auth/login/code`,
+ {
+ userName: phoneNumber,
+ password: null,
+ verifyCode,
+ }
+ );
+ localStorage.setItem("token", "Bearer " + data.access_token);
+
+ console.log(data);
+
+ if (data.user.signUpStatus == 1) {
+ setStepLogin(2);
+ } else if (data.user.signUpStatus == 10) {
+ // setProfile(data);
+ toast.success(` ${data.user.firstName} جان خوش اومدی `, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ router.push("/profile");
+ }
+
+ CTX.setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ CTX.setLoading(false);
+ }
+ };
+
+ const SignUpLogin = async () => {
+ CTX.setLoading(true);
+
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/auth/signup`,
+ { lastName, firstName },
+ {
+ headers: {
+ Authorization: localStorage.getItem("token"),
+ },
+ }
+ );
+
+ CTX.setLoading(false);
+
+ if (data.user.signUpStatus == 10) {
+ // setProfile(data);
+
+ toast.success(` ${data.user.firstName} جان خوش اومدی `, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ localStorage.setItem("token", data.access_token);
+
+ router.push("/profile");
+ }
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ CTX.setLoading(false);
+ }
+ };
+
return (
@@ -12,36 +122,28 @@ const Login = () => {
-
-
ورود / ثبت نام
-
- شماره موبایل خود را وارد کنید
-
-
-
-
-
-
-
- ورود و ثبت نام
-
-
-
-
-
- با ورود و یا ثبت نام در وسمه شما{" "}
-
- شرایط و قوانین
- {" "}
- استفاده از سرویس های سایت شاواز و قوانین حریم خصوصی آن را می
- پذیرید.
-
-
-
-
{" "}
+ {stepLogin == 0 ? (
+
+ ) : stepLogin == 1 ? (
+
+ ) : stepLogin == 2 ? (
+
+ ) : (
+ ""
+ )}