diff --git a/src/components/Modal/LogoutUserModal/index.tsx b/src/components/Modal/LogoutUserModal/index.tsx new file mode 100644 index 0000000..58ea293 --- /dev/null +++ b/src/components/Modal/LogoutUserModal/index.tsx @@ -0,0 +1,98 @@ +import { request } from "@/utils/request"; +import { Dialog, Transition } from "@headlessui/react"; +import { Fragment, useState } from "react"; +import { toast } from "react-toastify"; +import Cookies from "universal-cookie"; +import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query"; +import { useRouter } from "next/router"; + +export default function LogoutUserModal({ + isOpenUserLogoutModal, setIsOpenUserLogoutModal +}) { + const cookie = new Cookies(); + const router = useRouter(); + console.log(isOpenUserLogoutModal); + + // const isModalOpen = isOpenDeleteModal ? true : false; + + function closeModal() { + setIsOpenUserLogoutModal(false); + } + + const handleExit = () => { + cookie.remove("userID"); + cookie.remove("userToken"); + cookie.remove("refreshToken"); + setIsOpenUserLogoutModal(false); + }; + + return ( + <> + + + +
+ + +
+
+ + + + خروج + +
+

+ از خروج اطمینان دارید؟ +

+
+ +
+ + +
+
+
+
+
+
+
+ + ); +} diff --git a/src/layout/MainLayout/Navbar/index.tsx b/src/layout/MainLayout/Navbar/index.tsx index 349fbed..9fd1513 100644 --- a/src/layout/MainLayout/Navbar/index.tsx +++ b/src/layout/MainLayout/Navbar/index.tsx @@ -9,6 +9,7 @@ import { CiShoppingCart } from "react-icons/ci"; import Cookies from "universal-cookie"; import SearchBoxProducts from "./../../../components/SearchBox/index"; import { useDispatch, useSelector } from "react-redux"; +import LogoutUserModal from "@/components/Modal/LogoutUserModal"; // useEffect(() => { // const getData = async () => { @@ -50,7 +51,7 @@ import { useDispatch, useSelector } from "react-redux"; const Navbar = () => { - + const [isOpenUserLogoutModal, setIsOpenUserLogoutModal] = useState(false); const cart = useSelector((state) => state.cartSlices.CartProducts); console.log(cart.length); const cookie = new Cookies(); @@ -70,10 +71,7 @@ const Navbar = () => { if (isLoadingcategory) { return
Loading...
; } - // if (isError1) { - // return
Error:{error1}
; - // } - + // console.log(data1.categories); const toggleDropdown = () => { @@ -81,9 +79,7 @@ const Navbar = () => { }; // ========================================================= const handleLogout=()=>{ - cookie.remove("userID") - cookie.remove("userToken") - cookie.remove("refreshToken") + setIsOpenUserLogoutModal(true) } // ======================================================================= @@ -162,6 +158,7 @@ const handleLogout=()=>{ setOpenSerchBox={setOpenSerchBox} openSerchBox={openSerchBox} /> + {isOpenUserLogoutModal && } ); };