@@ -211,7 +242,7 @@ const Employees = (props) => {
شما
-
+ {/* */}
پوزیشن فعال دارید
@@ -249,7 +280,7 @@ const Employees = (props) => {
setActiveSection(3)}
+ onClick={() => handleGetApi(3)}
>
@@ -262,7 +293,7 @@ const Employees = (props) => {
شما
-
+ {/* */}
کارمند فعال دارید
@@ -297,12 +328,65 @@ const Employees = (props) => {
{activeSection == 3 &&
}
+
+
+
handleGetApi(4)}
+ >
+
+
+
+
مدیریت شیفت های مجموعه
+
+ شما
+
+ {/* */}
+
+ شیفت فعال دارید
+
+
+
+
+ {activeSection == 4 ? (
+
CTX.setBottomSheetCreateShiftsOpen(true)}
+ >
+
+
+ ) : (
+
+ )}
+
+ {activeSection == 4 &&
}
+
{/*
*/}
+
);
};
diff --git a/src/app/home/page.jsx b/src/app/home/page.jsx
index 8d2853e..9f24069 100644
--- a/src/app/home/page.jsx
+++ b/src/app/home/page.jsx
@@ -10,6 +10,37 @@ import { ParseJwt } from "plugins/ParseJwt/page";
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect } from "react";
// import { Swiper, SwiperSlide } from "swiper/react";
+import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
+import { Doughnut, Pie } from "react-chartjs-2";
+
+ChartJS.register(ArcElement, Tooltip, Legend);
+
+export const data = {
+ datasets: [
+ {
+ label: ["پوزیشن"],
+ data: [60, 38, 95, 60, 20, 30],
+ backgroundColor: [
+ "rgba(46, 161, 134, 0.8)",
+ "rgba(52, 115, 101, 0.41)",
+ "rgba(80, 143, 114, 0.61)",
+ "rgba(75, 155, 138, 0.61)",
+ "rgba(85, 155, 138, 0.91)",
+ "rgba(12, 75, 61, 0.51)",
+ ],
+ borderColor: [
+ "rgba(255, 99, 132, 1)",
+ "rgba(54, 162, 235, 1)",
+ "rgba(255, 206, 86, 1)",
+ "rgba(75, 192, 192, 1)",
+ "rgba(153, 102, 255, 1)",
+ "rgba(255, 159, 64, 1)",
+ ],
+ borderWidth: 1,
+ borderColor: " #356859",
+ },
+ ],
+};
const Home = (props) => {
const CTX = useContext(AppContext);
@@ -53,8 +84,68 @@ const Home = (props) => {
/>
-
-
+
+
+
مسیر فرایند شروع
+
+
+ شما
+
+ درصد از فرایند شروع را انجام داده اید
+
+
+
+
+
+
+
+
+
diff --git a/src/app/layout.jsx b/src/app/layout.jsx
index 3dade48..4a5c20c 100644
--- a/src/app/layout.jsx
+++ b/src/app/layout.jsx
@@ -46,6 +46,11 @@ export default function RootLayout({ children }) {
const [BottomSheetCreatePositionOpen, setBottomSheetCreatePositionOpen] =
useState(false);
+ const [
+ BottomSheetAddUserToPositionShiftPlanOpen,
+ setBottomSheetAddUserToPositionShiftPlanOpen,
+ ] = useState(false);
+
// BigPlus
const [BigPlusOpen, setBigPlusOpen] = useState(false);
const [BigPlusRotateIcon, setBigPlusRotateIcon] = useState(false);
@@ -86,6 +91,7 @@ export default function RootLayout({ children }) {
// createroutine/ routine
const [routinesData, setRoutinesData] = useState([]);
const [routineData, setRoutineData] = useState([]);
+ const [routineShiftPlan, setRoutineShiftPlan] = useState([]);
const [goToEditRoutine, setGoToEditRoutine] = useState(false);
const [idEditRoutine, setIdEditRoutine] = useState(null);
@@ -98,7 +104,6 @@ export default function RootLayout({ children }) {
// shift
const [dayOfWeeksChoose, setDayOfWeeksChoose] = useState([]);
-
const [startAtTimeShift, setStartAtTimeShift] = useState(["00", "00"]);
const [endAtTimeShift, setEndAtTimeShift] = useState(["00", "00"]);
const [shiftsData, setShiftsData] = useState([null]);
@@ -106,6 +111,16 @@ export default function RootLayout({ children }) {
const [goToEditShift, setGoToEditShift] = useState(false);
const [idEditShift, setIdEditShift] = useState(null);
+ // task
+ const [routineForTaskChoose, setRoutineForTaskChoose] = useState([]);
+ const [positionsForTaskChoose, setPositionsForTaskChoose] = useState([]);
+ const [shiftsForTaskChoose, setShiftsForTaskChoose] = useState([]);
+ const [shiftsDaysChoose, setShiftsDaysChoose] = useState([]);
+ const [tasksData, setTasksData] = useState([null]);
+ const [taskData, setTaskData] = useState([null]);
+ const [goToEditTask, setGoToEditTask] = useState(false);
+ const [idEditTask, setIdEditTask] = useState(null);
+
// shift manage-shift
const [searchUserChoose, setSearchUserChoose] = useState([]);
@@ -854,6 +869,58 @@ export default function RootLayout({ children }) {
setLoading(false);
}
};
+
+ const GetRoutineShiftPlan = async (id) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.get(
+ `${process.env.NEXT_PUBLIC_API_URL}/routine/${id}/shift`,
+
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+
+ console.log("GetRoutineShift", data);
+
+ setRoutineShiftPlan(data);
+ setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+ const CreateShifPlan = async (body) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`,
+ JSON.stringify(body),
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ toast.success(`مدیریت شیفت ساخته شد`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ router.push("/shifts");
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+
const DeleteRoutine = async (id) => {
setLoading(true);
try {
@@ -1008,6 +1075,140 @@ export default function RootLayout({ children }) {
}
};
+ const CreateTask = async (body) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/task`,
+ JSON.stringify(body),
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ toast.success(`فعالیت ساخته شد`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ // router->
+
+ setLoading(false);
+ GetTasks();
+
+ router.push("/tasks");
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ 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: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ toast.success(`فعالیت ویرایش شد`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+
+ // router->
+
+ setLoading(false);
+ GetTasks();
+ router.push("/tasks");
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+ const GetTasks = async () => {
+ setLoading(true);
+ try {
+ const data = await Chapar.get(
+ `${process.env.NEXT_PUBLIC_API_URL}/task?page=0`,
+
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ console.log("GetTasks", data);
+
+ setTasksData(data);
+ setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ 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: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ console.log("GetPosition", data);
+
+ setTaskData(data);
+ setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ 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: {
+ Authorization: getToken(),
+ },
+ }
+ );
+
+ setLoading(false);
+ GetTasks();
+ router.push("/tasks");
+ } catch ({ error, status }) {
+ toast.error(`${error.response.data.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+
const CheckUser = async () => {
setLoading(true);
try {
@@ -1091,6 +1292,16 @@ export default function RootLayout({ children }) {
positionsData,
BottomSheetCreatePositionOpen,
sectionIdChoose,
+ routineForTaskChoose,
+ positionsForTaskChoose,
+ shiftsForTaskChoose,
+ shiftsDaysChoose,
+ idEditTask,
+ goToEditTask,
+ taskData,
+ tasksData,
+ routineShiftPlan,
+ BottomSheetAddUserToPositionShiftPlanOpen,
},
setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen,
@@ -1174,6 +1385,23 @@ export default function RootLayout({ children }) {
UpdatePosition,
CreatePosition,
setSectionIdChoose,
+ setRoutineForTaskChoose,
+ setPositionsForTaskChoose,
+ setShiftsForTaskChoose,
+ setShiftsDaysChoose,
+ DeleteTask,
+ GetTask,
+ GetTasks,
+ UpdateTask,
+ CreateTask,
+ setIdEditTask,
+ setGoToEditTask,
+ setTaskData,
+ setTasksData,
+ setRoutineShiftPlan,
+ GetRoutineShiftPlan,
+ setBottomSheetAddUserToPositionShiftPlanOpen,
+ CreateShifPlan,
}}
>
diff --git a/src/app/routine/page.jsx b/src/app/routine/page.jsx
deleted file mode 100644
index 0dbe7db..0000000
--- a/src/app/routine/page.jsx
+++ /dev/null
@@ -1,244 +0,0 @@
-"use client";
-
-import AppHeader from "@comp/AppHeader/page";
-import AppContext from "@ctx/AppContext";
-import BottomSheetCreateRoutine from "plugins/BottomSheet/BottomSheetCreateRoutine";
-import PersianNumber from "plugins/PersianNumber";
-import React, { useContext } from "react";
-import { Swiper, SwiperSlide } from "swiper/react";
-import TaskCard from "@comp/TaskCard/page";
-import Link from "next/link";
-
-const page = () => {
- const CTX = useContext(AppContext);
-
- const routinesData = CTX.state.routinesData;
-
- // const goToEditRole = (id) => {
- // CTX.setGoToEditRole(true);
- // CTX.setBottomSheetCreateRoleOpen(true);
- // CTX.setIdEditRole(id);
- // };
-
- return (
-
-
CTX.setBottomSheetCreateRoutineOpen(true)}
- icon2={true}
- iconName2="ARROW"
- iconHref2="/home"
- iconEvent2={() => {
- return undefined;
- }}
- />
-
-
-
-
تسک های هفتگی مجموعه
-
- امروز
-
-
-
- تسک فعال دارید
-
-
-
-
-
-
-
console.log("slide change")}
- onSwiper={(swiper) => console.log(swiper)}
- >
-
-
-
-
- اهمیت بالا{" "}
-
-
- شیفت صبح
-
-
-
-
-
- کارگاه بدنسازی در خانه برای رستوران توگک
-
-
-
-
-
-
-
-
- +
-
-
-
- نفر دیگر
-
-
-
-
-
-
-
- دوشنبه
-
-
-
- اردیبهشت
-
-
-
-
-
-
-
-
-
-
-
-
-
- اهمیت بالا{" "}
-
-
- شیفت صبح
-
-
-
-
-
- کارگاه بدنسازی در خانه برای رستوران توگک
-
-
-
-
-
-
-
-
- +
-
-
-
- نفر دیگر
-
-
-
-
-
-
-
- دوشنبه
-
-
-
- اردیبهشت
-
-
-
-
-
-
-
-
-
-
-
-
-
تسک های امروز
-
- امروز
-
-
-
- تسک فعال دارید
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export default page;
diff --git a/src/app/shifts/complete-shift/page.jsx b/src/app/shifts/complete-shift/page.jsx
index 09a70f9..99c6c5b 100644
--- a/src/app/shifts/complete-shift/page.jsx
+++ b/src/app/shifts/complete-shift/page.jsx
@@ -1,5 +1,5 @@
import AppHeader from "@comp/AppHeader/page";
-import TaskCard from "@comp/TaskCard/page";
+import TaskCard from "@comp/TaskPage/ActivityCard/page";
import PersianNumber from "plugins/PersianNumber";
import React from "react";
diff --git a/src/app/shifts/manage-shift/page.jsx b/src/app/shifts/manage-shift/page.jsx
index 9bddff4..5fd3483 100644
--- a/src/app/shifts/manage-shift/page.jsx
+++ b/src/app/shifts/manage-shift/page.jsx
@@ -12,49 +12,71 @@ import Input from "plugins/Input/page";
import { toast } from "react-toastify";
import Avatar from "boring-avatars";
import BottomManageShift from "plugins/BottomSheet/BottomManageShift";
+import BottomSheetAddUserToPositionShiftPlan from "plugins/BottomSheet/BottomSheetAddUserToPositionShiftPlan";
+import Buttonbriz from "plugins/Buttonbriz/page";
const Calendar = () => {
const CTX = useContext(AppContext);
const shiftsData = CTX.state.shiftsData;
const searchUserChoose = CTX.state.searchUserChoose;
const usersData = CTX.state.usersData;
+ const routinesData = CTX.state.routinesData;
+ const routineShiftPlan = CTX.state.routineShiftPlan;
+ const positionsData = CTX.state.positionsData;
- console.log("usersData", usersData);
-
- const [searchUserCurrntData, setSearchUserCurrntData] = useState([]);
- const [daysUntilEnd, setDaysUntilEnd] = useState([]);
+ const [daysUntilWeek, setDaysUntilWeek] = useState([]);
const [selectDay, setSelectDay] = useState(null);
- const [selectShift, setselectShift] = useState(0);
+ const [selectShift, setselectShift] = useState(-1);
+ const [selectRoutine, setSelectRoutine] = useState(-1);
+ const [shiftsPlan, setShiftsPlan] = useState([]);
const [manageShiftEmployeesData, setManageShiftEmployeesData] = useState([]);
- const today = moment().format("jYYYY/jM/jD"); // Get the current Jalali date
- const todayJustDay = moment().format("jD"); // Get the current Jalali date
+ const [shiftPlanSteps, setShiftPlanSteps] = useState(0);
- // Find the end of the current month
- const endOfMonth = moment(today, "jYYYY/jM/jD").endOf("jMonth");
+ const [positionSelectNameBottomSheet, setPositionSelectNameBottomSheet] =
+ useState([]);
+ const [positionSelectIdBottomSheet, setPositionSelectIdBottomSheet] =
+ useState([]);
+ const [userAndPositionIds, setUserAndPositionIds] = useState([]);
+
+ const week = [
+ { key: "شنبه", value: 6 },
+ { key: "یکشنبه", value: 0 },
+ { key: "دوشنبه", value: 1 },
+ { key: "سه شنبه", value: 2 },
+ { key: "چهار شنبه", value: 3 },
+ { key: "پنج شنبه", value: 4 },
+ { key: "جمعه", value: 5 },
+ ];
+ const today = moment().format("jYYYY/jM/jD"); // Get the current Jalali date
const daysInCurrentMonth = moment(today, "jYYYY/jM/jD")
.endOf("jMonth")
.jDate();
const daysEndOfMonth = () => {
- const days = [];
- for (let i = -1; i < daysInCurrentMonth - todayJustDay + 1; i++) {
- const currentDate = moment(today, "jYYYY/jM/jD").add(i, "days");
- const isToday = currentDate.isSame(moment(), "day");
- days.push({
- checkDay: currentDate.format("jYYYY/jM/jD"),
- date: currentDate.format("jD / jM"),
- dayOfWeek: currentDate.format("dddd"),
- today: isToday, // Set today: true if it's the current date
+ const daysOfWeek = [];
+ const startOfNextWeek = moment(today, "jYYYY/jM/jD")
+ .startOf("jWeek")
+ .add(7, "days");
+ // Iterate from شنبه (Saturday) to جمعه (Friday) and add each day to the array
+ for (let i = 0; i < 7; i++) {
+ const currentDay = startOfNextWeek.clone().add(i, "days");
+ const isToday = currentDay.isSame(today, "day");
+ const dayOfWeekName = week[i].key; // Get the day name from the week array
+
+ daysOfWeek.push({
+ checkDay: currentDay.format("jYYYY/jM/jD"),
+ date: currentDay.format("jD / jM"),
+ dayOfWeek: dayOfWeekName,
+ today: isToday,
+ value: week[i].value,
});
}
- return setDaysUntilEnd(days);
+ return setDaysUntilWeek(daysOfWeek);
};
- console.log("daysUntilEnd", daysUntilEnd[selectDay]);
-
const handleManageShiftEmployeesOpen = (e) => {
setManageShiftEmployeesData(
usersData.map((item) => ({
@@ -71,27 +93,49 @@ const Calendar = () => {
);
};
- const deleteSearchUser = (id) => {
- CTX.setSearchUserChoose(searchUserChoose.filter((el) => el !== id));
+ const body = {
+ planDate:
+ daysUntilWeek[selectDay]?.checkDay &&
+ moment.utc(daysUntilWeek[selectDay].checkDay, "jYYYY-jMM-jDDTHH").unix(),
+ shiftId: shiftsPlan && shiftsPlan[selectShift]?.id,
+ routineId: routinesData && routinesData[selectRoutine]?.id,
+ userAndPositionIds,
+ };
+
+ const handleRoutineShiftPlan = (index, id) => {
+ setSelectRoutine(index);
+ CTX.GetRoutineShiftPlan(id);
+ setShiftPlanSteps(1);
+ };
+
+ const handleCreateShiftPlan = (update) => {
+ if (update == "UPDATE") {
+ // CTX.UpdateShiftPlan(bodyUpdate);
+ } else {
+ CTX.CreateShifPlan(body);
+ }
};
useEffect(() => {
+ CTX.GetRoutines();
daysEndOfMonth();
- setSelectDay(1);
+ setSelectDay(-1);
CTX.GetShifts();
- CTX.GetUsers();
+ CTX.GetPositions();
}, []);
useEffect(() => {
- // if (!!CTX.GetUsers()) {
- //
- // }
handleManageShiftEmployeesOpen();
}, [usersData]);
- console.log("searchUserChooseqqqqqqqqqqqqqqqqqqqqqqqqq", searchUserChoose);
+ useEffect(() => {
+ setShiftsPlan(
+ routineShiftPlan?.find((e) => e?.day == daysUntilWeek[selectDay]?.value)
+ ?.shifts
+ );
- console.log(daysUntilEnd);
+ setselectShift(-1);
+ }, [selectDay]);
return (
@@ -109,225 +153,272 @@ const Calendar = () => {
/>
-
console.log("slide change")}
- onSwiper={(swiper) => console.log(swiper)}
+
- {daysUntilEnd?.map((e, index) => (
-
- {
- setSelectDay(index);
- console.log(index);
- }}
- >
-
-
- b.date == e.checkDay)
- ? "text-red-500"
- : ""
- } `}
- />
-
-
-
-
b.date == e.checkDay)
- ? "bg-transparent text-red-500"
- : "bg-white text-gray-500"
- }`}
- >
-
- {/* {PersianD.find((i) => i == e.dayOfWeek)} */}
- {PersianDay(e.dayOfWeek)}
-
-
-
-
- ))}
-
-
-
-
- {shiftsData.length > 0 ? (
-
- {shiftsData.map((e, index) => (
-
setselectShift(index)}
- >
-
{e?.title}
-
- ))}
-
- ) : (
-
-
- چیزی یافت نشد
+ {routinesData?.map((e, index) => (
+
{
+ if (shiftPlanSteps >= 1) {
+ toast.error("برای تغییر روتین باید رفرش کنید", {
+ position: "bottom-right",
+ autoClose: 2000,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ });
+ } else {
+ handleRoutineShiftPlan(index, e.id);
+ }
+ }}
+ >
+
{e.name}
-
+ ))}
+
+
+ {shiftPlanSteps >= 1 && (
+
console.log("slide change")}
+ onSwiper={(swiper) => console.log(swiper)}
+ >
+ {daysUntilWeek?.map((e, index) => (
+
+ {
+ setSelectDay(index);
+ setShiftPlanSteps(2);
+ console.log(index);
+ }}
+ >
+
+
+ b.date == e.checkDay
+ )
+ ? "text-red-500"
+ : ""
+ } `}
+ />
+
+
+
+
b.date == e.checkDay)
+ ? "bg-transparent text-red-500"
+ : "bg-white text-gray-500"
+ }`}
+ >
+
+ {/* {PersianD.find((i) => i == e.dayOfWeek)} */}
+ {e.dayOfWeek}
+
+
+
+
+ ))}
+
)}
-
-
-
-
- ویرایش برای{" "}
-
- {shiftsData && shiftsData[selectShift]?.title}
- {" "}
- تاریخ{" "}
-
-
- {" "}
- میباشد
-
-
-
-
-
- {
- setSearchUserCurrntData(e.target.value);
-
- if (!!searchUserChoose.find((b) => b == e.target.value)) {
- toast.error("نقش تکراری است", {
- position: "bottom-right",
- closeOnClick: true,
- });
- } else {
- CTX.setSearchUserChoose((current) => [
- ...current,
- e.target.value,
- ]);
- }
- }}
- style="text-right"
- select={true}
- selectData={manageShiftEmployeesData}
- theme={1}
- defaultValue={"انتخاب کنید"}
- />
-
-
-
0 ? "" : "justify-center"
- }`}
- >
- {searchUserChoose.length > 0 ? (
- searchUserChoose.map((e) => (
-
-
deleteSearchUser(e)}
- >
-
b.userId == e)?.firstName}
- variant="beam"
- colors={["#9d9f88", "#83af96", "#b2de93"]}
- />
-
-
-
-
- {usersData.find((b) => b.userId == e)?.firstName}
+ {shiftPlanSteps >= 2 && (
+
+ <>
+ {!!routineShiftPlan?.find(
+ (e) => e?.day == daysUntilWeek[selectDay]?.value
+ ) && shiftsData.length > 0 ? (
+
+ {shiftsPlan?.map((e, index) => (
+
{
+ setselectShift(index);
+ setShiftPlanSteps(3);
+ }}
+ >
+
{e?.title}
+
+ ))}
+
+ ) : (
+
+
+
+ شما شیفتی دراین روز ندارید
- ))
- ) : (
-
-
- چیزی یافت نشد
+ )}
+ >
+
+ )}
+
+ {shiftPlanSteps >= 3 && (
+
+
+
+
+ ویرایش برای{" "}
+
+ {shiftsPlan && shiftsPlan[selectShift]?.title}
+ {" "}
+ تاریخ{" "}
+
+
+ {" "}
+ میباشد
+
+
+
+
+ {positionsData.map((e) => (
+
+
+
+
+
{
+ setPositionSelectIdBottomSheet(e.id);
+ setPositionSelectNameBottomSheet(e.name);
+ CTX.setBottomSheetAddUserToPositionShiftPlanOpen(true);
+ }}
+ >
+
کاربران +
+
+
+
+ {/*
+ {
+ setSearchUserCurrntData(e.target.value);
+
+ if (!!searchUserChoose.find((b) => b == e.target.value)) {
+ toast.error("نقش تکراری است", {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else {
+ CTX.setSearchUserChoose((current) => [
+ ...current,
+ e.target.value,
+ ]);
+ }
+ }}
+ style="text-right"
+ select={true}
+ selectData={manageShiftEmployeesData}
+ theme={1}
+ defaultValue={"انتخاب کنید"}
+ />
+
*/}
+
+
0 ? "" : "justify-center"
+ }`}
+ >
+ {userAndPositionIds?.length > 0 ? (
+ userAndPositionIds?.map((item) => (
+ <>
+ {e.id == item.key && (
+
+
deleteSearchUser(e)}
+ >
+
b?.userId == item?.value)
+ ?.firstName
+ }
+ variant="beam"
+ colors={["#9d9f88", "#83af96", "#b2de93"]}
+ />
+
+
+
+
+ {
+ usersData.find((b) => b.userId == item?.value)
+ ?.firstName
+ }
+
+
+
+ )}
+ >
+ ))
+ ) : (
+
+ )}
- )}
+ ))}
+
+ handleCreateShiftPlan()}
+ />
+
-
-
-
-
-
-
+ )}
+
);
};
export default Calendar;
-
-{
- /* {shiftsData.map((e, index) => (
-
-
-
-
-
-
{e?.title}
-
- {e?.title} {}
-
-
-
-
- ))} */
-}
diff --git a/src/app/shifts/page.jsx b/src/app/shifts/page.jsx
index 61c060d..c048515 100644
--- a/src/app/shifts/page.jsx
+++ b/src/app/shifts/page.jsx
@@ -1,7 +1,6 @@
"use client";
import AppHeader from "@comp/AppHeader/page";
-import ShiftCard from "@comp/ShiftComponent/ShiftCard/page";
import AppContext from "@ctx/AppContext";
import Image from "next/image";
import Link from "next/link";
@@ -69,11 +68,8 @@ const Shifts = (props) => {
-
-
-
+
-
>
);
};
diff --git a/src/app/tasks/add-task/page.jsx b/src/app/tasks/add-task/page.jsx
new file mode 100644
index 0000000..5fad656
--- /dev/null
+++ b/src/app/tasks/add-task/page.jsx
@@ -0,0 +1,704 @@
+"use client";
+
+import AppHeader from "@comp/AppHeader/page";
+import AppContext from "@ctx/AppContext";
+import Buttonbriz from "plugins/Buttonbriz/page";
+import DatePickerIran from "plugins/DatePickerIran/page";
+import Input from "plugins/Input/page";
+import PersianNumber from "plugins/PersianNumber";
+import React, { useContext, useEffect, useRef, useState } from "react";
+import { toast } from "react-toastify";
+import SimpleReactValidator from "simple-react-validator";
+import moment from "jalali-moment";
+import { useRouter, useSearchParams } from "next/navigation";
+
+const AddTask = () => {
+ const CTX = useContext(AppContext);
+ const query = useSearchParams();
+
+ const [routinesSelectData, setRoutinesSelectData] = useState([]);
+ const [routineForTaskCurrent, setRoutineForTaskCurrent] = useState([]);
+
+ const [positionsSelectData, setPositionsSelectData] = useState([]);
+ const [positionsForTaskCurrent, setPositionsForTaskCurrent] = useState([]);
+
+ const [shiftsSelectData, setShiftsSelectData] = useState([]);
+ const [shiftsForTaskCurrent, setShiftsForTaskCurrent] = useState([]);
+
+ const [title, setTitle] = useState("");
+ const [description, setDescription] = useState("");
+ const [scheduleType, setScheduleType] = useState(1);
+
+ const [birthDateTimeStamp, setBirthDateTimeStamp] = useState(0);
+
+ const [shiftsDaysSelectData, setShiftsDaysSelectData] = useState(null);
+ const [shiftsDaysCurrent, setShiftsDaysCurrent] = useState(null);
+
+ const [, forceUpdate] = useState();
+
+ const routinesData = CTX.state.routinesData;
+ const positionsData = CTX.state.positionsData;
+ const shiftsData = CTX.state.shiftsData;
+ const routineForTaskChoose = CTX.state.routineForTaskChoose;
+ const positionsForTaskChoose = CTX.state.positionsForTaskChoose;
+ const shiftsForTaskChoose = CTX.state.shiftsForTaskChoose;
+ const shiftsDaysChoose = CTX.state.shiftsDaysChoose;
+ const goToEditTask = CTX.state.goToEditTask;
+ const taskData = CTX.state.taskData;
+ const idEditTask = CTX.state.idEditTask;
+ const aqueryNew = query.get("new");
+
+ const schedule = [
+ { key: "هفتگی", value: 1 },
+ { key: "روزانه", value: 0 },
+ { key: "مخصوص یک روز ", value: 2 },
+ ];
+
+ const week = [
+ { key: "شنبه", value: 6 },
+ { key: "یکشنبه", value: 0 },
+ { key: "دوشنبه", value: 1 },
+ { key: "سه شنبه", value: 2 },
+ { key: "چهار شنبه", value: 3 },
+ { key: "پنج شنبه", value: 4 },
+ { key: "جمعه", value: 5 },
+ ];
+
+ const validator = useRef(
+ new SimpleReactValidator({
+ messages: {
+ required: "پر کردن این فیلد الزامی میباشد",
+ },
+ element: (message) => (
+ <>
+
+ {message}
+
+ >
+ ),
+ })
+ );
+
+ const body = {
+ title,
+ description,
+ routines: routineForTaskChoose,
+ positions: positionsForTaskChoose,
+ shifts: shiftsForTaskChoose,
+ scheduleType,
+ setFor:
+ birthDateTimeStamp &&
+ moment
+ .utc(
+ [
+ birthDateTimeStamp.year,
+ birthDateTimeStamp.month,
+ birthDateTimeStamp.day,
+ ],
+ "jYYYY-jMM-jDDTHH"
+ )
+ .unix(),
+ days: shiftsDaysChoose,
+ };
+
+ const bodyUpdate = {
+ title,
+ description,
+ routines: routineForTaskChoose,
+ positions: positionsForTaskChoose,
+ shifts: shiftsForTaskChoose,
+ scheduleType,
+ setFor:
+ birthDateTimeStamp &&
+ moment
+ .utc(
+ [
+ birthDateTimeStamp.year,
+ birthDateTimeStamp.month,
+ birthDateTimeStamp.day,
+ ],
+ "jYYYY-jMM-jDDTHH"
+ )
+ .unix(),
+ days: shiftsDaysChoose,
+ id: idEditTask,
+ };
+
+ const clear = () => {
+ setPositionsForTaskCurrent([]);
+ setPositionsSelectData([]);
+ setRoutineForTaskCurrent([]);
+ setRoutinesSelectData([]);
+ setBirthDateTimeStamp(0);
+ setScheduleType([]);
+ setDescription([]);
+ setTitle("");
+ setShiftsForTaskCurrent([]);
+ setShiftsSelectData([]);
+ setShiftsDaysCurrent([]);
+ setShiftsDaysSelectData([]);
+ CTX.setRoutineForTaskChoose([]);
+ CTX.setPositionsForTaskChoose([]);
+ CTX.setShiftsForTaskChoose([]);
+ CTX.setShiftsDaysChoose([]);
+ };
+
+ const handleCreateTask = (update) => {
+ if (scheduleType == 0) {
+ console.log("scheduleType == 0");
+ validator.current.message("shiftsDaysChoose", true, "required");
+ validator.current.message("birthDateTimeStamp", true, "required");
+ }
+
+ if (scheduleType == 1) {
+ console.log("scheduleType == 1");
+
+ validator.current.message("birthDateTimeStamp", true, "required");
+ }
+
+ if (scheduleType == 2) {
+ console.log("scheduleType == 2");
+
+ validator.current.message("shiftsDaysChoose", true, "required");
+ }
+
+ if (validator.current.allValid()) {
+ if (update == "UPDATE") {
+ CTX.UpdateTask(bodyUpdate);
+ } else {
+ CTX.CreateTask(body);
+ }
+ } else {
+ toast.error("پرکردن همه ی فیلد ها واجب است", {
+ position: "bottom-right",
+ autoClose: 2000,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ });
+
+ validator.current.showMessages();
+ console.log(validator.current);
+ forceUpdate(1);
+ }
+ };
+
+ const deleteRoutineForTask = (value) => {
+ CTX.setRoutineForTaskChoose(
+ routineForTaskChoose.filter((el) => el !== value)
+ );
+ };
+
+ const deletePositionForTask = (value) => {
+ CTX.setPositionsForTaskChoose(
+ positionsForTaskChoose.filter((el) => el !== value)
+ );
+ };
+
+ const deleteShiftForTask = (value) => {
+ CTX.setShiftsForTaskChoose(
+ shiftsForTaskChoose.filter((el) => el !== value)
+ );
+ };
+
+ const deleteShiftsDaysForTask = (value) => {
+ CTX.setShiftsDaysChoose(shiftsDaysChoose.filter((el) => el !== value));
+ };
+
+ useEffect(() => {
+ if (aqueryNew) {
+ clear();
+ }
+ CTX.GetRoutines();
+ CTX.GetPositions();
+ CTX.GetShifts();
+ }, []);
+
+ useEffect(() => {
+ setRoutinesSelectData(
+ routinesData?.map((item) => ({
+ key: item?.name,
+ value: item?.id,
+ }))
+ );
+ }, [routinesData]);
+
+ useEffect(() => {
+ setPositionsSelectData(
+ positionsData?.map((item) => ({
+ key: item?.name,
+ value: item?.id,
+ }))
+ );
+ }, [positionsData]);
+
+ useEffect(() => {
+ setShiftsSelectData(
+ shiftsData?.map((item) => ({
+ key: item?.title,
+ value: item?.id,
+ }))
+ );
+ }, [shiftsData]);
+
+ useEffect(() => {
+ setShiftsDaysSelectData(
+ shiftsForTaskChoose?.length > 0 &&
+ shiftsData
+ ?.find((e) => e?.id == shiftsForTaskChoose[0])
+ ?.days?.map((item) => ({
+ key: week?.find((e) => e.value == item)?.key,
+ value: item,
+ }))
+ );
+ }, [shiftsForTaskChoose]);
+
+ useEffect(() => {
+ switch (scheduleType) {
+ case 0:
+ setBirthDateTimeStamp(0);
+ CTX.setShiftsDaysChoose([]);
+
+ break;
+ case 1:
+ setBirthDateTimeStamp(0);
+
+ break;
+ case 2:
+ CTX.setShiftsDaysChoose([]);
+
+ break;
+ default:
+ break;
+ }
+ }, [scheduleType]);
+
+ useEffect(() => {
+ // console.log("ssssssssssssssssssssssssss", taskData.routines);
+
+ if (goToEditTask) {
+ // const date = moment
+ // .unix(taskData.birthDateTimeStamp)
+ // .locale("fa")
+ // .format("YYYY/MM/DD")
+ // .split("/");
+
+ // setBirthDateTimeStamp({
+ // day: parseInt(date[2]),
+ // month: parseInt(date[1]),
+ // year: parseInt(date[0]),
+ // });
+ setScheduleType(taskData.scheduleType);
+ setDescription(taskData.description);
+ setTitle(taskData.title);
+ CTX.setRoutineForTaskChoose(
+ taskData.routines?.map((item) => item.routineId)
+ );
+ CTX.setPositionsForTaskChoose(
+ taskData.positions?.map((item) => item.positionId)
+ );
+ CTX.setShiftsDaysChoose(taskData.days?.map((item) => item.dayOfWeek));
+ CTX.setShiftsForTaskChoose(taskData.shifts?.map((item) => item.shiftId));
+ }
+ }, [taskData]);
+
+ console.log("body", body);
+
+ return (
+
+
+
+
+
+
+ {
+ setTitle(e.target.value);
+ validator.current.showMessageFor("title");
+ }}
+ style="text-right"
+ validator={true}
+ validatorData={validator.current.message(
+ "title",
+ title,
+ "required"
+ )}
+ />
+
+
+
+ {
+ setDescription(e.target.value);
+ validator.current.showMessageFor("description");
+ }}
+ textarea={true}
+ style="text-right"
+ />
+
+ {/* ===========routine=============== */}
+
+
+ {
+ setRoutineForTaskCurrent(e.target.value);
+ validator.current.showMessageFor("routines");
+
+ if (routineForTaskChoose.length >= 1) {
+ toast.error(
+ "فعلا معلوم نیست بیشتر از یکی بتونی باید با ممد اینا حرف بزنیم",
+ {
+ position: "bottom-right",
+ closeOnClick: true,
+ }
+ );
+ } else {
+ if (!!routineForTaskChoose.find((b) => b == e.target.value)) {
+ toast.error("روز تکراری است", {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else {
+ CTX.setRoutineForTaskChoose((current) => [
+ ...current,
+ e.target.value,
+ ]);
+ }
+ }
+ }}
+ style="text-right"
+ validator={true}
+ validatorData={validator.current.message(
+ "routines",
+ routineForTaskChoose,
+ ["required", { min: 1 }]
+ )}
+ select={true}
+ selectData={routinesSelectData}
+ defaultValue={"انتخاب کنید"}
+ />
+
+
+
+ {routineForTaskChoose &&
+ routineForTaskChoose.map((e, index) => (
+
+
deleteRoutineForTask(e)}
+ >
+
+
+
+ {routinesData?.find((b) => b.id == e)?.name}
+
+
+
+ ))}
+
+ {/* ===========position=============== */}
+
+
+ {
+ setPositionsForTaskCurrent(e.target.value);
+ validator.current.showMessageFor("positions");
+
+ if (positionsForTaskChoose.length >= 1) {
+ toast.error(
+ "فعلا معلوم نیست بیشتر از یکی بتونی باید با ممد اینا حرف بزنیم",
+ {
+ position: "bottom-right",
+ closeOnClick: true,
+ }
+ );
+ } else {
+ if (
+ !!positionsForTaskChoose.find((b) => b == e.target.value)
+ ) {
+ toast.error("روز تکراری است", {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else {
+ CTX.setPositionsForTaskChoose((current) => [
+ ...current,
+ e.target.value,
+ ]);
+ }
+ }
+ }}
+ style="text-right"
+ validatorData={validator.current.message(
+ "positions",
+ positionsForTaskChoose,
+ ["required", { min: 1 }]
+ )}
+ select={true}
+ selectData={positionsSelectData}
+ defaultValue={"انتخاب کنید"}
+ />
+
+
+
+ {positionsForTaskChoose &&
+ positionsForTaskChoose.map((e, index) => (
+
+
deletePositionForTask(e)}
+ >
+
+
+
+ {positionsData?.find((b) => b.id == e)?.name}
+
+
+
+ ))}
+
+
+ {/* ===========shifts=============== */}
+
+ {
+ setShiftsForTaskCurrent(e.target.value);
+ validator.current.showMessageFor("shifts");
+
+ if (shiftsForTaskChoose.length >= 1) {
+ toast.error(
+ "فعلا معلوم نیست بیشتر از یکی بتونی باید با ممد اینا حرف بزنیم",
+ {
+ position: "bottom-right",
+ closeOnClick: true,
+ }
+ );
+ } else {
+ if (!!shiftsForTaskChoose.find((b) => b == e.target.value)) {
+ toast.error("روز تکراری است", {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else {
+ CTX.setShiftsForTaskChoose((current) => [
+ ...current,
+ e.target.value,
+ ]);
+ }
+ }
+ }}
+ style="text-right"
+ validatorData={validator.current.message(
+ "shifts",
+ shiftsForTaskChoose,
+ ["required", { min: 1 }]
+ )}
+ select={true}
+ selectData={shiftsSelectData}
+ defaultValue={"انتخاب کنید"}
+ />
+
+
+
+ {shiftsForTaskChoose &&
+ shiftsForTaskChoose.map((e, index) => (
+
+
deleteShiftForTask(e)}
+ >
+
+
+
+ {shiftsData?.find((b) => b?.id == e)?.title}
+
+
+
+ ))}
+
+
+ {/* ===========scheduleType=============== */}
+
+
+ {
+ setScheduleType(parseInt(e.target.value));
+ validator.current.showMessageFor("scheduleType");
+ }}
+ style="text-right"
+ validator={true}
+ validatorData={validator.current.message(
+ "scheduleType",
+ scheduleType,
+ ["required"]
+ )}
+ select={true}
+ selectData={[
+ { key: "هفتگی", value: 1 },
+ { key: "روزانه", value: 0 },
+ { key: "مخصوص یک روز ", value: 2 },
+ ]}
+ defaultValue={"انتخاب کنید"}
+ />
+
+
+ {/*
+
+
+
+ {schedule?.find((b) => b.value == scheduleType)?.key}
+
+
+
+
*/}
+
+ {/* ===========scheduleType setFor=============== */}
+
+ {scheduleType == 2 && (
+
{
+ setBirthDateTimeStamp(e);
+ validator.current.showMessageFor("birthDateTimeStamp");
+ }}
+ date={birthDateTimeStamp}
+ zindex="z-[101]"
+ validator={true}
+ validatorData={validator.current.message(
+ "birthDateTimeStamp",
+ birthDateTimeStamp,
+ ["required"]
+ )}
+ />
+ )}
+
+ {/* ===========shiftsDaysTask=============== */}
+ {scheduleType == 1 && (
+ <>
+
+ {
+ setShiftsDaysCurrent(e.target.value);
+ validator.current.showMessageFor("shiftsDaysChoose");
+
+ if (!!shiftsDaysChoose.find((b) => b == e.target.value)) {
+ toast.error("روز تکراری است", {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else {
+ CTX.setShiftsDaysChoose((current) => [
+ ...current,
+ parseInt(e.target.value),
+ ]);
+ }
+ }}
+ validator={true}
+ validatorData={validator.current.message(
+ "shiftsDaysChoose",
+ shiftsDaysChoose,
+ ["required", { min: 1 }]
+ )}
+ style="text-right"
+ select={true}
+ selectData={shiftsDaysSelectData}
+ defaultValue={"انتخاب کنید"}
+ />
+
+
+
+ {shiftsDaysChoose &&
+ shiftsDaysChoose.map((e, index) => (
+
+
deleteShiftsDaysForTask(e)}
+ >
+
+
+
+ {week?.find((b) => b.value == e).key}
+
+
+
+ ))}
+
+ >
+ )}
+ {goToEditTask ? (
+
handleCreateTask("UPDATE")}
+ subButton={true}
+ subButtonTitle="حذف فعالیت"
+ subButtonEvent={() => CTX.DeleteTask(idEditTask)}
+ />
+ ) : (
+ handleCreateTask()}
+ />
+ )}{" "}
+
+
+ );
+};
+
+export default AddTask;
diff --git a/src/app/tasks/page.jsx b/src/app/tasks/page.jsx
new file mode 100644
index 0000000..21c6ab6
--- /dev/null
+++ b/src/app/tasks/page.jsx
@@ -0,0 +1,114 @@
+"use client";
+
+import AppHeader from "@comp/AppHeader/page";
+import AppContext from "@ctx/AppContext";
+import BottomSheetCreateRoutine from "plugins/BottomSheet/BottomSheetCreateRoutine";
+import PersianNumber from "plugins/PersianNumber";
+import React, { useContext, useEffect } from "react";
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+import ActivityCard from "@comp/TaskPage/ActivityCard/page";
+import TasksCard from "@comp/TaskPage/TasksCard/page";
+
+const page = () => {
+ const CTX = useContext(AppContext);
+
+ const router = useRouter();
+
+ const routinesData = CTX.state.routinesData;
+
+ useEffect(() => {
+ CTX.GetTasks();
+ }, []);
+ return (
+
+
{
+ CTX.setTaskData([]);
+ CTX.setIdEditTask("");
+ CTX.setGoToEditTask(false);
+ }}
+ icon2={true}
+ iconName2="ARROW"
+ iconHref2="/home"
+ iconEvent2={() => {
+ return undefined;
+ }}
+ />
+
+
+
+
+
تسک های هفتگی مجموعه
+
+ امروز
+
+
+
+ تسک فعال دارید
+
+
+
+
+
+
+
+
+
+
تسک های امروز
+
+ امروز
+
+
+
+ تسک فعال دارید
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default page;
diff --git a/style/globals.css b/style/globals.css
index d989a64..d7246b8 100644
--- a/style/globals.css
+++ b/style/globals.css
@@ -66,6 +66,7 @@ body {
font-family: KalamehWeb !important;
background: #eeeeee;
--toastify-font-family: KalamehWeb !important;
+ --Chart-defaults-font-family: KalamehWeb !important;
}
.rtl {