Calling api for services dropdwon.
This commit is contained in:
parent
ea350db98b
commit
e154bac64a
@ -17,7 +17,7 @@ import {
|
|||||||
getCachedData,
|
getCachedData,
|
||||||
useSelectedProject,
|
useSelectedProject,
|
||||||
} from "../../slices/apiDataManager";
|
} from "../../slices/apiDataManager";
|
||||||
import { useProjectDetails, useProjectInfra } from "../../hooks/useProjects";
|
import { useProjectAssignedServices, useProjectDetails, useProjectInfra } from "../../hooks/useProjects";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { refreshData } from "../../slices/localVariablesSlice";
|
import { refreshData } from "../../slices/localVariablesSlice";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
@ -39,18 +39,17 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
|
|||||||
const [showModalTask, setshowModalTask] = useState(false);
|
const [showModalTask, setshowModalTask] = useState(false);
|
||||||
const [showModalBuilding, setshowModalBuilding] = useState(false);
|
const [showModalBuilding, setshowModalBuilding] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId);
|
||||||
|
|
||||||
|
const [selectedService, setSelectedService] = useState("");
|
||||||
|
const handleServiceChange = (e) => {
|
||||||
|
setSelectedService(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setProject(projectInfra);
|
setProject(projectInfra);
|
||||||
}, [data, projects_Details]);
|
}, [data, projects_Details]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (reloadedData) {
|
|
||||||
// refetch();
|
|
||||||
// dispatch(refreshData(false));
|
|
||||||
// }
|
|
||||||
// }, [reloadedData]);
|
|
||||||
|
|
||||||
const signalRHandler = (response) => {
|
const signalRHandler = (response) => {
|
||||||
setProject(response);
|
setProject(response);
|
||||||
}
|
}
|
||||||
@ -96,17 +95,19 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
|
|||||||
aria-controls="DataTables_Table_0"
|
aria-controls="DataTables_Table_0"
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
aria-label="Select Service"
|
aria-label="Select Service"
|
||||||
defaultValue="Fire-Fitting"
|
value={selectedService}
|
||||||
// onChange={handleServiceChange}
|
onChange={handleServiceChange}
|
||||||
>
|
>
|
||||||
<option value="Fire-Fitting">Fire-Fitting</option>
|
|
||||||
<option value="Welding">Welding</option>
|
{servicesLoading && <option>Loading...</option>}
|
||||||
<option value="Plumbing">Plumbing</option>
|
{assignedServices?.map((service) => (
|
||||||
<option value="Electrical">Electrical</option>
|
<option key={service.id} value={service.id}>
|
||||||
|
{service.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Buttons Section (aligned to right) */}
|
{/* Buttons Section (aligned to right) */}
|
||||||
<div className="col-md-8 col-12 text-end mb-1">
|
<div className="col-md-8 col-12 text-end mb-1">
|
||||||
{ManageInfra && (
|
{ManageInfra && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user