web/src/app/layout.jsx

1883 lines
52 KiB
React
Raw Normal View History

2023-10-19 11:44:56 +03:30
"use client";
import "../../style/globals.css";
import { Inter } from "next/font/google";
import "../../style/fontiran.css";
import NavBAr from "@comp/NavBar/NavBAr";
import "swiper/css";
import "swiper/css/navigation";
import "react-spring-bottom-sheet/dist/style.css";
import AppContext from "../../Contexts/AppContext";
import { useCallback, useEffect, useState } from "react";
import { motion } from "framer-motion";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { toast, ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import Loading from "plugins/Loading/page";
import Chapar, { getToken } from "plugins/Chapar";
2023-10-26 00:26:44 +03:30
import TimePicker from "plugins/TimePicker/page";
2023-11-05 17:48:39 +03:30
import axios from "axios";
2023-12-12 14:51:25 +03:30
import "rc-slider/assets/index.css";
2024-02-22 12:13:03 +03:30
import BottomSheetReport from "plugins/BottomSheet/BottomSheetReport";
2023-10-19 11:44:56 +03:30
const inter = Inter({ subsets: ["latin"] });
2023-10-21 16:02:24 +03:30
// export const metadata = {
// title: "Create Next App",
// description: "Generated by create next app",
// };
2023-10-19 11:44:56 +03:30
export default function RootLayout({ children }) {
// BottomSheet
const [BottomSheetCreateRoleOpen, setBottomSheetCreateRoleOpen] =
useState(false);
const [BottomSheetCreateEmployeesOpen, setBottomSheetCreateEmployeesOpen] =
useState(false);
const [BottomSheetCreateShiftsOpen, setBottomSheetCreateShiftsOpen] =
useState(false);
2023-11-05 17:48:39 +03:30
const [BottomManageShiftOpen, setBottomManageShiftOpen] = useState(false);
2024-03-11 12:24:41 +03:30
const [BottomFilterActivitiesOpen, setBottomFilterActivitiesOpen] =
useState(false);
2023-11-14 16:22:32 +03:30
const [BottomSheetCreateRoutineOpen, setBottomSheetCreateRoutineOpen] =
useState(false);
const [BottomSheetCreateSectionOpen, setBottomSheetCreateSectionOpen] =
useState(false);
const [BottomSheetCreatePositionOpen, setBottomSheetCreatePositionOpen] =
useState(false);
2023-11-05 17:48:39 +03:30
2023-11-20 00:07:55 +03:30
const [
BottomSheetAddUserToPositionShiftPlanOpen,
setBottomSheetAddUserToPositionShiftPlanOpen,
] = useState(false);
2023-12-07 13:46:57 +03:30
const [BottomSheetChangeRoleOpen, setBottomSheetChangeRoleOpen] =
useState(false);
2024-02-22 12:13:03 +03:30
const [BottomSheetReportOpen, setBottomSheetReportOpen] = useState(false);
2023-10-19 11:44:56 +03:30
// BigPlus
const [BigPlusOpen, setBigPlusOpen] = useState(false);
const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false);
// login
const [phoneNumber, setPhoneNumber] = useState("");
const [verifyCode, setVerifyCode] = useState("");
const [stepLogin, setStepLogin] = useState(0);
const [tokenForStorage, setTokenForStorage] = useState(null);
2023-12-07 13:46:57 +03:30
const [profile, setProfile] = useState([]);
2023-10-19 11:44:56 +03:30
// loading
2023-12-07 13:46:57 +03:30
2023-10-19 11:44:56 +03:30
const [loading, setLoading] = useState(false);
//auth
const [complexId, setComplexId] = useState(0);
// createRole / role
const [permissions, setPermissions] = useState(0);
const [permissionsChoose, setPermissionsChoose] = useState([]);
const [rolesData, setRolesData] = useState([]);
2023-10-21 11:14:11 +03:30
const [roleData, setRoleData] = useState([]);
const [goToEditRole, setGoToEditRole] = useState(false);
const [idEditRole, setIdEditRole] = useState(null);
2023-10-19 11:44:56 +03:30
// createUser/ user
const [usersData, setUsersData] = useState([]);
const [rolesChoose, setRolesChoose] = useState([]);
2023-10-21 15:57:05 +03:30
const [userData, setUserData] = useState([]);
const [goToEditUser, setGoToEditUser] = useState(false);
const [idEditUser, setIdEditUser] = useState(null);
2023-10-19 11:44:56 +03:30
2023-11-14 16:22:32 +03:30
// createsection/ section
const [sectionsData, setSectionsData] = useState([]);
const [sectionData, setSectionData] = useState([]);
const [goToEditSection, setGoToEditSection] = useState(false);
const [idEditSection, setIdEditSection] = useState(null);
// createroutine/ routine
const [routinesData, setRoutinesData] = useState([]);
const [routineData, setRoutineData] = useState([]);
2023-11-20 00:07:55 +03:30
const [routineShiftPlan, setRoutineShiftPlan] = useState([]);
2023-11-14 16:22:32 +03:30
const [goToEditRoutine, setGoToEditRoutine] = useState(false);
const [idEditRoutine, setIdEditRoutine] = useState(null);
// createPosition/ Position
const [positionsData, setPositionsData] = useState([]);
const [positionData, setPositionData] = useState([]);
const [goToEditPosition, setGoToEditPosition] = useState(false);
const [idEditPosition, setIdEditPosition] = useState(null);
const [sectionIdChoose, setSectionIdChoose] = useState([]);
2023-10-26 00:26:44 +03:30
// shift
2023-11-14 16:22:32 +03:30
const [dayOfWeeksChoose, setDayOfWeeksChoose] = useState([]);
2023-10-26 00:26:44 +03:30
const [startAtTimeShift, setStartAtTimeShift] = useState(["00", "00"]);
const [endAtTimeShift, setEndAtTimeShift] = useState(["00", "00"]);
const [shiftsData, setShiftsData] = useState([null]);
const [shiftData, setShiftData] = useState([null]);
const [goToEditShift, setGoToEditShift] = useState(false);
const [idEditShift, setIdEditShift] = useState(null);
2023-12-13 12:02:50 +03:30
const [shiftPlanData, setShiftPlanData] = useState([]);
2024-02-22 12:13:03 +03:30
const [shiftPlansData, setShifPlansData] = useState([]);
2023-10-26 00:26:44 +03:30
2023-11-20 00:07:55 +03:30
// task
const [routineForTaskChoose, setRoutineForTaskChoose] = useState([]);
const [positionsForTaskChoose, setPositionsForTaskChoose] = useState([]);
const [shiftsForTaskChoose, setShiftsForTaskChoose] = useState([]);
const [shiftsDaysChoose, setShiftsDaysChoose] = useState([]);
const [tasksData, setTasksData] = useState([]);
const [taskData, setTaskData] = useState([]);
2023-11-20 00:07:55 +03:30
const [goToEditTask, setGoToEditTask] = useState(false);
const [idEditTask, setIdEditTask] = useState(null);
const [pageGetTasks, setPageGetTasks] = useState(0);
const [stopGetTasks, setStopGetTasks] = useState(false);
const [typeTask, setTypeTask] = useState(1);
2023-11-20 00:07:55 +03:30
2023-12-07 13:46:57 +03:30
// activity
const [activitiesData, setActivitiesData] = useState([]);
const [pageGetActivity, setPageGetActivity] = useState(0);
const [stopGetActivities, setStopGetActivities] = useState(false);
2023-12-07 13:46:57 +03:30
2023-11-05 17:48:39 +03:30
// shift manage-shift
const [searchUserChoose, setSearchUserChoose] = useState([]);
2023-10-26 00:26:44 +03:30
// TimePicker
const [openTimePicker, setOpenTimePicker] = useState(false);
const [TimePickerOrder, setTimePickerOrder] = useState(null);
2023-12-12 14:51:25 +03:30
// closeShift
const [completeActivities, setCompleteActivities] = useState([]);
2024-02-22 12:13:03 +03:30
//report
const [reportDetail, setReportDetail] = useState(null);
2024-04-20 17:26:54 +03:30
//home page
const [homePageData, setHomePageData] = useState([]);
2023-10-19 11:44:56 +03:30
const pathname = usePathname();
const router = useRouter();
2024-01-04 04:03:16 +03:30
const hiddenUrls = ["/login", "/pricing", "/about-us", "/"];
2023-10-19 11:44:56 +03:30
const shouldRenderComponent = !hiddenUrls.includes(pathname);
const closeBigPlusPage = () => {
setTimeout(() => {
setBigPlusOpen(false);
}, 500);
setBigPlusRotateIcon(false);
};
const ConfirmPhoneNumber = async (phoneNumber) => {
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/auth/verifycode?phoneNumber=${phoneNumber}`
);
setStepLogin(1);
localStorage.removeItem("token");
} catch ({ error, status }) {
toast.error(" اطلاعات را صحیح وارد کنید ", {
position: "bottom-right",
closeOnClick: true,
});
}
};
const LoginWhitVerifyCode = async () => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/auth/login/code`,
{
userName: phoneNumber,
password: null,
verifyCode,
}
);
setLoading(false);
localStorage.setItem("token", data.access_token);
if (data.user.signUpStatus == 1) {
setStepLogin(2);
} else if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) {
2023-12-07 13:46:57 +03:30
setProfile(data);
2024-02-27 13:43:07 +03:30
toast.success(`${data.user.firstName} جان خوش اومدی `, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
router.push("/home");
}
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const SignUpLogin = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/auth/signup/complex`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-19 11:44:56 +03:30
},
}
);
2023-12-07 13:46:57 +03:30
2023-10-19 11:44:56 +03:30
setLoading(false);
if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) {
2023-12-07 13:46:57 +03:30
setProfile(data);
2023-10-26 00:26:44 +03:30
2023-10-19 11:44:56 +03:30
toast.success(` ${data.user.firstName} جان خوش اومدی `, {
position: "bottom-right",
closeOnClick: true,
});
2024-02-27 13:43:07 +03:30
// localStorage.removeItem("token");
2023-10-19 11:44:56 +03:30
localStorage.setItem("token", data.access_token);
router.push("/home");
}
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetPermissions = async (body) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/role/permission`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-19 11:44:56 +03:30
},
}
);
setPermissions(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const CreateRole = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/role`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-19 11:44:56 +03:30
},
}
);
toast.success(`نقش ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateRoleOpen(false);
setLoading(false);
GetRoles();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-21 11:14:11 +03:30
const UpdateRole = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/role`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-21 11:14:11 +03:30
},
}
);
toast.success(`نقش ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateRoleOpen(false);
setLoading(false);
GetRoles();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-21 11:14:11 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-19 11:44:56 +03:30
const GetRoles = async () => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/role?page=0`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-19 11:44:56 +03:30
},
}
);
setRolesData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-21 11:14:11 +03:30
const GetRole = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/role/${id}?page=0`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-21 11:14:11 +03:30
},
}
);
setRoleData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-21 11:14:11 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DeleteRole = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/role/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-21 11:14:11 +03:30
},
}
);
setBottomSheetCreateRoleOpen(false);
setLoading(false);
GetRoles();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-21 11:14:11 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-19 11:44:56 +03:30
const CreateUser = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/user`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-19 11:44:56 +03:30
},
}
);
toast.success(`کاربر ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateEmployeesOpen(false);
setLoading(false);
GetUsers();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-21 15:57:05 +03:30
const UpdateUser = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/user`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-21 15:57:05 +03:30
},
}
);
toast.success(`کاربر ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateEmployeesOpen(false);
setLoading(false);
GetUsers();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-21 15:57:05 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-19 11:44:56 +03:30
const GetUsers = async () => {
setLoading(true);
try {
const data = await Chapar.get(
2023-10-21 11:14:11 +03:30
`${process.env.NEXT_PUBLIC_API_URL}/user?page=0`,
2023-10-19 11:44:56 +03:30
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-19 11:44:56 +03:30
},
}
);
setUsersData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-19 11:44:56 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-21 15:57:05 +03:30
const GetUser = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/user/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-21 15:57:05 +03:30
},
}
);
setUserData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-21 15:57:05 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DeleteUser = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/user/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-21 15:57:05 +03:30
},
}
);
setBottomSheetCreateEmployeesOpen(false);
setLoading(false);
GetUsers();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-21 15:57:05 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-26 00:26:44 +03:30
const CreateShift = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/shift`,
JSON.stringify(body),
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-26 00:26:44 +03:30
},
}
);
toast.success(`شیفت ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateShiftsOpen(false);
setLoading(false);
GetShifts();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-26 00:26:44 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UpdateShift = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/shift`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-26 00:26:44 +03:30
},
}
);
toast.success(`شیفت ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateShiftsOpen(false);
setLoading(false);
GetShifts();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-26 00:26:44 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-12-12 14:51:25 +03:30
const GetShifts = async (date) => {
console.log(
"Date123456789",
`${process.env.NEXT_PUBLIC_API_URL}/shift?page=0${
date ? `&selectedDate=${date}` : ""
}`
);
2023-10-26 00:26:44 +03:30
setLoading(true);
try {
const data = await Chapar.get(
2023-12-12 14:51:25 +03:30
`${process.env.NEXT_PUBLIC_API_URL}/shift?page=0${
date ? `&selectedDate=${date}` : ""
}`,
2023-10-26 00:26:44 +03:30
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-26 00:26:44 +03:30
},
}
);
setShiftsData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-26 00:26:44 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetShift = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/shift/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-26 00:26:44 +03:30
},
}
);
setShiftData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-26 00:26:44 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DeleteShift = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/shift/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-26 00:26:44 +03:30
},
}
);
setBottomSheetCreateShiftsOpen(false);
setLoading(false);
GetShifts();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-26 00:26:44 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-11-14 16:22:32 +03:30
const CreateSection = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/section`,
JSON.stringify(body),
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
toast.success(`سکشن ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateSectionOpen(false);
setLoading(false);
GetSections();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UpdateSection = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/section`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
toast.success(`سکشن ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateSectionOpen(false);
setLoading(false);
GetSections();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetSections = async () => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/section?page=0`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setSectionsData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetSection = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/section/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setSectionData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DeleteSection = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/section/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setBottomSheetCreateSectionOpen(false);
setLoading(false);
GetSections();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const CreateRoutine = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/routine`,
JSON.stringify(body),
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
toast.success(`روتین ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateRoutineOpen(false);
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UpdateRoutine = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/routine`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
toast.success(`روتین ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreateRoutineOpen(false);
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetRoutines = async () => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/routine?page=0`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setRoutinesData(data);
setLoading(false);
2023-12-12 14:51:25 +03:30
} catch (error) {
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
2023-12-12 14:51:25 +03:30
// if (error.response.status === 401) {
// localStorage.removeItem("token");
// window.location.href = "/";
// }
2023-11-14 16:22:32 +03:30
}
};
const GetRoutine = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/routine/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setRoutineData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-12-13 12:02:50 +03:30
const GetRoutineShiftPlan = async (id, time) => {
2023-11-20 00:07:55 +03:30
setLoading(true);
try {
const data = await Chapar.get(
2023-12-13 12:02:50 +03:30
`${process.env.NEXT_PUBLIC_API_URL}/routine/${id}/shift?selectedDate=${time}`,
2023-11-20 00:07:55 +03:30
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
setRoutineShiftPlan(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2024-02-22 12:13:03 +03:30
const GetShiftPlan = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/shift/plan/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2024-02-22 12:13:03 +03:30
},
}
);
setShiftPlanData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UpdateShiftPlan = async (body, id) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/shift/plan`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2024-02-22 12:13:03 +03:30
},
}
);
toast.success(`شیفت ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
setShiftPlanData(id);
router.push("/shifts");
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-11-20 00:07:55 +03:30
const CreateShifPlan = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/shift/plan`,
JSON.stringify(body),
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
toast.success(`مدیریت شیفت ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
2024-02-22 12:13:03 +03:30
router.push("/shifts");
2023-11-20 00:07:55 +03:30
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2024-05-06 14:08:12 +03:30
const GetShifPlans = async (page, dataFilter) => {
2024-02-22 12:13:03 +03:30
setLoading(true);
try {
const data = await Chapar.get(
2024-05-06 14:08:12 +03:30
`${process.env.NEXT_PUBLIC_API_URL}/shift/plan?page=${page}&dateFilter=${dataFilter}`,
2024-02-22 12:13:03 +03:30
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2024-02-22 12:13:03 +03:30
},
}
);
console.log(data);
setShifPlansData(data);
2023-11-20 00:07:55 +03:30
2024-02-22 12:13:03 +03:30
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-11-14 16:22:32 +03:30
const DeleteRoutine = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/routine/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setBottomSheetCreateRoutineOpen(false);
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const CreatePosition = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/position`,
JSON.stringify(body),
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
toast.success(`پوزیشن ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreatePositionOpen(false);
setLoading(false);
GetPositions();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UpdatePosition = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/position`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
toast.success(`پوزیشن ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
setBottomSheetCreatePositionOpen(false);
setLoading(false);
GetPositions();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetPositions = async () => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/position?page=0`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setPositionsData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetPosition = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/position/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setPositionData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DeletePosition = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/position/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-14 16:22:32 +03:30
},
}
);
setBottomSheetCreatePositionOpen(false);
setLoading(false);
GetPositions();
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-14 16:22:32 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-11-20 00:07:55 +03:30
const CreateTask = async (body) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/task`,
JSON.stringify(body),
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
toast.success(`فعالیت ساخته شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
GetTasks(0);
2023-11-20 00:07:55 +03:30
router.push("/tasks");
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UpdateTask = async (body) => {
setLoading(true);
try {
const data = await Chapar.put(
`${process.env.NEXT_PUBLIC_API_URL}/task`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
toast.success(`فعالیت ویرایش شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
GetTasks(0);
2023-11-20 00:07:55 +03:30
router.push("/tasks");
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetTasks = async (page) => {
2023-11-20 00:07:55 +03:30
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/task?page=${page}`,
2023-11-20 00:07:55 +03:30
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
if (data.length < 14) {
setStopGetTasks(true);
}
if (page == 0) {
setTasksData(data);
} else {
setTasksData((prevData) => [...prevData, ...data]);
}
2023-11-20 00:07:55 +03:30
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const GetTask = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/task/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
setTaskData(data);
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DeleteTask = async (id) => {
setLoading(true);
try {
const data = await Chapar.delete(
`${process.env.NEXT_PUBLIC_API_URL}/task/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-11-20 00:07:55 +03:30
},
}
);
setLoading(false);
GetTasks();
router.push("/tasks");
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-11-20 00:07:55 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2024-03-11 12:24:41 +03:30
const GetActivity = async (date, shift, page, dateQueryFilter) => {
2023-12-07 13:46:57 +03:30
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/activity?page=${page}${
2023-12-12 14:51:25 +03:30
date ? `&selectedDate=${date}` : ""
2024-03-11 12:24:41 +03:30
}${shift ? `&selectedShift=${shift}` : ""}${
dateQueryFilter != null ? `&dateQueryFilter=${dateQueryFilter}` : ""
}`,
2023-12-07 13:46:57 +03:30
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-12-07 13:46:57 +03:30
},
}
);
2024-05-06 14:08:12 +03:30
if (data.length < 19) {
setStopGetActivities(true);
}
if (page == 0) {
setActivitiesData(data);
} else {
setActivitiesData((prevData) => [...prevData, ...data]);
}
2023-12-07 13:46:57 +03:30
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const DoneActivity = async (id) => {
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/activity/done/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-12-12 14:51:25 +03:30
},
}
);
toast.success(`فعالیت ثبت شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const UnDoneActivity = async (id, resone) => {
setLoading(true);
console.log("s");
2023-12-12 14:51:25 +03:30
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/activity/undone/${id}?undoneReason=${resone}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-12-12 14:51:25 +03:30
},
}
);
toast.success(`فعالیت ثبت شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2024-02-27 13:43:07 +03:30
const CloseShift = async (body, id, index) => {
2023-12-12 14:51:25 +03:30
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/shift/plan/${id}/complete`,
body,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-12-12 14:51:25 +03:30
},
}
);
toast.success(`فعالیت ثبت شد`, {
position: "bottom-right",
closeOnClick: true,
});
// router->
2024-02-27 13:43:07 +03:30
CTX.GetShifts(moment().locale("fa").startOf("day").unix() * 1000);
2023-12-12 14:51:25 +03:30
setLoading(false);
// GetTasks();
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const changeRole = async (id) => {
2024-02-27 13:43:07 +03:30
console.log(getToken());
2023-12-12 14:51:25 +03:30
setLoading(true);
try {
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/user/role/change/${id}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-12-12 14:51:25 +03:30
},
}
);
setProfile(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
2023-12-07 13:46:57 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-26 00:26:44 +03:30
const CheckUser = async () => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/user/profile`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2023-10-26 00:26:44 +03:30
},
}
);
setProfile(data);
2023-12-07 13:46:57 +03:30
2023-10-26 00:26:44 +03:30
setLoading(false);
} catch ({ error, status }) {
2023-12-12 14:51:25 +03:30
toast.error(`${error?.response?.data?.message}`, {
2023-10-26 00:26:44 +03:30
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2024-02-22 12:13:03 +03:30
const ReportShiftPlan = async (shiftPlanId) => {
setLoading(true);
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/report/shift/plan/${shiftPlanId}`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2024-02-22 12:13:03 +03:30
},
}
);
if (!response.ok) {
throw new Error("Failed to download report");
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "report.xlsx"; // Change the filename if needed
document.body.appendChild(a);
a.click();
a.remove();
setLoading(false);
} catch (error) {
toast.error(error.message, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
const ReportTask = async () => {
setLoading(true);
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/report/task`,
{
headers: {
2024-02-27 13:43:07 +03:30
Authorization: "Bearer " + localStorage.getItem("token"),
2024-02-22 12:13:03 +03:30
},
}
);
if (!response.ok) {
throw new Error("Failed to download report");
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "report.xlsx"; // Change the filename if needed
document.body.appendChild(a);
a.click();
a.remove();
setLoading(false);
} catch (error) {
toast.error(error.message, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2024-04-20 17:26:54 +03:30
const GetHomePageData = async (id) => {
setLoading(true);
try {
const data = await Chapar.get(
`${process.env.NEXT_PUBLIC_API_URL}/page/dashboard/app`,
{
headers: {
Authorization: "Bearer " + localStorage.getItem("token"),
},
}
);
console.log(data);
setHomePageData(data);
setLoading(false);
} catch ({ error, status }) {
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
2023-10-26 00:26:44 +03:30
useEffect(() => {
2023-12-12 14:51:25 +03:30
console.log(`
bbbbbbbb
b::::::b iiii
b::::::b i::::i
b::::::b iiii
b:::::b
b:::::bbbbbbbbb rrrrr rrrrrrrrr iiiiiiizzzzzzzzzzzzzzzzz cccccccccccccccc ooooooooooo
b::::::::::::::bb r::::rrr:::::::::ri:::::iz:::::::::::::::z cc:::::::::::::::coo:::::::::::oo
b::::::::::::::::br:::::::::::::::::ri::::iz::::::::::::::z c:::::::::::::::::o:::::::::::::::o
b:::::bbbbb:::::::rr::::::rrrrr::::::i::::izzzzzzzz::::::z c:::::::cccccc:::::o:::::ooooo:::::o
b:::::b b::::::br:::::r r:::::i::::i z::::::z c::::::c cccccco::::o o::::o
b:::::b b:::::br:::::r rrrrrri::::i z::::::z c:::::c o::::o o::::o
b:::::b b:::::br:::::r i::::i z::::::z c:::::c o::::o o::::o
b:::::b b:::::br:::::r i::::i z::::::z c::::::c cccccco::::o o::::o
b:::::bbbbbb::::::br:::::r i::::::i z::::::zzzzzzzc:::::::cccccc:::::o:::::ooooo:::::o
b::::::::::::::::b r:::::r i::::::iz::::::::::::::zc:::::::::::::::::o:::::::::::::::o
b:::::::::::::::b r:::::r i::::::z:::::::::::::::z cc:::::::::::::::coo:::::::::::oo
2023-12-13 12:02:50 +03:30
bbbbbbbbbbbbbbbb rrrrrrr iiiiiiizzzzzzzzzzzzzzzzz cccccccccccccccc ooooooooooo
soli chizi bood bgo hossein__masoomi
2023-12-12 14:51:25 +03:30
`);
2024-02-27 13:43:07 +03:30
const token = localStorage.getItem("token");
2024-05-06 14:08:12 +03:30
// if (!token) {
// router.push("/login");
// }
2023-12-12 14:51:25 +03:30
2024-02-27 13:43:07 +03:30
if (profile.length <= 0 && token) CheckUser();
2023-10-26 00:26:44 +03:30
}, []);
2023-10-19 11:44:56 +03:30
return (
<AppContext.Provider
value={{
state: {
BottomSheetCreateRoleOpen,
BottomSheetCreateEmployeesOpen,
BottomSheetCreateShiftsOpen,
BigPlusOpen,
BigPlusRotateIcon,
loading,
stepLogin,
phoneNumber,
verifyCode,
tokenForStorage,
complexId,
permissions,
permissionsChoose,
rolesData,
usersData,
rolesChoose,
2023-10-21 11:14:11 +03:30
goToEditRole,
roleData,
idEditRole,
2023-10-21 15:57:05 +03:30
idEditUser,
goToEditUser,
userData,
2023-10-26 00:26:44 +03:30
openTimePicker,
endAtTimeShift,
startAtTimeShift,
TimePickerOrder,
shiftsData,
idEditShift,
goToEditShift,
shiftData,
profile,
2023-11-05 17:48:39 +03:30
searchUserChoose,
BottomManageShiftOpen,
2023-11-14 16:22:32 +03:30
idEditSection,
goToEditSection,
sectionData,
sectionsData,
BottomSheetCreateSectionOpen,
BottomSheetCreateRoutineOpen,
idEditRoutine,
goToEditRoutine,
routineData,
routinesData,
dayOfWeeksChoose,
idEditPosition,
goToEditPosition,
positionData,
positionsData,
BottomSheetCreatePositionOpen,
sectionIdChoose,
2023-11-20 00:07:55 +03:30
routineForTaskChoose,
positionsForTaskChoose,
shiftsForTaskChoose,
shiftsDaysChoose,
idEditTask,
goToEditTask,
taskData,
tasksData,
routineShiftPlan,
BottomSheetAddUserToPositionShiftPlanOpen,
2023-12-07 13:46:57 +03:30
BottomSheetChangeRoleOpen,
activitiesData,
2023-12-12 14:51:25 +03:30
completeActivities,
2023-12-13 12:02:50 +03:30
shiftPlanData,
stopGetTasks,
pageGetTasks,
stopGetActivities,
pageGetActivity,
2024-02-22 12:13:03 +03:30
shiftPlansData,
BottomSheetReportOpen,
reportDetail,
2024-03-11 12:24:41 +03:30
BottomFilterActivitiesOpen,
2024-04-20 17:26:54 +03:30
homePageData,
typeTask,
2023-10-19 11:44:56 +03:30
},
setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen,
setBottomSheetCreateShiftsOpen,
setBigPlusOpen,
setBigPlusRotateIcon,
setLoading,
ConfirmPhoneNumber,
LoginWhitVerifyCode,
setStepLogin,
setPhoneNumber,
setVerifyCode,
SignUpLogin,
setTokenForStorage,
setComplexId,
setPermissions,
GetPermissions,
setPermissionsChoose,
CreateRole,
setRolesData,
GetRoles,
CreateUser,
GetUsers,
setUsersData,
setRolesChoose,
2023-10-21 11:14:11 +03:30
setGoToEditRole,
setRoleData,
GetRole,
setIdEditRole,
DeleteRole,
UpdateRole,
2023-10-21 15:57:05 +03:30
setIdEditUser,
setGoToEditUser,
setUserData,
DeleteUser,
GetUser,
UpdateUser,
2023-10-26 00:26:44 +03:30
setOpenTimePicker,
setEndAtTimeShift,
setIdEditShift,
setGoToEditShift,
2023-11-14 16:22:32 +03:30
setStartAtTimeShift,
setBottomManageShiftOpen,
GetShifts,
DeleteShift,
2023-10-26 00:26:44 +03:30
GetShift,
UpdateShift,
2023-11-14 16:22:32 +03:30
CreateShift,
setIdEditSection,
setGoToEditSection,
setSectionData,
setSectionsData,
setBottomSheetCreateSectionOpen,
DeleteSection,
GetSection,
GetSections,
UpdateSection,
CreateSection,
setBottomSheetCreateRoutineOpen,
setIdEditRoutine,
setGoToEditRoutine,
setRoutineData,
setRoutinesData,
DeleteRoutine,
GetRoutine,
GetRoutines,
UpdateRoutine,
CreateRoutine,
setDayOfWeeksChoose,
setShiftData,
setTimePickerOrder,
2023-11-05 17:48:39 +03:30
setSearchUserChoose,
2023-11-14 16:22:32 +03:30
setIdEditPosition,
setGoToEditPosition,
setPositionData,
setPositionsData,
setBottomSheetCreatePositionOpen,
DeletePosition,
GetPosition,
GetPositions,
UpdatePosition,
CreatePosition,
setSectionIdChoose,
2023-11-20 00:07:55 +03:30
setRoutineForTaskChoose,
setPositionsForTaskChoose,
setShiftsForTaskChoose,
setShiftsDaysChoose,
DeleteTask,
GetTask,
GetTasks,
UpdateTask,
CreateTask,
setIdEditTask,
setGoToEditTask,
setTaskData,
setTasksData,
setRoutineShiftPlan,
GetRoutineShiftPlan,
setBottomSheetAddUserToPositionShiftPlanOpen,
CreateShifPlan,
2023-12-07 13:46:57 +03:30
setBottomSheetChangeRoleOpen,
setActivitiesData,
GetActivity,
2023-12-12 14:51:25 +03:30
UnDoneActivity,
DoneActivity,
changeRole,
setCompleteActivities,
CloseShift,
2023-12-13 12:02:50 +03:30
setShiftPlanData,
GetShiftPlan,
UpdateShiftPlan,
setStopGetTasks,
setPageGetTasks,
setStopGetActivities,
setPageGetActivity,
2024-02-22 12:13:03 +03:30
setShifPlansData,
GetShifPlans,
setBottomSheetReportOpen,
setReportDetail,
ReportShiftPlan,
ReportTask,
2024-03-11 12:24:41 +03:30
setBottomFilterActivitiesOpen,
2024-04-20 17:26:54 +03:30
setHomePageData,
GetHomePageData,
setTypeTask,
2023-10-19 11:44:56 +03:30
}}
>
<html lang="en">
<body className={inter.className}>
{children}
{shouldRenderComponent && <NavBAr />}
<ToastContainer position="bottom-right" closeOnClick={true} rtl />
<Loading />
2024-02-22 12:13:03 +03:30
<BottomSheetReport />
2023-10-26 00:26:44 +03:30
{openTimePicker && <TimePicker />}
2024-04-18 23:47:31 +03:30
{/* {BigPlusOpen ? (
2023-12-12 14:51:25 +03:30
<div className="fixed w-full top-0 z-[120] ">
2023-10-19 11:44:56 +03:30
<motion.div
animate={{ opacity: [0, 0.5, 1] }}
transition={{ duration: 0.3 }}
>
2023-12-12 14:51:25 +03:30
<div className="h-screen bg-BigPlus ">
2023-10-19 11:44:56 +03:30
<div className="flex justify-center">
<div className="bg-primary-200 w-[60px] h-[60px] rounded-full fixed bottom-[37px] ">
<div
onClick={() => {
closeBigPlusPage();
}}
>
<svg
width="25"
height="25"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={`mx-auto mt-[16px] transition-all ${
BigPlusRotateIcon ? " rotate-45" : " rotate-0"
} `}
>
<path
d="M14 6H10V2C10 1.46957 9.78929 0.960859 9.41421 0.585786C9.03914 0.210714 8.53043 0 8 0C7.46957 0 6.96086 0.210714 6.58579 0.585786C6.21071 0.960859 6 1.46957 6 2L6.071 6H2C1.46957 6 0.960859 6.21071 0.585786 6.58579C0.210714 6.96086 0 7.46957 0 8C0 8.53043 0.210714 9.03914 0.585786 9.41421C0.960859 9.78929 1.46957 10 2 10L6.071 9.929L6 14C6 14.5304 6.21071 15.0391 6.58579 15.4142C6.96086 15.7893 7.46957 16 8 16C8.53043 16 9.03914 15.7893 9.41421 15.4142C9.78929 15.0391 10 14.5304 10 14V9.929L14 10C14.5304 10 15.0391 9.78929 15.4142 9.41421C15.7893 9.03914 16 8.53043 16 8C16 7.46957 15.7893 6.96086 15.4142 6.58579C15.0391 6.21071 14.5304 6 14 6Z"
fill="white"
/>
</svg>
</div>
</div>
</div>
2023-12-12 14:51:25 +03:30
<div className="fixed bottom-[110px] w-full px-3 ">
<Link href={"/shifts/complete-shift"}>
<div
className="bg-secondary-200 p-3 my-2 w-full rounded-full"
onClick={() => closeBigPlusPage()}
>
<p className="mb-0 text-center text-white">بستن شیفت</p>
2023-10-19 11:44:56 +03:30
</div>
</Link>
2023-12-12 14:51:25 +03:30
<div className="flex justify-between w-full">
<Link href={"/dsdasd"}>
<div
className="w-full p-3 rounded-full bg-secondaryDark-100 px-4"
onClick={() => closeBigPlusPage()}
>
<p className="mb-0 text-white">
افزودن خرید جدیـــــد
</p>
</div>
</Link>
<Link href={"/tasks/add-task?new=true"}>
<div
className="w-full p-3 rounded-full bg-secondaryDark-100 px-4"
onClick={() => closeBigPlusPage()}
>
<p className="mb-0 text-white">افزودن وظیفه جدید</p>
</div>
</Link>
</div>
2023-10-19 11:44:56 +03:30
</div>
</div>
</motion.div>
</div>
) : (
""
2024-04-18 23:47:31 +03:30
)} */}
2023-10-19 11:44:56 +03:30
</body>
</html>
</AppContext.Provider>
);
}