web/plugins/bottomSheet/BottomSheetLogOut.jsx

45 lines
1.2 KiB
React
Raw Normal View History

2024-02-16 18:23:02 +03:30
"use client";
import AppContext from "@ctx/AppContext";
import { useRouter } from "next/navigation";
2024-02-16 19:36:30 +03:30
import { useContext } from "react";
2024-02-16 18:23:02 +03:30
import { BottomSheet } from "react-spring-bottom-sheet";
const BottomSheetLogOut = ({ id }) => {
const CTX = useContext(AppContext);
const cart = CTX.state.cart;
const router = useRouter();
const handleLogOut = async () => {
localStorage.removeItem("token");
2024-02-22 20:45:50 +03:30
CTX.setProfile([]);
CTX.setBottomSheetLogOutOpen(false);
2024-02-16 18:23:02 +03:30
router.push("/");
};
return (
<BottomSheet
open={CTX.state.bottomSheetLogOutOpen}
onDismiss={() => CTX.setBottomSheetLogOutOpen(false)}
className={"z-50 relative"}
>
<div className="text-center p-3">
<p className="mb-0 text-sm pb-3">
آیا از خروج حساب کاربری اطمینان دارید ؟{" "}
</p>
</div>
<div className="xs:w-full lg:w-3/12 mx-auto p-3 ">
<button
className="btn bg-red-500 text-white text-sm w-full py-3 rounded-3xl"
onClick={() => handleLogOut()}
>
خروج{" "}
</button>
</div>
</BottomSheet>
);
};
export default BottomSheetLogOut;