From 644f19eebec7c232adb9da994934ba3ab62b06c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=AD=D8=B3=DB=8C=D9=86=20=D9=85=D8=B9=D8=B5=D9=88=D9=85?= =?UTF-8?q?=DB=8C=20=D9=BE=D9=88=D8=B1?= Date: Mon, 6 May 2024 14:08:12 +0330 Subject: [PATCH] fix bugs --- .env | 8 +- .../TaskPage/ActivityCardCloseShift/page.jsx | 16 ++- components/TaskPage/TasksCard/page.jsx | 15 ++- plugins/Chapar/index.js | 8 +- src/app/home/page.jsx | 36 ++++-- src/app/layout.jsx | 12 +- src/app/shifts/complete-shift/page.jsx | 37 +++++- src/app/shifts/page.jsx | 105 +++++++++++++++++- src/app/tasks/page.jsx | 10 +- style/globals.css | 23 ++++ 10 files changed, 234 insertions(+), 36 deletions(-) diff --git a/.env b/.env index 4daae03..d7337d9 100644 --- a/.env +++ b/.env @@ -1,9 +1,9 @@ NODE_ENV="development" -NEXT_PUBLIC_SERVER_URL=http://192.168.1.12:32768 -NEXT_PUBLIC_PUBLIC_URL=http://192.168.1.12:32768 -NEXT_PUBLIC_API_URL=http://192.168.1.12:32768/api -NEXT_PUBLIC_VERSION=0.2.7 +NEXT_PUBLIC_SERVER_URL=http://192.168.1.12:32767 +NEXT_PUBLIC_PUBLIC_URL=http://192.168.1.12:32767 +NEXT_PUBLIC_API_URL=http://192.168.1.12:32767/api +NEXT_PUBLIC_VERSION=0.3.0 # SECURE_LOCAL_STORAGE_HASH_KEY=f1da2b2c7a4c446934267fea631102ec389b5b99 # NEXT_PUBLIC_API_URL_IMAGE=https://192.168.88.12:49154/Files/ReportImages diff --git a/components/TaskPage/ActivityCardCloseShift/page.jsx b/components/TaskPage/ActivityCardCloseShift/page.jsx index 20902da..93e6418 100644 --- a/components/TaskPage/ActivityCardCloseShift/page.jsx +++ b/components/TaskPage/ActivityCardCloseShift/page.jsx @@ -1,8 +1,10 @@ "use client"; import AppContext from "@ctx/AppContext"; import Avatar from "boring-avatars"; +import moment from "jalali-moment"; import Buttonbriz from "plugins/Buttonbriz/page"; import Input from "plugins/Input/page"; +import PersianNumber from "plugins/PersianNumber"; import React, { useContext, useRef, useState } from "react"; import SimpleReactValidator from "simple-react-validator"; @@ -113,6 +115,18 @@ const ActivityCardCloseShift = ({ data }) => { {data?.shiftTitle} +
+ {data?.userFullName} +
+ + {data?.doneAt !== "0001-01-01T00:00:00" && ( +
+ {" "} +
+ )} @@ -276,7 +290,7 @@ const ActivityCardCloseShift = ({ data }) => { >
{ } }; + console.log("tasksData", tasksData.days); + return (
{tasksData?.map((e, index) => ( @@ -30,7 +32,7 @@ const TasksCard = ({ tasksData, permissions }) => { goToEditTask(e.id); }} > -
+
{/*
*/} @@ -53,6 +55,17 @@ const TasksCard = ({ tasksData, permissions }) => {
+ {e?.days?.length > 0 && ( + <> + {e?.days.map((s) => ( +
+ {" "} + {s} +
+ ))} + + )} +
{" "} {e?.positions[0]} diff --git a/plugins/Chapar/index.js b/plugins/Chapar/index.js index ba2f528..8243fe0 100644 --- a/plugins/Chapar/index.js +++ b/plugins/Chapar/index.js @@ -31,10 +31,10 @@ Chapar.interceptors.response.use( // Do something with response error // ; - // if (error.response.status === 401) { - // localStorage.removeItem("token"); - // window.location.href = "/login"; - // } + if (error.response.status === 401) { + localStorage.removeItem("token"); + window.location.href = "/login"; + } return Promise.reject({ error, status: error?.response?.status }); } diff --git a/src/app/home/page.jsx b/src/app/home/page.jsx index aef44ca..7880dd8 100644 --- a/src/app/home/page.jsx +++ b/src/app/home/page.jsx @@ -92,6 +92,8 @@ const Home = (props) => { const today = new Date(); const formattedDate = formatJalaliDate(today); + console.log(homePageData?.todayStaffNames?.slice(0, 4)); + return (
{ />
+
+
+
+
+
+

+ +

+ +

+ {homePageData?.currentShift}-{homePageData?.currentPosition} +

+
+
{homePageData?.totalStaffToday > 0 && (
-
+
{homePageData?.todayStaffNames ?.slice(0, 4) .map((e, index) => (
{
)} +
-

- -

diff --git a/src/app/layout.jsx b/src/app/layout.jsx index 7860c76..a570845 100644 --- a/src/app/layout.jsx +++ b/src/app/layout.jsx @@ -984,11 +984,11 @@ export default function RootLayout({ children }) { setLoading(false); } }; - const GetShifPlans = async (page) => { + const GetShifPlans = async (page, dataFilter) => { setLoading(true); try { const data = await Chapar.get( - `${process.env.NEXT_PUBLIC_API_URL}/shift/plan?page=${page}`, + `${process.env.NEXT_PUBLIC_API_URL}/shift/plan?page=${page}&dateFilter=${dataFilter}`, { headers: { Authorization: "Bearer " + localStorage.getItem("token"), @@ -1312,7 +1312,7 @@ export default function RootLayout({ children }) { } ); - if (data.length < 14) { + if (data.length < 19) { setStopGetActivities(true); } @@ -1584,9 +1584,9 @@ export default function RootLayout({ children }) { `); const token = localStorage.getItem("token"); - if (!token) { - router.push("/login"); - } + // if (!token) { + // router.push("/login"); + // } if (profile.length <= 0 && token) CheckUser(); }, []); diff --git a/src/app/shifts/complete-shift/page.jsx b/src/app/shifts/complete-shift/page.jsx index ccd5150..a97ca46 100644 --- a/src/app/shifts/complete-shift/page.jsx +++ b/src/app/shifts/complete-shift/page.jsx @@ -21,6 +21,7 @@ const CompleteShift = () => { const [closeShiftScore, setCloseShiftScore] = useState(50); const [activeShifPlan, setActiveShifPlan] = useState(-1); const [selectDayForShift, setSelectDayForShift] = useState(-1); + const currentDate = new Date(); const siftsData = CTX.state.shiftsData; @@ -70,6 +71,8 @@ const CompleteShift = () => { }; const handleOpenShift = (isCompleted, id, index, hasCurrentShiftPlan) => { + CTX.setStopGetActivities(false); + CTX.setPageGetActivity(0); if (isCompleted) { toast.warning(`شیفت بسته شده است `, { position: "bottom-right", @@ -132,6 +135,7 @@ const CompleteShift = () => { CTX.CloseShift(body, siftsData[activeShifPlan]?.currentShiftPlanId); setActiveShifPlan(-1); handleDayCloseShift(1); + CTX.GetShifts(moment().locale("fa").startOf("day").unix() * 1000); }, [siftsData[activeShifPlan]?.currentShiftPlanId], body @@ -170,13 +174,34 @@ const CompleteShift = () => { const handleInfiniteNextFetchActivity = () => { CTX.setPageGetActivity((e) => e + 1); - CTX.GetActivity( - moment().locale("fa").startOf("day").unix() * 1000, - null, - pageGetActivity + 1 - ); + + if (selectDayForShift == 0) { + CTX.GetActivity( + moment().locale("fa").subtract(1, "day")?.unix() * 1000, + siftsData[activeShifPlan].id, + pageGetActivity + 1 + ); + } else if (selectDayForShift == 1) { + CTX.GetActivity( + moment().locale("fa").startOf("day").unix() * 1000, + siftsData[activeShifPlan].id, + pageGetActivity + 1 + ); + } else if (selectDayForShift == 2) { + CTX.GetActivity( + moment().locale("fa").add(1, "day").unix() * 1000, + siftsData[activeShifPlan].id, + pageGetActivity + 1 + ); + } }; + console.log(siftsData[activeShifPlan]); + console.log( + "getYesterdayPersianDate", + moment().locale("fa").subtract(1, "day")?.unix() * 1000 + ); + return (
{ {activeShifPlan == index && ( <> diff --git a/src/app/shifts/page.jsx b/src/app/shifts/page.jsx index be4cd38..e1da83f 100644 --- a/src/app/shifts/page.jsx +++ b/src/app/shifts/page.jsx @@ -18,9 +18,15 @@ const Shifts = (props) => { const [shiftplans, setShiftplans] = useState([]); const [shiftPlansSelect, setShiftPlansSelect] = useState(0); + const [shifilterShifPlaneSelect, setFilterShifPlaneSelect] = useState(0); const shiftplansData = CTX.state.shiftPlansData; + const handleFilterGetShifPlane = (num, index) => { + setFilterShifPlaneSelect(index); + CTX.GetShifPlans(0, num); + }; + const groupObjectsByPlanFor = (responseData) => { const groupedData = {}; @@ -87,7 +93,8 @@ const Shifts = (props) => { } useEffect(() => { - CTX.GetShifPlans(0); + CTX.GetShifPlans(0, 12); + setFilterShifPlaneSelect(1); }, []); useEffect(() => { @@ -128,7 +135,7 @@ const Shifts = (props) => { {HasPermission("ManageShiftPlans", permissions) && ( <> -
+

شیفت بندی هفته{" "}

@@ -136,6 +143,100 @@ const Shifts = (props) => { )} +
+
handleFilterGetShifPlane(12, 1)} + > +
+

+ شیفت های هفته{" "} +

+
+
+ +
handleFilterGetShifPlane(22, 6)} + > +
+

+ شیفت های ماه{" "} +

+
+
+ +
handleFilterGetShifPlane(11, 2)} + > +
+

+ شیفت های هفته بعد{" "} +

+
+
+ +
handleFilterGetShifPlane(10, 3)} + > +
+

+ شیفت های هفته قبل{" "} +

+
+
+ +
handleFilterGetShifPlane(20, 4)} + > +
+

+ شیفت های ماه قبل{" "} +

+
+
+ +
handleFilterGetShifPlane(21, 5)} + > +
+

+ شیفت های ماه بعد{" "} +

+
+
+
{shiftplans.length <= 0 ? (
diff --git a/src/app/tasks/page.jsx b/src/app/tasks/page.jsx index 740c7d7..2356f5b 100644 --- a/src/app/tasks/page.jsx +++ b/src/app/tasks/page.jsx @@ -112,11 +112,11 @@ const page = () => {
)} -
CTX.setBottomFilterActivitiesOpen(true)} - > -
+
+
CTX.setBottomFilterActivitiesOpen(true)} + >