feat: no project selecting for clients

This commit is contained in:
2025-07-14 09:52:36 +04:00
parent c866231730
commit 50590fa41c
2 changed files with 21 additions and 8 deletions

View File

@@ -1,11 +1,22 @@
import { useEffect, useState } from "react";
import { BoardSchema, BoardService } from "../../../client";
import { useProjectsContext } from "../../../contexts/ProjectsContext.tsx";
import { useSelector } from "react-redux";
import { RootState } from "../../../redux/store.ts";
const useBoards = () => {
const { selectedProject } = useProjectsContext();
const [boards, setBoards] = useState<BoardSchema[]>([]);
const { isDealsViewer } = useSelector((state: RootState) => state.auth);
const filterBoards = (boards: BoardSchema[]): BoardSchema[] => {
if (isDealsViewer) {
const SALES_DEPARTMENT_FF = 5;
return boards.filter(board => board.id !== SALES_DEPARTMENT_FF);
}
return boards;
};
const refetchBoards = () => {
if (!selectedProject) return;
@@ -14,7 +25,7 @@ const useBoards = () => {
projectId: selectedProject.id,
})
.then(data => {
setBoards(data.boards);
setBoards(filterBoards(data.boards));
})
.catch(e => console.log(e));
};