Compare commits

..

No commits in common. "1caeeb890d2f566ee809fac48be7ece68552810b" and "d4fed679121e1fe95e0c6bf01e26e035b2be8a98" have entirely different histories.

3 changed files with 31 additions and 47 deletions

View File

@ -7,7 +7,6 @@ import { setProjectId } from "../slices/localVariablesSlice";
export const useProjects = () => export const useProjects = () =>
{ {
const {profile} = useProfile()
const dispatch = useDispatch(); const dispatch = useDispatch();
const [projects, setProjects] = useState([]); const [projects, setProjects] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@ -49,19 +48,9 @@ export const useProjects = () =>
fetchData(); fetchData();
}, []); }, []);
useEffect( () => useEffect(() => {
{ dispatch(setProjectId(projects[0]?.id));
if (projects ) }, [projects]);
{
if ( profile?.projects && profile?.projects?.length > 0 )
{
dispatch(setProjectId(profile?.projects[0]))
} else
{
dispatch(setProjectId(1))
}
}
}, [profile]);
return { projects, loading, error, refetch: fetchData }; return { projects, loading, error, refetch: fetchData };
}; };

View File

@ -178,9 +178,7 @@ const EmployeeList = () => {
<> <>
<option value="">All Employees</option> <option value="">All Employees</option>
{Array.isArray(projects) && {Array.isArray(projects) &&
projects projects.map((item) => (
.filter((item) => loginUser?.projects?.includes(String(item.id)))
.map((item) => (
<option key={item.id} value={item.id}> <option key={item.id} value={item.id}>
{item.name} {item.name}
</option> </option>

View File

@ -176,13 +176,10 @@ const ProjectList = () =>
{loading && <p className="text-center">Loading...</p>} {loading && <p className="text-center">Loading...</p>}
{Array.isArray(currentItems) && loginUser?.projects && ( {currentItems &&
currentItems currentItems.map((item) => (
.filter((item) => loginUser.projects.includes(String(item.id))) <ProjectCard projectData={item} key={item.id}></ProjectCard>
.map((item) => ( ))}
<ProjectCard projectData={item} key={item.id} />
))
)}
</div> </div>
{/* Pagination */} {/* Pagination */}
{!loading && ( {!loading && (