deleted this component. no more used
This commit is contained in:
parent
e5f6ac23ef
commit
e0994c6f43
@ -1,104 +0,0 @@
|
||||
import React, {useState} from 'react'
|
||||
import ProjectRepository from '../../../repositories/ProjectRepository'
|
||||
import {useProjectDetails} from '../../../hooks/useProjects'
|
||||
|
||||
const DleleteActivity = ( {workItem, workArea, building, floor, onClose} ) =>
|
||||
{
|
||||
const {projects_Details, refetch} = useProjectDetails()
|
||||
const [loading,setLoading] = useState(false)
|
||||
|
||||
|
||||
const handleDeleteActivity =async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
setLoading(false)
|
||||
const updatedProject = { ...projects_Details };
|
||||
const response = await ProjectRepository.deleteProjectTask( workItem.workItemId );
|
||||
const newProject = {
|
||||
...updatedProject,
|
||||
buildings: updatedProject.buildings.map((building) =>
|
||||
building.id === building.buildingID
|
||||
? {
|
||||
...building,
|
||||
floors: building.floors.map((floor) =>
|
||||
floor.id === building.floorId
|
||||
? {
|
||||
...floor,
|
||||
workAreas: floor.workAreas.map((workArea) =>
|
||||
workArea.id === workItem?.workAreaId
|
||||
? {
|
||||
...workArea,
|
||||
workItems: (() => {
|
||||
const exists = workArea.workItems.some(
|
||||
(item) =>
|
||||
String(
|
||||
item?.workItem?.id ?? item?.id
|
||||
) === String(finalData.id)
|
||||
);
|
||||
|
||||
finalUpdatedWorkItem = workItem;
|
||||
|
||||
return exists
|
||||
? workArea.workItems.map((item) =>
|
||||
String(
|
||||
item?.workItem?.id ?? item?.id
|
||||
) === String(finalData.id)
|
||||
? workItem
|
||||
: item
|
||||
)
|
||||
: [...workArea.workItems, workItem];
|
||||
})(),
|
||||
}
|
||||
: workArea
|
||||
),
|
||||
}
|
||||
: floor
|
||||
),
|
||||
}
|
||||
: building
|
||||
),
|
||||
};
|
||||
cacheData("projectInfo", {
|
||||
projectId: newProject.id,
|
||||
data: newProject,
|
||||
});
|
||||
resetForm();
|
||||
dispatch( refreshData( true ) );
|
||||
setLoading(false)
|
||||
showToast("Activity Updated Successfully","success")
|
||||
|
||||
onClose();
|
||||
} catch ( error )
|
||||
{
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div className="modal-dialog modal-md modal-simple modal-edit-user">
|
||||
<div className='modal-dialog modal-dialog-centered'>
|
||||
<div className="modal-content">
|
||||
<div className="modal-body">
|
||||
<div className="row">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-close"
|
||||
aria-label="Close"
|
||||
onClick={()=>onClose}
|
||||
/>
|
||||
<div className="text-center mb-1">
|
||||
<h5>Are you sure you want delete this Activity { workItem.id}</h5>
|
||||
<div className='d-flex justify-content-evenly'>
|
||||
<button className='btn btn-primary btn-xs' onClick={handleDeleteActivity}>{ loading ? "Please Wait ":"Yes"}</button>
|
||||
<button className='btn btn-secondary btn-xs' onClick={()=>onClose}>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default DleleteActivity
|
Loading…
x
Reference in New Issue
Block a user