Skip to content

Commit

Permalink
Merge pull request #1079 from sriranjan-s/Dev-2.0
Browse files Browse the repository at this point in the history
Added BPA fix for filed inspector report
  • Loading branch information
sriranjan-s committed Apr 28, 2024
2 parents 83365d5 + c457393 commit f8f0c2a
Showing 1 changed file with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ const ActionModal = ({ t, action, tenantId, state, id, closeModal, submitAction,
const [error, setError] = useState(null);
const [selectedFinancialYear, setSelectedFinancialYear] = useState(null);
const mobileView = Digit.Utils.browser.isMobile() ? true : false;
const [setDateTime,setDateTimeVal]=useState(true);

useEffect(() => {
setApprovers(approverData?.Employees?.map((employee) => ({ uuid: employee?.uuid, name: employee?.user?.name })));
getfeildInspection(applicationData);
}, [approverData]);

function selectFile(e) {
Expand Down Expand Up @@ -119,7 +117,19 @@ const ActionModal = ({ t, action, tenantId, state, id, closeModal, submitAction,
if (data?.additionalDetails?.fieldinspection_pending?.length > 0) {
inspectionOb = data?.additionalDetails?.fieldinspection_pending
}
inspectionOb = inspectionOb.filter(obj => {
// Check if the object has the date field
if (!obj.date) return false;

// Get today's date
const today = new Date();
// Extract date from the object and convert it to a Date object
const objDate = new Date(obj.date);
// Compare the object's date with today's date
return objDate <= today;
});


if(data.status == "FIELDINSPECTION_INPROGRESS") {
formdata = JSON.parse(sessionStorage.getItem("INSPECTION_DATA"));
formdata?.length > 0 && formdata.map((ob,ind) => {
Expand All @@ -130,10 +140,9 @@ const ActionModal = ({ t, action, tenantId, state, id, closeModal, submitAction,
time: ob?.InspectionTime,
})
})
if(!inspectionOb?.[inspectionOb?.length-1]?.date && !inspectionOb?.[inspectionOb?.length-1]?.time){
setDateTimeVal(false);
}
console.log("FIELDINSPECTION_INPROGRESS",inspectionOb)
inspectionOb = inspectionOb.filter((ob) => ob.date && ob.time);
console.log("inspectionObinspectionOb",inspectionOb)
} else {
sessionStorage.removeItem("INSPECTION_DATA")
}
Expand Down Expand Up @@ -243,17 +252,28 @@ const ActionModal = ({ t, action, tenantId, state, id, closeModal, submitAction,
}
})
}
if(setDateTime){
submitAction({
BPA:applicationData
}, nocData?.length > 0 ? nocData : false, {isStakeholder: false, bpa: true});
}
else{
closeModal();
alert("Please fill Inspection Date and Time");
}
}
if(applicationData.status == "FIELDINSPECTION_INPROGRESS") {
let formdata = JSON.parse(sessionStorage.getItem("INSPECTION_DATA"));
formdata?.length > 0 && formdata.map((ob,ind) => {

ob.InspectionDate && ob.InspectionTime ? submitAction({
BPA:applicationData
}, nocData?.length > 0 ? nocData : false, {isStakeholder: false, bpa: true}) : closeModalNew()
console.log(" ob.InspectionDate && ob.InspectionTime", ob.InspectionDate , ob.InspectionTime)
} )
}
else
{
submitAction({
BPA:applicationData
}, nocData?.length > 0 ? nocData : false, {isStakeholder: false, bpa: true})

}
}
const closeModalNew = ()=>{
closeModal()
alert("Please fill Inspection Date and Time")
}

useEffect(() => {
if (action) {
Expand Down

0 comments on commit f8f0c2a

Please sign in to comment.