// import React, { useEffect, useState, useRef } from "react"; // import { Modal, Table } from "react-bootstrap"; // import ErrorLogService from "../../../../services/ErrorLogService"; // import Alert from "../../../../components/Common/Alert"; // import { requestRegularizationTime } from "../../../../services/TicketService/TaskService"; // import { getRegularizationTime, changeStatusRegularizationTime } from '../../../../services/TicketService/TaskService'; // import { Label } from "recharts"; // const RequestModal = (props) => { // const [notify, setNotify] = useState(null); // const [inputList, setInputList] = useState([ // { // // date: "", // from_time: "00:00", // to_time: "00:00", // from_date: null, // to_date: null // }, // ]); // const [date, setDate] = useState(""); // const [time, setTime] = useState(null); // const [fromTime, setFromTime] = useState(''); // const [toTime, setToTime] = useState(''); // const [timeDifference, setTimeDifference] = useState(''); // const currentDate = new Date(); // const year = currentDate.getFullYear(); // const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // const day = String(currentDate.getDate()).padStart(2, '0'); // const formattedDate = `${year}-${month}-${day}`; // const handleInputChange = (e, index) => { // const { name, value } = e.target; // const list = [...inputList]; // list[index] = { ...list[index], [name]: value }; // const fromDateList = list.map(item => item[`from_date[${index}]`]); // const toDateList = list.map(item => item[`to_date[${index}]`]); // // const payload = { // // from_date: fromDateList.filter(date => date !== undefined), // // to_date: toDateList.filter(date => date !== undefined), // // // Add other relevant values from the component state or props // // // Example: fromDate: date, // // // fromTime: time, // // // ... // // }; // if (name.includes("from_date")) { // setDate(value); // } // if (name.includes("from_time")) { // setTime(value); // } // setInputList(list); // }; // const statusValue = props.data.regularized_data.map((i)=>i.status) // const [timeData, setTimeData] = useState({}); // var ticket_id = props.data.ticket_id; // var ticket_basket_id = props.data.ticket_basket_id; // var task_owner_id = localStorage.getItem("id"); // var ticket_task_id = props.data.id; // const [firstCheckboxChecked, setFirstCheckboxChecked] = useState(false); // const [secondCheckboxChecked, setSecondCheckboxChecked] = useState(false); // const [showModal, setShowModal] = useState(false); // const handleFirstCheckboxChange = (e) => { // if (e) { // setFirstCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleSecondCheckboxChange({ target: { checked: false } }); // } // } // }; // const handleSecondCheckboxChange = (e) => { // if (e) { // setSecondCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleFirstCheckboxChange({ target: { checked: false } }); // } // } // }; // const [rows, setRows] = useState([{ increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // const addRow = () => { // setRows(prevRows => [...prevRows, { increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // }; // // Assuming you are using React and have a state variable called 'values' // const calculateTimeDifference = () => { // // Your existing code for calculating the time difference goes here // if (fromTime && toTime) { // const fromDateTime = new Date(`2000-01-01T${fromTime}`); // const toDateTime = new Date(`2000-01-01T${toTime}`); // const timeDiffMs = toDateTime - fromDateTime; // const timeDiffMinutes = Math.floor(timeDiffMs / (1000 * 60)); // let hours = Math.floor(timeDiffMinutes / 60); // let minutes = timeDiffMinutes % 60; // if (hours === 24 && minutes === 0) { // hours = 0; // minutes = 0; // } // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // setTimeDifference(formattedTime); // Assuming setTimeDifference is a state setter function // return formattedTime; // } // return ''; // }; // const handleActualTimeChange = (index, fromTime, toTime) => { // const calculateTimeDifference = (fromTime, toTime) => { // if (fromTime && toTime) { // const fromDateTime = new Date(`2000-01-01T${fromTime}`); // const toDateTime = new Date(`2000-01-01T${toTime}`); // const timeDiffMs = toDateTime - fromDateTime; // const timeDiffMinutes = Math.floor(timeDiffMs / (1000 * 60)); // let hours = Math.floor(timeDiffMinutes / 60); // let minutes = timeDiffMinutes % 60; // if (hours === 24 && minutes === 0) { // hours = 0; // minutes = 0; // } // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // return formattedTime; // } // return ''; // }; // setRows((prev) => { // return prev.map((data, rowIndex) => { // if (rowIndex === index) { // const newData = { ...data }; // Create a new copy of the row data // newData.from_time = fromTime; // Update the from_time value // newData.to_time = toTime; // Update the to_time value // newData.actual_time = calculateTimeDifference(fromTime, toTime); // Calculate and set the actual_time // return newData; // } else { // return data; // } // }); // }); // }; // const handleRowInputChange = (e, rowIndex) => { // const { name, value, type, checked } = e.target; // const updatedRows = rows.map((row, index) => { // if (index === rowIndex) { // if (type === "checkbox") { // return { ...row, [name]: checked }; // } else if (name === "actual_time[]") { // const formattedTime = calculateTimeDifference(value); // return { ...row, [name]: value, timeDifference: formattedTime }; // } else { // return { ...row, [name]: value }; // } // } else { // return row; // } // }); // setRows(updatedRows); // setDate(e.target.value) // }; // // const handleIncreaseChange = (index) => { // // const updatedRows = [...rows]; // // updatedRows[index].increaseChecked = true; // // updatedRows[index].decreaseChecked = false; // // setRows(updatedRows); // // }; // // This function is called when the checkbox for regularization time increase is clicked. // const handleIncreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'increaseChecked' property of the row at the specified index to true. // updatedRows[index].increaseChecked = true; // // Set the 'decreaseChecked' property of the same row to false. // updatedRows[index].decreaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleActualChange = (index) => { // const updatedRows = [...rows]; // updatedRows[index].actual_time = timeDifference; // setRows(updatedRows); // }; // // const handleDecreaseChange = (index) => { // // const updatedRows = [...rows]; // // updatedRows[index].decreaseChecked = true; // // updatedRows[index].increaseChecked = false; // // setRows(updatedRows); // // }; // // This function is called when the checkbox for regularization time decrease is clicked. // const handleDecreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'decreaseChecked' property of the row at the specified index to true. // updatedRows[index].decreaseChecked = true; // // Set the 'increaseChecked' property of the same row to false. // updatedRows[index].increaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleSubmit = (e) => { // e.preventDefault(); // setNotify(null); // const data = new FormData(e.target); // data.append('scheduled_time', props.data.task_hours); // // data.append('actual_total_time',"00:30"); // new requestRegularizationTime(data).then((res) => { // if (res.status === 200) { // if (res.data.status === 1) { // setNotify({ type: "success", message: res.data.message }); // // window.location.reload(false) // props.hide(); // document.getElementById("requestForm").reset(); // } else { // setNotify({ type: "danger", message: res.data.message }); // } // } // }); // }; // // handle click event of the Remove button // const handleRemoveClick = (index) => { // const list = [...rows]; // list.splice(index, 1); // setRows(list); // }; // // handle click event of the Add button // const[remark, setRemark] = useState() // const handleAddClick = (e) => { // setRemark(e.target.value) // // setInputList([...inputList, { name: null, id: null }]); // }; // const [approveData, setApproveData] = useState() // const getApproveData = () => { // new getRegularizationTime(props.data.ticket_id).then(res => { // if (res.data.data) { // var temp = []; // setApproveData(null); // res.data.data.forEach(d => { // temp.push({ // 'id': d.id, // 'created_by_name': d.created_by_name, // 'from_date': d.from_date, // 'to_date': d.to_date, // 'from_time': d.from_time, // 'to_time': d.to_time, // 'status': d.status, // 'remark': d.remark, // 'is_checked': 0, // 'regularization_time_status': d.regularization_time_status, // 'task_name': d.task_name, // 'ticket_id_name': d.ticket_id_name, // 'ticket_task_id': d.ticket_task_id // }); // }) // setApproveData(temp); // } // }) // } // useEffect(() => { // calculateTimeDifference(); // }, [fromTime, toTime, rows]); // useEffect(() => { // // Code to update the actual_time value automatically // const updatedRows = rows.map(row => ({ // ...row, // actual_time: timeDifference // })); // setRows(updatedRows); // }, [timeDifference]); // useEffect(() => { // setNotify(null); // getApproveData() // }, []); // console.log("row",rows) // // const [approvedStatus, setApprovedStatus] = useState() // // useEffect(() => { // // props.isRegularised.map((d,i)=>{ // // setApprovedStatus(d.status) // // }) // // console.log(approvedStatus); // // }, [approvedStatus]); // console.log("statusValue", props.data.regularized_data.length) // console.log("statusValue==>", statusValue) // return ( //
// {notify && } // // { window.location.reload(false)}} // > // // Request Regularization // // // // //
// {/*
//
Task Name
//
*/} //
//
{`Ticket ID: ${props.data.ticket_id_name}`}
//
//
//
{`Task Name: // ${props.data.task_name}`}
//
//
//
{`Scheduled Time: ${props.data.task_hours}`}
//
//
//
//
//
// // // // {/* {console.log("hi",props.data.regularized_data.map((i)=>i.status))} */} // //
// // // // // // // // // // // // // // // // // {/* Updated by */} // {/* {rows.map((row, index) => ( // // // // // // // // {props.data.regularization_time_status ? // // : // // } // {props.data.regularization_time_status ? // // : // // } // // // // ))} */} // {props && props.isRegularisedData.length == 0 || props && props.isRegularisedData.length == 1 && props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status) == "REJECTED" || props && props.isRegularisedData.length == 2 && props.isRegularisedData.filter((d)=>d.status === "APPROVED").map((i)=>i.status) != "APPROVED"? // <> // {rows.map((row, index) => { // return // // // // // // // // // // })} // : <> // {rows.map((row, index) => { // // console.log("props.isss", props.isRegularisedData.length) // // console.log("props.isssSTATUS", props.isRegularisedData.filter((d)=>d.status === "PENDING").map((i)=>i.status)) // // console.log("r", props.isRegularisedData.filter((d)=>d.status != "REJECTED").map((i)=>i.status )) // return // // // // // // // // // // })} // } // //
Sr No From Date To Date From Time To Time Actual Time Increase Time Decrease Time Remark Action
{index + 1} // handleRowInputChange(e, index)} // required // disabled={props.data.regularized_data.length == 0 || statusValue === "REJECTED" ? false :true } // /> // // handleRowInputChange(e, index)} // required // disabled={props.data.regularized_data.length > 0 || statusValue === "REJECT" ? false :true } // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // handleActualTimeChange(index, e.target.value, row.to_time)} // required // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // handleActualTimeChange(index, row.from_time, e.target.value)} // required // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // // handleIncreaseChange(index)} // value="YES" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // handleIncreaseChange(index)} // name="regularization_time_status" // id="regularization_time_status" // value="YES" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // handleDecreaseChange(index)} // name="regularization_time_status" // id="regularization_time_status" // value="NO" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // // disabled={props.data.is_regularized === "NO" ? true : false} // /> // // // handleDecreaseChange(index)} // name="regularization_time_status" // id="regularization_time_status" // value="NO" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // handleAddClick(e)} // defaultValue={props.data.remark} // required // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
{index + 1} // handleRowInputChange(e, index)} // required // /> // // handleRowInputChange(e, index)} // required // disabled={props.data.is_regularized === "YES" ? true : false} // /> // // handleActualTimeChange(index, e.target.value, row.to_time)} // required // disabled={props.data.is_regularized === "YES" ? true : false} // /> // // // handleActualTimeChange(index, row.from_time, e.target.value)} // required // disabled={props.data.is_regularized === "YES" ? true : false} // /> // // // // handleAddClick(e)} // defaultValue={props.data.remark} // required // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
{index + 1} // i.from_date)} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // disabled={true} // // disabled={props.isRegularisedData.length == 0 || props.isRegularisedData.length == 1 && props.isRegularisedData.filter((d)=>d.status === "PENDING").map((i)=>i.status === []) || props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status === []) || props.isRegularisedData.filter((d)=>d.status === ["PENDING"]).map((i)=>i.status === ["PENDING"]) || props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status === []) || props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status === "REJECTED") ? false : true} // // disabled= // // Change this to true if you want to disable when status is not "REJECTED" // /> // // i.to_date)} // min={date} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // i.from_time)} // onChange={(e) => handleActualTimeChange(index, e.target.value, row.to_time)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // disabled={true} // /> // // // i.to_time)} // onChange={(e) => handleActualTimeChange(index, row.from_time, e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // disabled={true} // /> // // // // handleAddClick(e)} // defaultValue={ props.isRegularisedData.map((i)=>i.remark)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // disabled={true} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
//
//
// // // //
//
//
// ); // }; // export default RequestModal; // import React, { useEffect, useState, useRef } from "react"; // import { Modal, Table } from "react-bootstrap"; // import ErrorLogService from "../../../../services/ErrorLogService"; // import Alert from "../../../../components/Common/Alert"; // import { requestRegularizationTime } from "../../../../services/TicketService/TaskService"; // import { getRegularizationTime,getRegularizationTimeData, changeStatusRegularizationTime } from '../../../../services/TicketService/TaskService'; // import { Label } from "recharts"; // const RequestModal = (props) => { // const [notify, setNotify] = useState(null); // const [inputList, setInputList] = useState([ // { // // date: "", // from_time: "00:00", // to_time: "00:00", // from_date: null, // to_date: null // }, // ]); // const [date, setDate] = useState(""); // const [time, setTime] = useState(null); // const [fromTime, setFromTime] = useState(''); // const [toTime, setToTime] = useState(''); // const [timeDifference, setTimeDifference] = useState(''); // const currentDate = new Date(); // const year = currentDate.getFullYear(); // const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // const day = String(currentDate.getDate()).padStart(2, '0'); // const formattedDate = `${year}-${month}-${day}`; // const handleFromDate = (e) => { // setDate(e.target.value); // }; // const [timeData, setTimeData] = useState({}); // var ticket_id = props.data.ticket_id; // var ticket_basket_id = props.data.ticket_basket_id; // var task_owner_id = localStorage.getItem("id"); // var ticket_task_id = props.data.id; // const [firstCheckboxChecked, setFirstCheckboxChecked] = useState(false); // const [secondCheckboxChecked, setSecondCheckboxChecked] = useState(false); // const [showModal, setShowModal] = useState(false); // const handleFirstCheckboxChange = (e) => { // if (e) { // setFirstCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleSecondCheckboxChange({ target: { checked: false } }); // } // } // }; // const handleSecondCheckboxChange = (e) => { // if (e) { // setSecondCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleFirstCheckboxChange({ target: { checked: false } }); // } // } // }; // // This function is called when the checkbox for regularization time increase is clicked. // const handleIncreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'increaseChecked' property of the row at the specified index to true. // updatedRows[index].increaseChecked = true; // // Set the 'decreaseChecked' property of the same row to false. // updatedRows[index].decreaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleActualChange = (index) => { // const updatedRows = [...rows]; // updatedRows[index].actual_time = timeDifference; // setRows(updatedRows); // }; // // This function is called when the checkbox for regularization time decrease is clicked. // const handleDecreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'decreaseChecked' property of the row at the specified index to true. // updatedRows[index].decreaseChecked = true; // // Set the 'increaseChecked' property of the same row to false. // updatedRows[index].increaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleSubmit = (e) => { // e.preventDefault(); // setNotify(null); // const data = new FormData(e.target); // data.append('scheduled_time', props.data.task_hours); // // data.append('actual_total_time',"00:30"); // new requestRegularizationTime(data).then((res) => { // if (res.status === 200) { // if (res.data.status === 1) { // setNotify({ type: "success", message: res.data.message }); // loadData() // // window.location.reload(false) // props.hide(); // document.getElementById("requestForm").reset(); // } else { // setNotify({ type: "danger", message: res.data.message }); // } // } // }); // }; // // handle click event of the Remove button // const handleRemoveClick = (index) => { // const list = [...rows]; // list.splice(index, 1); // setRows(list); // }; // // handle click event of the Add button // const [remark, setRemark] = useState() // const handleAddClick = (e) => { // setRemark(e.target.value) // // setInputList([...inputList, { name: null, id: null }]); // }; // const [approveData, setApproveData] = useState() // const getApproveData = () => { // new getRegularizationTime(props.data.ticket_id).then(res => { // if (res.data.data) { // var temp = []; // setApproveData(null); // res.data.data.forEach(d => { // temp.push({ // 'id': d.id, // 'created_by_name': d.created_by_name, // 'from_date': d.from_date, // 'to_date': d.to_date, // 'from_time': d.from_time, // 'to_time': d.to_time, // 'status': d.status, // 'remark': d.remark, // 'is_checked': 0, // 'regularization_time_status': d.regularization_time_status, // 'task_name': d.task_name, // 'ticket_id_name': d.ticket_id_name, // 'ticket_task_id': d.ticket_task_id // }); // }) // setApproveData(temp); // } // }) // } // const [regularizeTimeData,setRegularizeTimeData]=useState([]) // const loadData = () => { // new getRegularizationTimeData(props.data.ticket_id,props.data.id).then(res => { // if (res.data.data) { // // setData(null); // setRegularizeTimeData(res.data.data) // } // }) // } // // useEffect(() => { // // calculateTimeDifference(); // // }, [fromTime, toTime, rows]); // // console.log("hii",props.data) // useEffect(() => { // // Code to update the actual_time value automatically // const updatedRows = rows.map(row => ({ // ...row, // actual_time: timeDifference // })); // setRows(updatedRows); // }, [timeDifference]); // useEffect(() => { // setNotify(null); // getApproveData() // }, []); // useEffect(() => { // loadData() // }, []); // const [rows, setRows] = useState([ // { from_date: '', to_date: '', from_time: '', to_time: '', actual_time: '' }, // // Add more rows as needed // ]); // const calculateTimeDifference = (fromDate, toDate, fromTime, toTime) => { // if (fromDate && toDate && fromTime && toTime) { // const fromDateObj = new Date(fromDate); // const toDateObj = new Date(toDate); // // Extract hours and minutes from the time strings // const fromHours = Number(fromTime.split(':')[0]); // const fromMinutes = Number(fromTime.split(':')[1]); // const toHours = Number(toTime.split(':')[0]); // const toMinutes = Number(toTime.split(':')[1]); // fromDateObj.setHours(fromHours, fromMinutes); // toDateObj.setHours(toHours, toMinutes); // // Calculate the time difference in milliseconds // const timeDiffMs = toDateObj - fromDateObj; // // Ensure the time difference is positive // const positiveTimeDiffMs = Math.abs(timeDiffMs); // const timeDiffMinutes = Math.floor(positiveTimeDiffMs / (1000 * 60)); // const hours = Math.floor(timeDiffMinutes / 60); // const minutes = (timeDiffMinutes % 60).toString().padStart(2, '0'); // return `${hours}:${minutes}`; // } // return ''; // }; // const addRow = () => { // setRows(prevRows => [...prevRows, { increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // }; // const handleActualTimeChange = (index, fromTime, toTime) => { // const fromDate = rows[index].from_date; // const toDate = rows[index].to_date; // const actualTime = calculateTimeDifference(fromDate, toDate, fromTime, toTime); // setRows((prev) => { // return prev.map((data, rowIndex) => { // if (rowIndex === index) { // const newData = { ...data }; // newData.from_time = fromTime; // newData.to_time = toTime; // newData.actual_time = actualTime; // return newData; // } else { // return data; // } // }); // }); // }; // const handleDateChange = (index, dateType, value) => { // setRows((prev) => { // const updatedRows = prev.map((data, rowIndex) => { // if (rowIndex === index) { // return { ...data, [dateType]: value }; // } else { // return data; // } // }); // const updatedFromTime = updatedRows[index].from_time; // const updatedToTime = updatedRows[index].to_time; // const actualTime = calculateTimeDifference( // updatedRows[index].from_date, // updatedRows[index].to_date, // updatedFromTime, // updatedToTime // ); // updatedRows[index].actual_time = actualTime; // return updatedRows; // }); // }; // const handleInputChange = (e, index) => { // const { name, value } = e.target; // setRows((prev) => // prev.map((data, rowIndex) => // rowIndex === index ? { ...data, [name]: value } : data // ) // ); // }; // return ( //
// {notify && } // // { window.location.reload(false) }} // > // // Time Regularization // // // // //
//
//
{`Ticket ID: ${props.data.ticket_id_name}`}
//
//
//
{`Task Name: // ${props.data.task_name}`}
//
//
//
{`Scheduled Time: ${props.data.task_hours}`}
//
//
//
//
//
// // // // //
// // // // // // // // // // // // // // // {console.log("re",regularizeTimeData)} // {regularizeTimeData && regularizeTimeData.length > 0 ? // <> // { regularizeTimeData && regularizeTimeData.map((x, index) => { // return // // {rows && rows.map((row,i)=>{ // return<> // // // // // {regularizeTimeData && regularizeTimeData.length > 0 || x.status === "REJECTED" ? : // } // })} // // // // // })} // })} // // : // <> // {rows.map((row, index) => { // return // // // // // // // // // // })}} // {/* } */} // //
Sr No From Date To Date From Time To Time Actual Time Remark Action
{index + 1} // handleDateChange(index, 'from_date', e.target.value)} // /> // // handleDateChange(index, 'to_date', e.target.value)} // min={date} // max={formattedDate} // required // /> // // handleActualTimeChange(index, e.target.value, row.to_time)} // required // /> // // // handleActualTimeChange(index, row.from_time, e.target.value)} // required // /> // // // // // // handleAddClick(e)} // defaultValue={ x.remark} // required // disabled={x.status === "REJECTED" ? false :true} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
{index + 1} // i.to_date)} // // min={date} // max={formattedDate} // // onChange={(e) => handleRowInputChange(e, index)} // value={row.from_date} // onChange={(e) => handleDateChange(index, 'from_date', e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // i.to_date)} // min={date} // max={formattedDate} // // onChange={(e) => handleRowInputChange(e, index)} // value={row.to_date} // onChange={(e) => handleDateChange(index, 'to_date', e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // i.from_time)} // // onChange={(e) => handleActualTimeChange(index, e.target.value, row.to_time)} // value={row.from_time} // onChange={(e) => handleActualTimeChange(index, e.target.value, row.to_time)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={true} // /> // // // i.to_time)} // // onChange={(e) => handleActualTimeChange(index, row.from_time, e.target.value)} // value={row.to_time} // onChange={(e) => handleActualTimeChange(index, row.from_time, e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={true} // /> // // // // handleAddClick(e)} // // defaultValue={ props.isRegularisedData.map((i)=>i.remark)} // required // // disabled={true} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
//
//
// // // //
//
//
// ); // }; // export default RequestModal; // import React, { useEffect, useState, useRef } from "react"; // import { Modal, Table } from "react-bootstrap"; // import ErrorLogService from "../../../../services/ErrorLogService"; // import Alert from "../../../../components/Common/Alert"; // import { requestRegularizationTime } from "../../../../services/TicketService/TaskService"; // import { getRegularizationTime,getRegularizationTimeData, changeStatusRegularizationTime } from '../../../../services/TicketService/TaskService'; // import { Label } from "recharts"; // const RequestModal = (props) => { // const [notify, setNotify] = useState(null); // const [inputList, setInputList] = useState([ // { // // date: "", // from_time: "00:00", // to_time: "00:00", // from_date: null, // to_date: null // }, // ]); // const [date, setDate] = useState(""); // const [time, setTime] = useState(null); // const [fromTime, setFromTime] = useState(''); // const [toTime, setToTime] = useState(''); // const [timeDifference, setTimeDifference] = useState(''); // const currentDate = new Date(); // const year = currentDate.getFullYear(); // const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // const day = String(currentDate.getDate()).padStart(2, '0'); // const formattedDate = `${year}-${month}-${day}`; // const handleInputChange = (e, index) => { // const { name, value } = e.target; // const list = [...inputList]; // list[index] = { ...list[index], [name]: value }; // const fromDateList = list.map(item => item[`from_date[${index}]`]); // const toDateList = list.map(item => item[`to_date[${index}]`]); // // const payload = { // // from_date: fromDateList.filter(date => date !== undefined), // // to_date: toDateList.filter(date => date !== undefined), // // // Add other relevant values from the component state or props // // // Example: fromDate: date, // // // fromTime: time, // // // ... // // }; // if (name.includes("from_date")) { // setDate(value); // } // if (name.includes("from_time")) { // setTime(value); // } // setInputList(list); // }; // const handleFromDate = (e) => { // setDate(e.target.value); // // const gettodatevalue = e.target.value; // // const setdateformat = gettodatevalue.split('-'); // // const settoyear = setdateformat[0]; // // const settomonth = setdateformat[1]; // // const settodate = setdateformat[2]; // // const settodateformat = settoyear + "" + settomonth + "" + settodate; // // setTodate(gettodatevalue); // // setTodateformat(settodateformat); // }; // const [timeData, setTimeData] = useState({}); // var ticket_id = props.data.ticket_id; // var ticket_basket_id = props.data.ticket_basket_id; // var task_owner_id = localStorage.getItem("id"); // var ticket_task_id = props.data.id; // const [firstCheckboxChecked, setFirstCheckboxChecked] = useState(false); // const [secondCheckboxChecked, setSecondCheckboxChecked] = useState(false); // const [showModal, setShowModal] = useState(false); // const handleFirstCheckboxChange = (e) => { // if (e) { // setFirstCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleSecondCheckboxChange({ target: { checked: false } }); // } // } // }; // const handleSecondCheckboxChange = (e) => { // if (e) { // setSecondCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleFirstCheckboxChange({ target: { checked: false } }); // } // } // }; // const [rows, setRows] = useState([{ increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // const addRow = () => { // setRows(prevRows => [...prevRows, { increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // }; // // Assuming you are using React and have a state variable called 'values' // const calculateTimeDifference = () => { // // Your existing code for calculating the time difference goes here // if (fromTime && toTime) { // const fromDateTime = new Date(`2000-01-01T${fromTime}`); // const toDateTime = new Date(`2000-01-01T${toTime}`); // const timeDiffMs = toDateTime - fromDateTime; // const timeDiffMinutes = Math.floor(timeDiffMs / (1000 * 60)); // let hours = Math.floor(timeDiffMinutes / 60); // let minutes = timeDiffMinutes % 60; // if (hours === 24 && minutes === 0) { // hours = 0; // minutes = 0; // } // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // setTimeDifference(formattedTime); // Assuming setTimeDifference is a state setter function // return formattedTime; // } // return ''; // }; // const handleActualTimeChange = (index, fromTime, toTime) => { // // const calculateTimeDifference = (fromTime, toTime) => { // // if (fromTime && toTime) { // // const fromDateTime = new Date(`2000-01-01T${fromTime}`); // // const toDateTime = new Date(`2000-01-01T${toTime}`); // // const timeDiffMs = toDateTime - fromDateTime; // // const timeDiffMinutes = Math.floor(timeDiffMs / (1000 * 60)); // // let hours = Math.floor(timeDiffMinutes / 60); // // let minutes = timeDiffMinutes % 60; // // if (hours === 24 && minutes === 0) { // // hours = 0; // // minutes = 0; // // } // // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // // console.log("t",formattedTime) // // return formattedTime; // // } // // return ''; // // }; // const calculateTimeDifference = (fromTime, toTime) => { // if (fromTime && toTime) { // const [fromHours, fromMinutes] = fromTime.split(':').map(Number); // const [toHours, toMinutes] = toTime.split(':').map(Number); // let hours = toHours - fromHours; // let minutes = toMinutes - fromMinutes; // if (minutes < 0) { // minutes += 60; // hours--; // } // if (hours < 0) { // hours += 24; // Handle cases where 'toTime' is on the next day // } // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // return formattedTime; // } // return ''; // }; // setRows((prev) => { // return prev.map((data, rowIndex) => { // if (rowIndex === index) { // const newData = { ...data }; // Create a new copy of the row data // newData.from_time = fromTime; // Update the from_time value // newData.to_time = toTime; // Update the to_time value // newData.actual_time = calculateTimeDifference(fromTime, toTime); // Calculate and set the actual_time // return newData; // } else { // return data; // } // }); // }); // }; // // const handleRowInputChange = (e, rowIndex) => { // // const { name, value, type, checked } = e.target; // // const updatedRows = rows.map((row, index) => { // // if (index === rowIndex) { // // if (type === "checkbox") { // // return { ...row, [name]: checked }; // // } else if (name === "actual_time[]") { // // const formattedTime = calculateTimeDifference(value); // // return { ...row, [name]: value, timeDifference: formattedTime }; // // } else { // // return { ...row, [name]: value }; // // } // // } else { // // return row; // // } // // }); // // setRows(updatedRows); // // setDate(e.target.value) // // }; // const handleRowInputChange = (e, rowIndex) => { // const { name, value, type, checked } = e.target; // setDate(e.target.value) // const updatedRows = rows.map((row, index) => { // if (index === rowIndex) { // if (type === "checkbox") { // return { ...row, [name]: checked }; // } else if (name === "actual_time[]") { // const formattedTime = calculateTimeDifference(value); // return { ...row, [name]: value, actual_time: formattedTime }; // Update actual_time // } else { // return { ...row, [name]: value }; // } // } else { // return row; // } // }); // setRows(updatedRows); // }; // // const handleIncreaseChange = (index) => { // // const updatedRows = [...rows]; // // updatedRows[index].increaseChecked = true; // // updatedRows[index].decreaseChecked = false; // // setRows(updatedRows); // // }; // // This function is called when the checkbox for regularization time increase is clicked. // const handleIncreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'increaseChecked' property of the row at the specified index to true. // updatedRows[index].increaseChecked = true; // // Set the 'decreaseChecked' property of the same row to false. // updatedRows[index].decreaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleActualChange = (index) => { // const updatedRows = [...rows]; // updatedRows[index].actual_time = timeDifference; // setRows(updatedRows); // }; // // const handleDecreaseChange = (index) => { // // const updatedRows = [...rows]; // // updatedRows[index].decreaseChecked = true; // // updatedRows[index].increaseChecked = false; // // setRows(updatedRows); // // }; // // This function is called when the checkbox for regularization time decrease is clicked. // const handleDecreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'decreaseChecked' property of the row at the specified index to true. // updatedRows[index].decreaseChecked = true; // // Set the 'increaseChecked' property of the same row to false. // updatedRows[index].increaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleSubmit = (e) => { // e.preventDefault(); // setNotify(null); // const data = new FormData(e.target); // data.append('scheduled_time', props.data.task_hours); // // data.append('actual_total_time',"00:30"); // new requestRegularizationTime(data).then((res) => { // if (res.status === 200) { // if (res.data.status === 1) { // setNotify({ type: "success", message: res.data.message }); // loadData() // // window.location.reload(false) // props.hide(); // document.getElementById("requestForm").reset(); // } else { // setNotify({ type: "danger", message: res.data.message }); // } // } // }); // }; // {console.log("date",date)} // // handle click event of the Remove button // const handleRemoveClick = (index) => { // const list = [...rows]; // list.splice(index, 1); // setRows(list); // }; // // handle click event of the Add button // const [remark, setRemark] = useState() // const handleAddClick = (e) => { // setRemark(e.target.value) // // setInputList([...inputList, { name: null, id: null }]); // }; // const [approveData, setApproveData] = useState() // const getApproveData = () => { // new getRegularizationTime(props.data.ticket_id).then(res => { // if (res.data.data) { // var temp = []; // setApproveData(null); // res.data.data.forEach(d => { // temp.push({ // 'id': d.id, // 'created_by_name': d.created_by_name, // 'from_date': d.from_date, // 'to_date': d.to_date, // 'from_time': d.from_time, // 'to_time': d.to_time, // 'status': d.status, // 'remark': d.remark, // 'is_checked': 0, // 'regularization_time_status': d.regularization_time_status, // 'task_name': d.task_name, // 'ticket_id_name': d.ticket_id_name, // 'ticket_task_id': d.ticket_task_id // }); // }) // setApproveData(temp); // } // }) // } // const [regularizeTimeData,setRegularizeTimeData]=useState([]) // const loadData = () => { // new getRegularizationTimeData(props.data.ticket_id,props.data.id).then(res => { // if (res.data.data) { // // setData(null); // setRegularizeTimeData(res.data.data) // } // }) // } // useEffect(() => { // calculateTimeDifference(); // }, [fromTime, toTime, rows]); // // console.log("hii",props.data) // useEffect(() => { // // Code to update the actual_time value automatically // const updatedRows = rows.map(row => ({ // ...row, // actual_time: timeDifference // })); // setRows(updatedRows); // }, [timeDifference]); // useEffect(() => { // setNotify(null); // getApproveData() // }, []); // useEffect(() => { // loadData() // }, []); // // console.log("props",props.data) // // console.log("isR",props.isRegularisedData.length) // // const [approvedStatus, setApprovedStatus] = useState() // // useEffect(() => { // // props.isRegularised.map((d,i)=>{ // // setApprovedStatus(d.status) // // }) // // console.log(approvedStatus); // // }, [approvedStatus]); // // console.log("props",props) // return ( //
// {notify && } // // { window.location.reload(false) }} // > // // Time Regularization // // // // //
// {/*
//
Task Name
//
*/} //
//
{`Ticket ID: ${props.data.ticket_id_name}`}
//
//
//
{`Task Name: // ${props.data.task_name}`}
//
//
//
{`Scheduled Time: ${props.data.task_hours}`}
//
//
//
//
//
// // // // //
// // // // // // // // // // // // // // // {regularizeTimeData && regularizeTimeData.length > 0 ? // <> // { regularizeTimeData && regularizeTimeData.map((x, index) => { // return // // {rows && rows.map((row,i)=>{ // return<> // // // // // {regularizeTimeData && regularizeTimeData.length > 0 || x.status === "REJECTED" ? : // } // })} // // // // // })} // })} // : // <> // {rows.map((row, index) => { // return // // // // // // // // // // })}} // {/* } */} // //
Sr No From Date To Date From Time To Time Actual Time Remark Action
{index + 1} // i.from_date)} // defaultValue={x.from_date} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // disabled={x.status === "REJECTED" ? false :true} // /> // // handleRowInputChange(e, index)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // handleActualTimeChange(index, e.target.value, x.to_time)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={true} // /> // // // handleActualTimeChange(index, x.from_time, e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={true} // /> // // // // // // handleAddClick(e)} // defaultValue={ x.remark} // required // disabled={x.status === "REJECTED" ? false :true} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
{index + 1} // i.to_date)} // // min={date} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // i.to_date)} // min={date} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // i.from_time)} // onChange={(e) => handleActualTimeChange(index, e.target.value, row.to_time)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={true} // /> // // // i.to_time)} // onChange={(e) => handleActualTimeChange(index, row.from_time, e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={true} // /> // // // // handleAddClick(e)} // // defaultValue={ props.isRegularisedData.map((i)=>i.remark)} // required // // disabled={true} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
//
//
// // // //
//
//
// ); // }; // export default RequestModal; // import React, { useEffect, useState, useRef } from "react"; // import { Modal, Table } from "react-bootstrap"; // import ErrorLogService from "../../../../services/ErrorLogService"; // import Alert from "../../../../components/Common/Alert"; // import { requestRegularizationTime } from "../../../../services/TicketService/TaskService"; // import { getRegularizationTime, changeStatusRegularizationTime } from '../../../../services/TicketService/TaskService'; // import { Label } from "recharts"; // const RequestModal = (props) => { // const [notify, setNotify] = useState(null); // const [inputList, setInputList] = useState([ // { // // date: "", // from_time: "00:00", // to_time: "00:00", // from_date: null, // to_date: null // }, // ]); // const [date, setDate] = useState(""); // const [time, setTime] = useState(null); // const [fromTime, setFromTime] = useState(''); // const [toTime, setToTime] = useState(''); // const [timeDifference, setTimeDifference] = useState(''); // const currentDate = new Date(); // const year = currentDate.getFullYear(); // const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // const day = String(currentDate.getDate()).padStart(2, '0'); // const formattedDate = `${year}-${month}-${day}`; // const handleInputChange = (e, index) => { // const { name, value } = e.target; // const list = [...inputList]; // list[index] = { ...list[index], [name]: value }; // const fromDateList = list.map(item => item[`from_date[${index}]`]); // const toDateList = list.map(item => item[`to_date[${index}]`]); // // const payload = { // // from_date: fromDateList.filter(date => date !== undefined), // // to_date: toDateList.filter(date => date !== undefined), // // // Add other relevant values from the component state or props // // // Example: fromDate: date, // // // fromTime: time, // // // ... // // }; // if (name.includes("from_date")) { // setDate(value); // } // if (name.includes("from_time")) { // setTime(value); // } // setInputList(list); // }; // const statusValue = props.data.regularized_data.map((i)=>i.status) // const [timeData, setTimeData] = useState({}); // var ticket_id = props.data.ticket_id; // var ticket_basket_id = props.data.ticket_basket_id; // var task_owner_id = localStorage.getItem("id"); // var ticket_task_id = props.data.id; // const [firstCheckboxChecked, setFirstCheckboxChecked] = useState(false); // const [secondCheckboxChecked, setSecondCheckboxChecked] = useState(false); // const [showModal, setShowModal] = useState(false); // const handleFirstCheckboxChange = (e) => { // if (e) { // setFirstCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleSecondCheckboxChange({ target: { checked: false } }); // } // } // }; // const handleSecondCheckboxChange = (e) => { // if (e) { // setSecondCheckboxChecked(e.target.checked); // if (e.target.checked) { // handleFirstCheckboxChange({ target: { checked: false } }); // } // } // }; // const [rows, setRows] = useState([{ increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // const addRow = () => { // setRows(prevRows => [...prevRows, { increaseChecked: false, decreaseChecked: false, value: 0, actual_time: null }]); // }; // // Assuming you are using React and have a state variable called 'values' // const calculateTimeDifference = () => { // // Your existing code for calculating the time difference goes here // if (fromTime && toTime) { // const fromDateTime = new Date(`2000-01-01T${fromTime}`); // const toDateTime = new Date(`2000-01-01T${toTime}`); // const timeDiffMs = toDateTime - fromDateTime; // const timeDiffMinutes = Math.floor(timeDiffMs / (1000 * 60)); // let hours = Math.floor(timeDiffMinutes / 60); // let minutes = timeDiffMinutes % 60; // if (hours === 24 && minutes === 0) { // hours = 0; // minutes = 0; // } // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // setTimeDifference(formattedTime); // Assuming setTimeDifference is a state setter function // return formattedTime; // } // return ''; // }; // const handleActualTimeChange = (index, fromTime, toTime) => { // const calculateTimeDifference = (fromTime, toTime) => { // if (fromTime && toTime) { // const fromDateTime = new Date(`2000-01-01T${fromTime}`); // const toDateTime = new Date(`2000-01-01T${toTime}`); // const timeDiffMs = toDateTime - fromDateTime; // const timeDiffMinutes = Math.floor(timeDiffMs / (1000 * 60)); // let hours = Math.floor(timeDiffMinutes / 60); // let minutes = timeDiffMinutes % 60; // if (hours === 24 && minutes === 0) { // hours = 0; // minutes = 0; // } // const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // return formattedTime; // } // return ''; // }; // setRows((prev) => { // return prev.map((data, rowIndex) => { // if (rowIndex === index) { // const newData = { ...data }; // Create a new copy of the row data // newData.from_time = fromTime; // Update the from_time value // newData.to_time = toTime; // Update the to_time value // newData.actual_time = calculateTimeDifference(fromTime, toTime); // Calculate and set the actual_time // return newData; // } else { // return data; // } // }); // }); // }; // const handleRowInputChange = (e, rowIndex) => { // const { name, value, type, checked } = e.target; // const updatedRows = rows.map((row, index) => { // if (index === rowIndex) { // if (type === "checkbox") { // return { ...row, [name]: checked }; // } else if (name === "actual_time[]") { // const formattedTime = calculateTimeDifference(value); // return { ...row, [name]: value, timeDifference: formattedTime }; // } else { // return { ...row, [name]: value }; // } // } else { // return row; // } // }); // setRows(updatedRows); // setDate(e.target.value) // }; // // const handleIncreaseChange = (index) => { // // const updatedRows = [...rows]; // // updatedRows[index].increaseChecked = true; // // updatedRows[index].decreaseChecked = false; // // setRows(updatedRows); // // }; // // This function is called when the checkbox for regularization time increase is clicked. // const handleIncreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'increaseChecked' property of the row at the specified index to true. // updatedRows[index].increaseChecked = true; // // Set the 'decreaseChecked' property of the same row to false. // updatedRows[index].decreaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleActualChange = (index) => { // const updatedRows = [...rows]; // updatedRows[index].actual_time = timeDifference; // setRows(updatedRows); // }; // // const handleDecreaseChange = (index) => { // // const updatedRows = [...rows]; // // updatedRows[index].decreaseChecked = true; // // updatedRows[index].increaseChecked = false; // // setRows(updatedRows); // // }; // // This function is called when the checkbox for regularization time decrease is clicked. // const handleDecreaseChange = (index) => { // // Create a copy of the 'rows' array to avoid directly modifying the state. // const updatedRows = [...rows]; // // Set the 'decreaseChecked' property of the row at the specified index to true. // updatedRows[index].decreaseChecked = true; // // Set the 'increaseChecked' property of the same row to false. // updatedRows[index].increaseChecked = false; // // Update the state with the modified array of rows. // setRows(updatedRows); // }; // const handleSubmit = (e) => { // e.preventDefault(); // setNotify(null); // const data = new FormData(e.target); // data.append('scheduled_time', props.data.task_hours); // // data.append('actual_total_time',"00:30"); // new requestRegularizationTime(data).then((res) => { // if (res.status === 200) { // if (res.data.status === 1) { // setNotify({ type: "success", message: res.data.message }); // // window.location.reload(false) // props.hide(); // document.getElementById("requestForm").reset(); // } else { // setNotify({ type: "danger", message: res.data.message }); // } // } // }); // }; // // handle click event of the Remove button // const handleRemoveClick = (index) => { // const list = [...rows]; // list.splice(index, 1); // setRows(list); // }; // // handle click event of the Add button // const[remark, setRemark] = useState() // const handleAddClick = (e) => { // setRemark(e.target.value) // // setInputList([...inputList, { name: null, id: null }]); // }; // const [approveData, setApproveData] = useState() // const getApproveData = () => { // new getRegularizationTime(props.data.ticket_id).then(res => { // if (res.data.data) { // var temp = []; // setApproveData(null); // res.data.data.forEach(d => { // temp.push({ // 'id': d.id, // 'created_by_name': d.created_by_name, // 'from_date': d.from_date, // 'to_date': d.to_date, // 'from_time': d.from_time, // 'to_time': d.to_time, // 'status': d.status, // 'remark': d.remark, // 'is_checked': 0, // 'regularization_time_status': d.regularization_time_status, // 'task_name': d.task_name, // 'ticket_id_name': d.ticket_id_name, // 'ticket_task_id': d.ticket_task_id // }); // }) // setApproveData(temp); // } // }) // } // useEffect(() => { // calculateTimeDifference(); // }, [fromTime, toTime, rows]); // useEffect(() => { // // Code to update the actual_time value automatically // const updatedRows = rows.map(row => ({ // ...row, // actual_time: timeDifference // })); // setRows(updatedRows); // }, [timeDifference]); // useEffect(() => { // setNotify(null); // getApproveData() // }, []); // console.log("row",rows) // // const [approvedStatus, setApprovedStatus] = useState() // // useEffect(() => { // // props.isRegularised.map((d,i)=>{ // // setApprovedStatus(d.status) // // }) // // console.log(approvedStatus); // // }, [approvedStatus]); // console.log("statusValue", props.data.regularized_data.length) // console.log("statusValue==>", statusValue) // return ( //
// {notify && } // // { window.location.reload(false)}} // > // // Request Regularization // // // // //
// {/*
//
Task Name
//
*/} //
//
{`Ticket ID: ${props.data.ticket_id_name}`}
//
//
//
{`Task Name: // ${props.data.task_name}`}
//
//
//
{`Scheduled Time: ${props.data.task_hours}`}
//
//
//
//
//
// // // // {/* {console.log("hi",props.data.regularized_data.map((i)=>i.status))} */} // //
// // // // // // // // // // // // // // // // // {/* Updated by */} // {/* {rows.map((row, index) => ( // // // // // // // // {props.data.regularization_time_status ? // // : // // } // {props.data.regularization_time_status ? // // : // // } // // // // ))} */} // {props && props.isRegularisedData.length == 0 || props && props.isRegularisedData.length == 1 && props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status) == "REJECTED" || props && props.isRegularisedData.length == 2 && props.isRegularisedData.filter((d)=>d.status === "APPROVED").map((i)=>i.status) != "APPROVED"? // <> // {rows.map((row, index) => { // return // // // // // // // // // // })} // : <> // {rows.map((row, index) => { // // console.log("props.isss", props.isRegularisedData.length) // // console.log("props.isssSTATUS", props.isRegularisedData.filter((d)=>d.status === "PENDING").map((i)=>i.status)) // // console.log("r", props.isRegularisedData.filter((d)=>d.status != "REJECTED").map((i)=>i.status )) // return // // // // // // // // // // })} // } // //
Sr No From Date To Date From Time To Time Actual Time Increase Time Decrease Time Remark Action
{index + 1} // handleRowInputChange(e, index)} // required // disabled={props.data.regularized_data.length == 0 || statusValue === "REJECTED" ? false :true } // /> // // handleRowInputChange(e, index)} // required // disabled={props.data.regularized_data.length > 0 || statusValue === "REJECT" ? false :true } // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // handleActualTimeChange(index, e.target.value, row.to_time)} // required // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // handleActualTimeChange(index, row.from_time, e.target.value)} // required // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // // handleIncreaseChange(index)} // value="YES" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // handleIncreaseChange(index)} // name="regularization_time_status" // id="regularization_time_status" // value="YES" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // handleDecreaseChange(index)} // name="regularization_time_status" // id="regularization_time_status" // value="NO" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // // disabled={props.data.is_regularized === "NO" ? true : false} // /> // // // handleDecreaseChange(index)} // name="regularization_time_status" // id="regularization_time_status" // value="NO" // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // /> // // // handleAddClick(e)} // defaultValue={props.data.remark} // required // disabled={props.data.regularized_data.length <= 0 || statusValue === "REJECT" ? false :true } // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
{index + 1} // handleRowInputChange(e, index)} // required // /> // // handleRowInputChange(e, index)} // required // disabled={props.data.is_regularized === "YES" ? true : false} // /> // // handleActualTimeChange(index, e.target.value, row.to_time)} // required // disabled={props.data.is_regularized === "YES" ? true : false} // /> // // // handleActualTimeChange(index, row.from_time, e.target.value)} // required // disabled={props.data.is_regularized === "YES" ? true : false} // /> // // // // handleAddClick(e)} // defaultValue={props.data.remark} // required // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
{index + 1} // i.from_date)} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // disabled={true} // // disabled={props.isRegularisedData.length == 0 || props.isRegularisedData.length == 1 && props.isRegularisedData.filter((d)=>d.status === "PENDING").map((i)=>i.status === []) || props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status === []) || props.isRegularisedData.filter((d)=>d.status === ["PENDING"]).map((i)=>i.status === ["PENDING"]) || props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status === []) || props.isRegularisedData.filter((d)=>d.status === "REJECTED").map((i)=>i.status === "REJECTED") ? false : true} // // disabled= // // Change this to true if you want to disable when status is not "REJECTED" // /> // // i.to_date)} // min={date} // max={formattedDate} // onChange={(e) => handleRowInputChange(e, index)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // /> // // i.from_time)} // onChange={(e) => handleActualTimeChange(index, e.target.value, row.to_time)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // disabled={true} // /> // // // i.to_time)} // onChange={(e) => handleActualTimeChange(index, row.from_time, e.target.value)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // disabled={true} // /> // // // // handleAddClick(e)} // defaultValue={ props.isRegularisedData.map((i)=>i.remark)} // required // // disabled={props.data.is_regularized === "YES" ? true : false} // // disabled={props.data.is_regularized === "YES" && props.isRegularised.filter((d)=>d.ticket_task_id == props.data.id).map((i)=>i.status) != "REJECTED" ? true : false} // disabled={true} // /> // // {index + 1 == 1 && ( // // )} // {index + 1 > 1 && ( // // )} //
//
//
// // // //
//
//
// ); // }; // export default RequestModal;