Merge branch 'Ashutosh_Enhancement#132_Int_To_Guid' of https://git.marcoaiot.com/admin/marco.pms.web into Ashutosh_Enhancement#132_Int_To_Guid

This commit is contained in:
ashutosh.nehete 2025-05-04 12:32:04 +05:30
commit 149b51c1c2

View File

@ -5,14 +5,14 @@ import { useProfile } from "./useProfile";
import { useDispatch } from "react-redux";
import { setProjectId } from "../slices/localVariablesSlice";
export const useProjects = () =>
{
const {profile} = useProfile()
export const useProjects = () => {
const { profile } = useProfile();
const dispatch = useDispatch();
const [projects, setProjects] = useState([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState("");
const projects_cache = getCachedData("projectslist");
const fetchData = async () => {
const projectIds = profile?.projects || [];
@ -22,7 +22,6 @@ export const useProjects = () =>
.sort((a, b) => a.name.localeCompare(b.name));
};
if (!projects_cache) {
setLoading(true);
try {
@ -40,20 +39,15 @@ export const useProjects = () =>
if (!projects.length) {
const filtered = filterProjects(projects_cache);
setProjects(filtered);
}
}
};
useEffect( () =>
{
if ( profile )
{
useEffect(() => {
if (profile) {
fetchData();
}
}, []);
}, [profile]);
return { projects, loading, error, refetch: fetchData };
};