React Query Integration for Server State Sync in Clinet #245
@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
|
||||
import WorkItem from "./WorkItem";
|
||||
import { useProjectDetails } from "../../../hooks/useProjects";
|
||||
import { cacheData, getCachedData } from "../../../slices/apiDataManager";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { refreshData } from "../../../slices/localVariablesSlice";
|
||||
import ProjectRepository from "../../../repositories/ProjectRepository";
|
||||
import showToast from "../../../services/toastService";
|
||||
@ -17,7 +17,12 @@ import ProgressDonutChart from "../../Charts/ProgressDonutChart";
|
||||
import ProgressBar from "../../common/ProgressBar";
|
||||
import { componentsToColor } from "pdf-lib";
|
||||
|
||||
const WorkArea = ({ workArea, floor, forBuilding }) => {
|
||||
const WorkArea = ( {workArea, floor, forBuilding} ) =>
|
||||
{
|
||||
const selectedProject = useSelector( ( store ) => store.localVariables.projectId )
|
||||
const { projects_Details, loading, error, refetch } = useProjectDetails(
|
||||
selectedProject
|
||||
);
|
||||
const [workItems, setWorkItems] = useState([]);
|
||||
const dispatch = useDispatch();
|
||||
const [Project, setProject] = useState();
|
||||
@ -48,15 +53,16 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
||||
}, [workItems]);
|
||||
|
||||
useEffect(() => {
|
||||
const project = getCachedData("projectInfo");
|
||||
setProject(project);
|
||||
// const project = getCachedData("projectInfo");
|
||||
setProject( projects_Details );
|
||||
|
||||
if (!project || !forBuilding?.id || !floor?.id || !workArea?.id) return;
|
||||
const building = project.buildings?.find((b) => b.id === forBuilding.id);
|
||||
|
||||
if (!projects_Details || !forBuilding?.id || !floor?.id || !workArea?.id) return;
|
||||
const building = projects_Details.buildings?.find((b) => b.id === forBuilding.id);
|
||||
const floors = building?.floors?.find((f) => f.id === floor.id);
|
||||
const workAreas = floor?.workAreas?.find((wa) => wa.id === workArea.id);
|
||||
setWorkItems(workAreas?.workItems || []);
|
||||
}, [workArea, floor, floor]);
|
||||
}, [workArea, floor, floor,loading]);
|
||||
|
||||
const HanldeDeleteActivity = async (workItemId) => {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user