diff --git a/src/components/Project/Infrastructure/DleleteActivity.jsx b/src/components/Project/Infrastructure/DleleteActivity.jsx deleted file mode 100644 index efdc32b7..00000000 --- a/src/components/Project/Infrastructure/DleleteActivity.jsx +++ /dev/null @@ -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 ( -