diff --git a/src/app/layout.jsx b/src/app/layout.jsx
index 301a52b..12e1b87 100644
--- a/src/app/layout.jsx
+++ b/src/app/layout.jsx
@@ -18,6 +18,7 @@ import Loading from "plugins/Loading/page";
import Chapar, { getToken } from "plugins/Chapar";
import TimePicker from "plugins/TimePicker/page";
import axios from "axios";
+import "rc-slider/assets/index.css";
const inter = Inter({ subsets: ["latin"] });
@@ -136,6 +137,9 @@ export default function RootLayout({ children }) {
const [openTimePicker, setOpenTimePicker] = useState(false);
const [TimePickerOrder, setTimePickerOrder] = useState(null);
+ // closeShift
+ const [completeActivities, setCompleteActivities] = useState([]);
+
const pathname = usePathname();
const router = useRouter();
const hiddenUrls = ["/login", "/"];
@@ -188,7 +192,7 @@ export default function RootLayout({ children }) {
router.push("/home");
}
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -209,7 +213,6 @@ export default function RootLayout({ children }) {
}
);
- console.log("SignUpLogin", SignUpLogin);
setLoading(false);
if (data.user.signUpStatus == 2 || data.user.signUpStatus == 3) {
@@ -224,7 +227,7 @@ export default function RootLayout({ children }) {
router.push("/home");
}
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -245,11 +248,10 @@ export default function RootLayout({ children }) {
}
);
- console.log(data);
setPermissions(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -278,7 +280,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoles();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -306,7 +308,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoles();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -325,12 +327,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetRoles", data);
-
setRolesData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -349,12 +349,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetRole ", data);
-
setRoleData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -378,7 +376,7 @@ export default function RootLayout({ children }) {
GetRoles();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -407,7 +405,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetUsers();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -435,7 +433,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetUsers();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -455,11 +453,10 @@ export default function RootLayout({ children }) {
}
);
- console.log("GetUsers", data);
setUsersData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -478,12 +475,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetUsersalam", data);
-
setUserData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -507,7 +502,7 @@ export default function RootLayout({ children }) {
GetUsers();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -535,7 +530,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetShifts();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -564,37 +559,43 @@ export default function RootLayout({ children }) {
setLoading(false);
GetShifts();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
- const GetShifts = async () => {
+ const GetShifts = async (date) => {
+ console.log(
+ "Date123456789",
+ `${process.env.NEXT_PUBLIC_API_URL}/shift?page=0${
+ date ? `&selectedDate=${date}` : ""
+ }`
+ );
setLoading(true);
try {
const data = await Chapar.get(
- `${process.env.NEXT_PUBLIC_API_URL}/shift?page=0`,
-
+ `${process.env.NEXT_PUBLIC_API_URL}/shift?page=0${
+ date ? `&selectedDate=${date}` : ""
+ }`,
{
headers: {
Authorization: getToken(),
},
}
);
- console.log("GetShifts", data);
-
setShiftsData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
}
};
+
const GetShift = async (id) => {
setLoading(true);
try {
@@ -607,12 +608,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetShift", data);
-
setShiftData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -636,7 +635,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetShifts();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -664,7 +663,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetSections();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -693,7 +692,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetSections();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -712,12 +711,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetSection", data);
-
setSectionsData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -736,12 +733,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetShift", data);
-
setSectionData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -765,7 +760,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetSections();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -793,7 +788,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -822,7 +817,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -841,16 +836,18 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetRoutines", GetRoutines);
-
setRoutinesData(data);
setLoading(false);
- } catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ } catch (error) {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
setLoading(false);
+ // if (error.response.status === 401) {
+ // localStorage.removeItem("token");
+ // window.location.href = "/";
+ // }
}
};
const GetRoutine = async (id) => {
@@ -865,12 +862,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetRoutine", GetRoutine);
-
setRoutineData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -891,12 +886,10 @@ export default function RootLayout({ children }) {
}
);
- console.log("GetRoutineShift", data);
-
setRoutineShiftPlan(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -921,7 +914,7 @@ export default function RootLayout({ children }) {
});
router.push("/shifts");
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -946,7 +939,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetRoutines();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -974,7 +967,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetPositions();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1003,7 +996,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetPositions();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1022,12 +1015,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetPositions", data);
-
setPositionsData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1046,12 +1037,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetPosition", data);
-
setPositionData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1075,7 +1064,7 @@ export default function RootLayout({ children }) {
setLoading(false);
GetPositions();
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1106,7 +1095,7 @@ export default function RootLayout({ children }) {
router.push("/tasks");
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1137,7 +1126,7 @@ export default function RootLayout({ children }) {
GetTasks();
router.push("/tasks");
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1156,12 +1145,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetTasks", data);
-
setTasksData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1180,12 +1167,10 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetPosition", data);
-
setTaskData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1209,7 +1194,7 @@ export default function RootLayout({ children }) {
GetTasks();
router.push("/tasks");
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1217,11 +1202,13 @@ export default function RootLayout({ children }) {
}
};
- const GetActivity = async () => {
+ const GetActivity = async (date, shift) => {
setLoading(true);
try {
const data = await Chapar.get(
- `${process.env.NEXT_PUBLIC_API_URL}/activity?page=0`,
+ `${process.env.NEXT_PUBLIC_API_URL}/activity?page=0${
+ date ? `&selectedDate=${date}` : ""
+ }${shift ? `&selectedShift=${shift}` : ""}`,
{
headers: {
@@ -1229,12 +1216,114 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("GetActivity", data);
-
setActivitiesData(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ 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: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ 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);
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/activity/undone/${id}?undoneReason=${resone}`,
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ 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 CloseShift = async (body, id) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/shift/plan/${id}/complete`,
+ body,
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ toast.success(`فعالیت ثبت شد`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ // router->
+
+ setLoading(false);
+ // GetTasks();
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ setLoading(false);
+ }
+ };
+
+ const changeRole = async (id) => {
+ setLoading(true);
+ try {
+ const data = await Chapar.post(
+ `${process.env.NEXT_PUBLIC_API_URL}/user/role/change/${id}`,
+
+ {
+ headers: {
+ Authorization: getToken(),
+ },
+ }
+ );
+ setProfile(data);
+ setLoading(false);
+ } catch ({ error, status }) {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1254,13 +1343,11 @@ export default function RootLayout({ children }) {
},
}
);
- console.log("CheckUser", data);
-
setProfile(data);
setLoading(false);
} catch ({ error, status }) {
- toast.error(`${error.response.data.message}`, {
+ toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,
});
@@ -1269,6 +1356,28 @@ export default function RootLayout({ children }) {
};
useEffect(() => {
+ 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
+ bbbbbbbbbbbbbbbb rrrrrrr iiiiiiizzzzzzzzzzzzzzzzz cccccccccccccccc ooooooooooo
+ soli chizi bood bgo hossein__masoomi
+
+ `);
+
if (profile.length <= 0 && localStorage.token) CheckUser();
}, []);
@@ -1338,6 +1447,7 @@ export default function RootLayout({ children }) {
BottomSheetAddUserToPositionShiftPlanOpen,
BottomSheetChangeRoleOpen,
activitiesData,
+ completeActivities,
},
setBottomSheetCreateRoleOpen,
setBottomSheetCreateEmployeesOpen,
@@ -1441,6 +1551,11 @@ export default function RootLayout({ children }) {
setBottomSheetChangeRoleOpen,
setActivitiesData,
GetActivity,
+ UnDoneActivity,
+ DoneActivity,
+ changeRole,
+ setCompleteActivities,
+ CloseShift,
}}
>
@@ -1452,12 +1567,12 @@ export default function RootLayout({ children }) {
{openTimePicker &&
}
{BigPlusOpen ? (
-
+
-
+
-
-
-
-
افزودن خرید جدیـــــد
+
+
+
closeBigPlusPage()}
+ >
+
بستن شیفت
-
-
-
+
+
+
closeBigPlusPage()}
+ >
+
+ افزودن خرید جدیـــــد
+
+
+
+
+
+
closeBigPlusPage()}
+ >
+
افزودن وظیفه جدید
+
+
+
diff --git a/src/app/login/page.jsx b/src/app/login/page.jsx
index 7dc89dc..b724cfb 100644
--- a/src/app/login/page.jsx
+++ b/src/app/login/page.jsx
@@ -14,14 +14,14 @@ const Login = (props) => {
const stepLogin = CTX.state.stepLogin;
const router = useRouter();
- // useEffect(() => {
- // if (typeof window !== "undefined") {
- // const item = localStorage.token;
- // if (!!item) {
- // router.push("/home");
- // }
- // }
- // }, []);
+ useEffect(() => {
+ if (typeof window !== "undefined") {
+ const item = localStorage.token;
+ if (!!item) {
+ router.push("/home");
+ }
+ }
+ }, []);
return (
diff --git a/src/app/shifts/complete-shift/page.jsx b/src/app/shifts/complete-shift/page.jsx
index 99c6c5b..8f38185 100644
--- a/src/app/shifts/complete-shift/page.jsx
+++ b/src/app/shifts/complete-shift/page.jsx
@@ -1,10 +1,142 @@
+"use client";
import AppHeader from "@comp/AppHeader/page";
-import TaskCard from "@comp/TaskPage/ActivityCard/page";
+import ActivityCard from "@comp/TaskPage/ActivityCard/page";
+import ActivityCardCloseShift from "@comp/TaskPage/ActivityCardCloseShift/page";
+import AppContext from "@ctx/AppContext";
+import moment from "jalali-moment";
+import Buttonbriz from "plugins/Buttonbriz/page";
import PersianNumber from "plugins/PersianNumber";
-import React from "react";
+import Slider from "rc-slider";
+import React, { useContext, useEffect, useState } from "react";
+import { toast } from "react-toastify";
const CompleteShift = () => {
- const data = [1, 2, 3, 4, 5, 8];
+ const CTX = useContext(AppContext);
+
+ const [closeShiftScore, setCloseShiftScore] = useState(70);
+ const [activeShifPlan, setActiveShifPlan] = useState(-1);
+ const [selectDayForShift, setSelectDayForShift] = useState(-1);
+ const currentDate = new Date();
+
+ const siftsData = CTX.state.shiftsData;
+ const activitiesData = CTX.state.activitiesData;
+
+ const circularHandleStyle = {
+ backgroundColor: "green",
+ border: "2px solid #ffffff",
+ boxShadow: "0 0 5px #333",
+ cursor: "pointer",
+ height: 30, // Adjust the height in pixels
+ width: 30, // Adjust the width to maintain a circular shape
+ marginLeft: -15, // Adjust the margin to center the handle
+ marginTop: -10, // Adjust the margin to center the handle
+ borderRadius: "50%", // Make the handle circular
+ };
+
+ const railStyle = {
+ backgroundColor: "red", // Overall track color
+ height: 10,
+ };
+
+ const trackStyle = {
+ backgroundColor: "green", // Color between handles
+ height: 10,
+ };
+
+ const body = {
+ completeDescription: "",
+ completeActivities: CTX.state.completeActivities,
+ completePercent: closeShiftScore,
+ };
+
+ const getTodayPersianDate = () => {
+ return moment().locale("fa").format("D MMMM YYYY");
+ };
+
+ const getYesterdayPersianDate = () => {
+ const yesterday = moment().locale("fa").subtract(1, "day");
+ return yesterday.format("D MMMM YYYY");
+ };
+
+ const getTomorrowPersianDate = () => {
+ const tomorrow = moment().locale("fa").add(1, "day");
+ return tomorrow.format("D MMMM YYYY");
+ };
+
+ const handleOpenShift = (isCompleted, id, index, hasCurrentShiftPlan) => {
+ if (isCompleted) {
+ toast.warning(`شیفت بسته شده است `, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else if (!hasCurrentShiftPlan) {
+ toast.warning(`شیفت نا مشخص است `, {
+ position: "bottom-right",
+ closeOnClick: true,
+ });
+ } else {
+ handleActivityCloseShift(id, index);
+ }
+ };
+ const handleActivityCloseShift = (id, index) => {
+ CTX.setCompleteActivities([]);
+ setCloseShiftScore(70);
+ if (activeShifPlan == index) {
+ setActiveShifPlan(-1);
+ } else {
+ setActiveShifPlan(index);
+
+ if (selectDayForShift == 0) {
+ CTX.GetActivity(
+ moment().locale("fa").subtract(1, "day").unix() * 1000,
+ id
+ );
+ } else if (selectDayForShift == 1) {
+ CTX.GetActivity(moment().locale("fa").startOf("day").unix() * 1000, id);
+ } else if (selectDayForShift == 2) {
+ CTX.GetActivity(moment().locale("fa").add(1, "day").unix() * 1000, id);
+ }
+ }
+ };
+
+ const handleDayCloseShift = (index) => {
+ setSelectDayForShift(index);
+ setActiveShifPlan(-1);
+
+ if (index == 0) {
+ CTX.GetShifts(moment().locale("fa").subtract(1, "day").unix() * 1000);
+ } else if (index == 1) {
+ CTX.GetShifts(moment().locale("fa").startOf("day").unix() * 1000);
+ } else if (index == 2) {
+ CTX.GetShifts(moment().locale("fa").add(1, "day").unix() * 1000);
+ }
+ };
+
+ const handleCloseShift = () => {
+ CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId);
+
+ // ;
+ // ;
+ // ;
+ // ;
+ };
+
+ useEffect(() => {
+ handleDayCloseShift(1);
+ }, []);
+
+ useEffect(() => {
+ if (activitiesData.length > 0) {
+ CTX.setCompleteActivities(
+ activitiesData.map((activity) => ({
+ activityId: activity?.id,
+ isCompleted: activity?.isDone,
+ performanceDescription: activity?.performanceDescription,
+ }))
+ );
+ }
+ }, [activitiesData]);
+
return (
{
/>
- {" "}
-
-
- فعالیت های انجام شده{" "}
-
-
- در این شیفت
-
-
-
- فعالیت از
-
-
-
- نفر انجام شده است
-
+
+
handleDayCloseShift(0)}
+ >
+
+
+
handleDayCloseShift(1)}
+ >
+
+
+ ( امروز )
+
+
+
+
handleDayCloseShift(2)}
+ >
+
+
- {data.map((e) => (
-
+
+ {siftsData?.map((e, index) => (
+
+
+ handleOpenShift(
+ e?.isCompleted,
+ e?.id,
+ index,
+ e?.hasCurrentShiftPlan
+ )
+ }
+ >
+
{e?.title}
+
+
+
+
+ {e?.undoneActivitiesCount != 0 && (
+
+ )}
+
+ {e?.isCompleted && (
+
+ )}
+
+
+ {activeShifPlan == index && (
+ <>
+ {activitiesData?.map((e) => (
+
+ ))}
+
+
+
+ setCloseShiftScore(e)}
+ />
+
+
+
handleCloseShift()}
+ />
+
+ >
+ )}
+
))}
diff --git a/src/app/shifts/manage-shift/page.jsx b/src/app/shifts/manage-shift/page.jsx
index d748b27..0860d9a 100644
--- a/src/app/shifts/manage-shift/page.jsx
+++ b/src/app/shifts/manage-shift/page.jsx
@@ -96,7 +96,8 @@ const Calendar = () => {
const body = {
planDate:
daysUntilWeek[selectDay]?.checkDay &&
- moment.utc(daysUntilWeek[selectDay].checkDay, "jYYYY-jMM-jDDTHH").unix(),
+ moment.utc(daysUntilWeek[selectDay].checkDay, "jYYYY-jMM-jDDTHH").unix() *
+ 1000,
shiftId: shiftsPlan && shiftsPlan[selectShift]?.id,
routineId: routinesData && routinesData[selectRoutine]?.id,
userAndPositionIds,
@@ -196,8 +197,8 @@ const Calendar = () => {
console.log("slide change")}
- onSwiper={(swiper) => console.log(swiper)}
+ // onSlideChange={() => }
+ // onSwiper={(swiper) => }
>
{daysUntilWeek?.map((e, index) => (
@@ -211,7 +212,6 @@ const Calendar = () => {
onClick={() => {
setSelectDay(index);
setShiftPlanSteps(2);
- console.log(index);
}}
>
@@ -406,7 +406,7 @@ const Calendar = () => {
>
))
) : (
-
+
چیزی یافت نشد
diff --git a/src/app/shifts/page.jsx b/src/app/shifts/page.jsx
index c048515..ba9d3f4 100644
--- a/src/app/shifts/page.jsx
+++ b/src/app/shifts/page.jsx
@@ -8,15 +8,14 @@ import { useRouter } from "next/navigation";
import BottomSheetCreateShifts from "plugins/BottomSheet/BottomSheetCreateShifts";
import PersianNumber from "plugins/PersianNumber";
-import React, { useContext, useEffect } from "react";
+import React, { useContext, useEffect, useState } from "react";
+import Slider, { Range } from "rc-slider";
+import Buttonbriz from "plugins/Buttonbriz/page";
+import moment from "jalali-moment";
+import ActivityCard from "@comp/TaskPage/ActivityCard/page";
const Shifts = (props) => {
const CTX = useContext(AppContext);
- const router = useRouter();
-
- useEffect(() => {
- CTX.GetShifts();
- }, []);
return (
<>
@@ -24,12 +23,12 @@ const Shifts = (props) => {
{
- CTX.setBottomSheetCreateShiftsOpen(true);
- }}
+ // icon1={true}
+ // iconName1="PLUS"
+ // iconHref1="#"
+ // iconEvent1={() => {
+ // CTX.setBottomSheetCreateShiftsOpen(true);
+ // }}
icon2={true}
iconName2="ARROW"
iconHref2="/home"
diff --git a/src/app/tasks/add-task/page.jsx b/src/app/tasks/add-task/page.jsx
index 5fad656..32bbfa7 100644
--- a/src/app/tasks/add-task/page.jsx
+++ b/src/app/tasks/add-task/page.jsx
@@ -145,20 +145,15 @@ const AddTask = () => {
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");
}
@@ -180,7 +175,6 @@ const AddTask = () => {
});
validator.current.showMessages();
- console.log(validator.current);
forceUpdate(1);
}
};
@@ -276,7 +270,7 @@ const AddTask = () => {
}, [scheduleType]);
useEffect(() => {
- // console.log("ssssssssssssssssssssssssss", taskData.routines);
+ // ;
if (goToEditTask) {
// const date = moment
@@ -304,8 +298,6 @@ const AddTask = () => {
}
}, [taskData]);
- console.log("body", body);
-
return (
{
const CTX = useContext(AppContext);
const router = useRouter();
-
- const routinesData = CTX.state.routinesData;
+ const activities = CTX.state.activitiesData;
+ const tasksData = CTX.state.tasksData;
+ const permissions = CTX.state.profile?.permissions;
useEffect(() => {
CTX.GetTasks();
- CTX.GetActivity();
+ CTX.GetActivity(moment().locale("fa").startOf("day").unix() * 1000);
}, []);
return (
{
@@ -49,7 +52,7 @@ const page = () => {
امروز
-
+
تسک فعال دارید
@@ -71,7 +74,7 @@ const page = () => {
-
+
@@ -103,7 +106,9 @@ const page = () => {
-
+ {activities?.map((e) => (
+
+ ))}