diff --git a/.env b/.env index d7337d9..e7ec524 100644 --- a/.env +++ b/.env @@ -1,9 +1,9 @@ NODE_ENV="development" -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 +# 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 @@ -15,8 +15,8 @@ NEXT_PUBLIC_VERSION=0.3.0 -# NEXT_PUBLIC_SERVER_URL=https://api.brizco.io -# NEXT_PUBLIC_PUBLIC_URL=https://api.brizco.io -# NEXT_PUBLIC_API_URL=https://api.brizco.io/api +NEXT_PUBLIC_SERVER_URL=https://api.brizco.io +NEXT_PUBLIC_PUBLIC_URL=https://api.brizco.io +NEXT_PUBLIC_API_URL=https://api.brizco.io/api # NEXT_PUBLIC_API_URL_IMAGE=https://api.macsonline.ir/Files/ReportImages # NEXT_PUBLIC_API_URL_BackUp=https://api.macsonline.ir/Files/BackUps \ No newline at end of file diff --git a/plugins/BottomSheet/BottomSheetReportManageShift.jsx b/plugins/BottomSheet/BottomSheetReportManageShift.jsx new file mode 100644 index 0000000..d4c2fd8 --- /dev/null +++ b/plugins/BottomSheet/BottomSheetReportManageShift.jsx @@ -0,0 +1,164 @@ +"use client"; + +import React, { useContext, useEffect, useRef, useState } from "react"; +import { BottomSheet } from "react-spring-bottom-sheet"; +import Input from "plugins/Input/page"; +import AppContext from "@ctx/AppContext"; +import SimpleReactValidator from "simple-react-validator"; +import CheckBoxBriz from "plugins/CheckBoxBriz/page"; +import Buttonbriz from "plugins/Buttonbriz/page"; +import { toast } from "react-toastify"; +import PersianNumber from "plugins/PersianNumber"; +import moment from "jalali-moment"; + +const BottomSheetReportManageShift = (props) => { + const CTX = useContext(AppContext); + const shiftplansData = CTX.state.shiftPlansData; + const [shiftplans, setShiftplans] = useState([]); + + // const reportDetail = CTX.state.reportDetail; + + // const handleSendReport_SHIFTPLAN = () => { + // CTX.ReportShiftPlan(reportDetail?.shiftId); + // CTX.setBottomSheetReportManageShiftOpen(false); + // }; + + // const handleSendReport_TASK = () => { + // CTX.ReportTask(); + // CTX.setBottomSheetReportManageShiftOpen(false); + // }; + + const handleBottomSheetCreateRole = (e) => { + if (e.type == "OPEN") { + CTX.GetShifPlans(0, 12); + } + }; + + const groupObjectsByPlanFor = (responseData) => { + const groupedData = {}; + + // Iterate through the array + responseData.forEach((obj) => { + const { planFor } = obj; + + // If the planFor value is not in the groupedData object, create a new array + if (!groupedData[planFor]) { + groupedData[planFor] = [obj]; + } else { + // If the planFor value already exists, push the object into the existing array + groupedData[planFor].push(obj); + } + }); + + // Sort the objects within each group by the planFor date + Object.keys(groupedData).forEach((key) => { + groupedData[key].sort( + (a, b) => new Date(a.planFor) - new Date(b.planFor) + ); + }); + + // Convert the groupedData object into an array of objects + const groupedArray = Object.keys(groupedData).map((key) => ({ + planFor: key, + data: groupedData[key], + })); + + // Sort the groupedArray by the planFor date + groupedArray.sort((a, b) => new Date(a.planFor) - new Date(b.planFor)); + + console.log(groupedArray); + setShiftplans(groupedArray); + }; + + useEffect(() => { + groupObjectsByPlanFor(shiftplansData); + }, [shiftplansData]); + + console.log(shiftplans); + + return ( + handleBottomSheetCreateRole(e)} + open={CTX.state.BottomSheetReportManageShiftOpen} + onDismiss={() => CTX.setBottomSheetReportManageShiftOpen(false)} + blocking={false} + > +
+

گزارشات

+
+ +
+

+ {shiftplans?.map((e, index) => ( + <> +

+
+
+ +
+
+ + <> + {e.data.map((e) => ( +
+
+
+

+ {" "} + {e.shiftTitle} +

+
+
+ +
+ {e.users.map((i) => ( +
+

+ {i.positionName} :{" "} +

{" "} +

+ {i.userFullName} +

+
+ ))} +
+

+ سوپروایزر :{" "} +

{" "} +

+ {e.supervisorFullName} +

+
+
+
+ ))} + +
+ + ))} +

+
+ +
+ { + var text = document.getElementById("MYTEXT").innerText; + var elem = document.createElement("textarea"); + document.body.appendChild(elem); + elem.value = text; + elem.select(); + document.execCommand("copy"); + document.body.removeChild(elem); + }} + /> +
+
+ ); +}; + +export default BottomSheetReportManageShift; diff --git a/src/app/home/page.jsx b/src/app/home/page.jsx index 7880dd8..83bb803 100644 --- a/src/app/home/page.jsx +++ b/src/app/home/page.jsx @@ -348,6 +348,47 @@ const Home = (props) => { +
+
+
+ + + + + +
+
CTX.setBottomSheetReportManageShiftOpen(true)} + > +

+ {" "} + شیفت های هفته (new) +

+

+ خروجی متن +

+
+
+
+
diff --git a/src/app/layout.jsx b/src/app/layout.jsx index a570845..77446bf 100644 --- a/src/app/layout.jsx +++ b/src/app/layout.jsx @@ -20,6 +20,7 @@ import TimePicker from "plugins/TimePicker/page"; import axios from "axios"; import "rc-slider/assets/index.css"; import BottomSheetReport from "plugins/BottomSheet/BottomSheetReport"; +import BottomSheetReportManageShift from "plugins/BottomSheet/BottomSheetReportManageShift"; const inter = Inter({ subsets: ["latin"] }); @@ -59,6 +60,10 @@ export default function RootLayout({ children }) { useState(false); const [BottomSheetReportOpen, setBottomSheetReportOpen] = useState(false); + const [ + BottomSheetReportManageShiftOpen, + setBottomSheetReportManageShiftOpen, + ] = useState(false); // BigPlus const [BigPlusOpen, setBigPlusOpen] = useState(false); @@ -929,61 +934,62 @@ export default function RootLayout({ children }) { setLoading(false); } }; - const UpdateShiftPlan = async (body, id) => { - setLoading(true); - try { - const data = await Chapar.put( - `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`, - body, + // const UpdateShiftPlan = async (body, id) => { + // setLoading(true); + // try { + // const data = await Chapar.put( + // `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`, + // body, - { - headers: { - Authorization: "Bearer " + localStorage.getItem("token"), - }, - } - ); - toast.success(`شیفت ویرایش شد`, { - position: "bottom-right", - closeOnClick: true, - }); + // { + // headers: { + // Authorization: "Bearer " + localStorage.getItem("token"), + // }, + // } + // ); + // 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); - } - }; - 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: "Bearer " + localStorage.getItem("token"), - }, - } - ); - 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); + // } + // }; + // 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: "Bearer " + localStorage.getItem("token"), + // }, + // } + // ); + // 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); - } - }; + // router.push("/shifts"); + + // } catch ({ error, status }) { + // toast.error(`${error?.response?.data?.message}`, { + // position: "bottom-right", + // closeOnClick: true, + // }); + // setLoading(false); + // } + // }; const GetShifPlans = async (page, dataFilter) => { setLoading(true); try { @@ -1669,6 +1675,7 @@ export default function RootLayout({ children }) { BottomFilterActivitiesOpen, homePageData, typeTask, + BottomSheetReportManageShiftOpen, }, setBottomSheetCreateRoleOpen, setBottomSheetCreateEmployeesOpen, @@ -1768,7 +1775,7 @@ export default function RootLayout({ children }) { setRoutineShiftPlan, GetRoutineShiftPlan, setBottomSheetAddUserToPositionShiftPlanOpen, - CreateShifPlan, + // CreateShifPlan, setBottomSheetChangeRoleOpen, setActivitiesData, GetActivity, @@ -1779,7 +1786,7 @@ export default function RootLayout({ children }) { CloseShift, setShiftPlanData, GetShiftPlan, - UpdateShiftPlan, + // UpdateShiftPlan, setStopGetTasks, setPageGetTasks, setStopGetActivities, @@ -1794,6 +1801,7 @@ export default function RootLayout({ children }) { setHomePageData, GetHomePageData, setTypeTask, + setBottomSheetReportManageShiftOpen, }} > @@ -1803,78 +1811,9 @@ export default function RootLayout({ children }) { + {openTimePicker && } - {/* {BigPlusOpen ? ( -
- -
-
-
-
{ - closeBigPlusPage(); - }} - > - - - -
-
-
-
- -
closeBigPlusPage()} - > -

بستن شیفت

-
- - -
- -
closeBigPlusPage()} - > -

- افزودن خرید جدیـــــد -

-
- - - -
closeBigPlusPage()} - > -

افزودن وظیفه جدید

-
- -
-
-
-
-
- ) : ( - "" - )} */} diff --git a/src/app/shifts/manage-shift/page.jsx b/src/app/shifts/manage-shift/page.jsx index 1170a9f..74e0c4b 100644 --- a/src/app/shifts/manage-shift/page.jsx +++ b/src/app/shifts/manage-shift/page.jsx @@ -15,6 +15,7 @@ import BottomManageShift from "plugins/BottomSheet/BottomManageShift"; import BottomSheetAddUserToPositionShiftPlan from "plugins/BottomSheet/BottomSheetAddUserToPositionShiftPlan"; import Buttonbriz from "plugins/Buttonbriz/page"; import GoBack from "plugins/GoBack/page"; +import Chapar from "plugins/Chapar"; const Calendar = () => { const CTX = useContext(AppContext); @@ -144,11 +145,74 @@ const Calendar = () => { ); }; + const UpdateShiftPlan = async (body, id) => { + setLoading(true); + try { + const data = await Chapar.put( + `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`, + body, + + { + headers: { + Authorization: "Bearer " + localStorage.getItem("token"), + }, + } + ); + toast.success(`شیفت ویرایش شد`, { + position: "bottom-right", + closeOnClick: true, + }); + + CTX.setLoading(false); + CTX.setShiftPlanData(id); + router.push("/shifts"); + } catch ({ error, status }) { + toast.error(`${error?.response?.data?.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + CTX.setLoading(false); + } + }; + const CreateShifPlan = async (body) => { + CTX.setLoading(true); + try { + const data = await Chapar.post( + `${process.env.NEXT_PUBLIC_API_URL}/shift/plan`, + JSON.stringify(body), + { + headers: { + Authorization: "Bearer " + localStorage.getItem("token"), + }, + } + ); + toast.success(`مدیریت شیفت ساخته شد`, { + position: "bottom-right", + closeOnClick: true, + }); + + setSelectDay(null); + setShiftsPlan([]); + setSuperId(null); + setUserAndPositionIds([]); + setShiftPlanSteps(1); + CTX.setLoading(false); + + // router.push("/shifts"); + } catch ({ error, status }) { + toast.error(`${error?.response?.data?.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + CTX.setLoading(false); + } + }; + const handleCreateShiftPlan = (update) => { if (update == "UPDATE") { - CTX.UpdateShiftPlan(bodyUpdate); + UpdateShiftPlan(bodyUpdate); } else { - CTX.CreateShifPlan(body); + CreateShifPlan(body); } }; @@ -404,7 +468,6 @@ const Calendar = () => {

-

پرسنل را انتخاب کنید

@@ -471,7 +534,6 @@ const Calendar = () => {
))} -

@@ -503,29 +565,6 @@ const Calendar = () => {

-
-

غیر فعال کردن شیفت

-
-
- setRoleCheckBox(e.target.checked)} - /> -
-

- با خاموش کردن شیفت فعالیت ها برای افراد داخل شیفت خاموش میشود{" "} -

-
-
-
{editManageShift ? (