"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;