diff --git a/components/AppHeader/page.jsx b/components/AppHeader/page.jsx index 09c5e26..e2f3ff9 100644 --- a/components/AppHeader/page.jsx +++ b/components/AppHeader/page.jsx @@ -2,6 +2,8 @@ import Avatar from "boring-avatars"; import Link from "next/link"; import { useRouter } from "next/navigation"; import React from "react"; +import { useLongPress } from "@uidotdev/usehooks"; +import { toast } from "react-toastify"; const AppHeader = ({ title, @@ -20,7 +22,24 @@ const AppHeader = ({ userIconData, userIconHref, userRole, + logOut, }) => { + const router = useRouter(); + + const handlelogOut = () => { + localStorage.removeItem("token"); + router.push("/login"); + }; + + const attrs = useLongPress(() => handlelogOut(), { + // onStart: (event) => setSubButtonAction(true), + onFinish: (event) => { + handlelogOut(); + }, + // onCancel: (event) => setSubButtonAction(false), + threshold: 1000, + }); + const icons = [ { iconName: "ACOUNT", @@ -124,6 +143,20 @@ const AppHeader = ({ {!userRole ? (
خروج
+{iconName3}
diff --git a/plugins/BottomSheet/BottomSheetAddUserToPositionShiftPlan.jsx b/plugins/BottomSheet/BottomSheetAddUserToPositionShiftPlan.jsx index 20c3559..7f21789 100644 --- a/plugins/BottomSheet/BottomSheetAddUserToPositionShiftPlan.jsx +++ b/plugins/BottomSheet/BottomSheetAddUserToPositionShiftPlan.jsx @@ -14,13 +14,12 @@ const BottomSheetAddUserToPositionShiftPlan = ({ userAndPositionIds, positionId, positionName, + usersData, }) => { const CTX = useContext(AppContext); const [, forceUpdate] = useState(); - const usersData = CTX.state.usersData; - const validator = useRef( new SimpleReactValidator({ messages: { @@ -36,76 +35,8 @@ const BottomSheetAddUserToPositionShiftPlan = ({ }) ); - // const body = { - // persianName, - // englishName, - // description, - // permissions: permissionsChoose, - // }; - // const bodyUpdate = { - // persianName, - // englishName, - // description, - // permissions: permissionsChoose, - // roleId: roleData.roleId, - // }; - - // const clear = () => { - // setPersianName(""); - // setEnglishName(""); - // setDescription(""); - // CTX.setPermissionsChoose([]); - // }; - - // const handleCreateRole = (update) => { - // if (validator.current.allValid()) { - // if (update == "UPDATE") { - // CTX.UpdateRole(bodyUpdate); - // } else { - // CTX.CreateRole(body); - // } - // } else { - // toast.error("پرکردن همه ی فیلد ها واجب است", { - // position: "bottom-right", - // autoClose: 2000, - // hideProgressBar: false, - // closeOnClick: true, - // pauseOnHover: true, - // draggable: true, - // progress: undefined, - // }); - - // validator.current.showMessages(); - // forceUpdate(1); - // } - // }; - - const handleBottomSheetAddUserToPositionShiftPlan = (e) => { - if (e.type == "OPEN") { - if (!!usersData.length <= 0) { - // User data is not in state, send request to get user - CTX.GetUsers(); - } - } else if (e.type == "CLOSE") { - // clear(); - // CTX.setGoToEditRole(false); - // CTX.setIdEditRole(null); - // CTX.setRoleData([]); - } - }; - - // useEffect(() => { - // if (goToEditRole) { - // setPersianName(roleData.persianName); - // setEnglishName(roleData.englishName); - // setDescription(roleData.description); - // CTX.setPermissionsChoose(roleData.permissions); - // } - // }, [roleData]); - return (@@ -271,9 +326,9 @@ const Calendar = () => {