fixed project level permission bug
This commit is contained in:
parent
442ecff926
commit
09bb58e50e
@ -30,19 +30,19 @@ import DirectoryPage from "../Directory/DirectoryPage";
|
|||||||
import { useHasAnyPermission } from "../../hooks/useExpense";
|
import { useHasAnyPermission } from "../../hooks/useExpense";
|
||||||
import { VIEW_PROJECTS } from "../../utils/constants";
|
import { VIEW_PROJECTS } from "../../utils/constants";
|
||||||
import { useNavigate, useRoutes } from "react-router-dom";
|
import { useNavigate, useRoutes } from "react-router-dom";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
|
||||||
const ProjectDetails = () => {
|
const ProjectDetails = () => {
|
||||||
|
const projectId = useSelectedProject();
|
||||||
const projectId = useSelectedProject()
|
const CanViewProject = useHasUserPermission(VIEW_PROJECTS);
|
||||||
const CanViewProject = useHasAnyPermission(VIEW_PROJECTS);
|
const navigate = useNavigate();
|
||||||
const navigate = useNavigate()
|
|
||||||
|
|
||||||
const { projectNames, fetchData } = useProjectName();
|
const { projectNames, fetchData } = useProjectName();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(!CanViewProject){
|
if (!CanViewProject) {
|
||||||
navigate("/dashboard")
|
navigate("/dashboard");
|
||||||
}
|
}
|
||||||
if (projectId == null) {
|
if (projectId == null) {
|
||||||
dispatch(setProjectId(projectNames[0]?.id));
|
dispatch(setProjectId(projectNames[0]?.id));
|
||||||
@ -56,7 +56,6 @@ const ProjectDetails = () => {
|
|||||||
refetch,
|
refetch,
|
||||||
} = useProjectDetails(projectId);
|
} = useProjectDetails(projectId);
|
||||||
|
|
||||||
// const [activePill, setActivePill] = useState("profile");
|
|
||||||
const [activePill, setActivePill] = useState(() => {
|
const [activePill, setActivePill] = useState(() => {
|
||||||
return localStorage.getItem("lastActiveProjectTab") || "profile";
|
return localStorage.getItem("lastActiveProjectTab") || "profile";
|
||||||
});
|
});
|
||||||
@ -80,7 +79,7 @@ const ProjectDetails = () => {
|
|||||||
|
|
||||||
const handlePillClick = (pillKey) => {
|
const handlePillClick = (pillKey) => {
|
||||||
setActivePill(pillKey);
|
setActivePill(pillKey);
|
||||||
localStorage.setItem("lastActiveProjectTab", pillKey); // ✅ Save to localStorage
|
localStorage.setItem("lastActiveProjectTab", pillKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderContent = () => {
|
const renderContent = () => {
|
||||||
@ -136,7 +135,7 @@ const ProjectDetails = () => {
|
|||||||
<ProjectDocuments />
|
<ProjectDocuments />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case "setting":
|
case "setting":
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<ProjectSetting />
|
<ProjectSetting />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user