Compare commits
No commits in common. "1caeeb890d2f566ee809fac48be7ece68552810b" and "d4fed679121e1fe95e0c6bf01e26e035b2be8a98" have entirely different histories.
1caeeb890d
...
d4fed67912
@ -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 };
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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>
|
||||||
@ -188,7 +186,7 @@ const EmployeeList = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -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 && (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user