#167 added fix on the projects that are reformated in the fetchProjectsNonWatcher reducer

parent 637da7d0
...@@ -228,7 +228,8 @@ router.put('/change-project-role/:userId',authAdminProject, async (req: Request ...@@ -228,7 +228,8 @@ router.put('/change-project-role/:userId',authAdminProject, async (req: Request
/** return projects where user's member.role not equal 'watcher' */ /** return projects where user's member.role not equal 'watcher' */
router.get('/task_create/:userId', async (req : Request, res : Response): Promise<Response>=>{ router.get('/task_create/:userId', async (req : Request, res : Response): Promise<Response>=>{
try{ try{
const userId:string = req.params.userId const userId = req.params.userId
console.log('userId', userId)
const userProjects = await dataSource const userProjects = await dataSource
.createQueryBuilder() .createQueryBuilder()
.select('project') .select('project')
...@@ -238,6 +239,7 @@ router.get('/task_create/:userId', async (req : Request, res : Response): Promis ...@@ -238,6 +239,7 @@ router.get('/task_create/:userId', async (req : Request, res : Response): Promis
.where("user.id = :id", { id: userId }) .where("user.id = :id", { id: userId })
.andWhere("member.roleProject != :role", {role:MemberRole.WATCHER}) .andWhere("member.roleProject != :role", {role:MemberRole.WATCHER})
.getMany(); .getMany();
console.log('userProjects', userProjects)
return res.send({userProjects}) return res.send({userProjects})
} catch(e) { } catch(e) {
return res.status(502).send({message:(e as Error).message}) return res.status(502).send({message:(e as Error).message})
......
...@@ -2,6 +2,7 @@ import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'; ...@@ -2,6 +2,7 @@ import { FormControl, InputLabel, MenuItem, Select } from '@mui/material';
import { memo } from 'react'; import { memo } from 'react';
function СustomSelect({ value, onChange, label, variant = 'standard', items, id, defaultValue, name, sx, renderValue}) { function СustomSelect({ value, onChange, label, variant = 'standard', items, id, defaultValue, name, sx, renderValue}) {
console.log('custom select render , ' , items)
return ( return (
<> <>
<FormControl variant={variant} sx={ sx?.width ? sx : { m: 0, minWidth: 125}}> <FormControl variant={variant} sx={ sx?.width ? sx : { m: 0, minWidth: 125}}>
......
...@@ -17,7 +17,7 @@ export default function MyTasks() { ...@@ -17,7 +17,7 @@ export default function MyTasks() {
const { user } = useSelector((state) => state.users); const { user } = useSelector((state) => state.users);
const { tasks, sortedTasks } = useSelector((state) => state.tasks, shallowEqual); const { tasks, sortedTasks } = useSelector((state) => state.tasks, shallowEqual);
const { allUserProjectsForModalTask, projects } = useSelector(state => state.projects, shallowEqual) const { allUserProjectsForModalTask, projects } = useSelector(state => state.projects, shallowEqual)
console.log('allUserProjectsForModalTask', allUserProjectsForModalTask)
const [newTask, setNewTask] = useState({ const [newTask, setNewTask] = useState({
priority: '', priority: '',
title: '', title: '',
...@@ -118,9 +118,11 @@ export default function MyTasks() { ...@@ -118,9 +118,11 @@ export default function MyTasks() {
dateTimeDeadLine: null dateTimeDeadLine: null
}) })
} }
console.log('before dispatch fetchProjectsNonWatcherForTaskCreate')
dispatch(fetchProjectsNonWatcherForTaskCreate(user.id)) dispatch(fetchProjectsNonWatcherForTaskCreate(user.id))
setAddFormStatus((prevState) => { return !prevState }) setAddFormStatus((prevState) => { return !prevState })
}, [addFormStatus]) // }, [addFormStatus])
}, [])
......
import axios from "../../axiosPlanner"; import axios from "../../axiosPlanner";
import { CHANGE_MEMBER_ROLE_FAILURE, CHANGE_MEMBER_ROLE_REQUEST, CHANGE_MEMBER_ROLE_SUCCESS, CREATE_MEMBER_SUCCESS, CREATE_PROJECT_SUCCESS, DELETE_MEMBER_FAILURE, DELETE_MEMBER_REQUEST, DELETE_MEMBER_SUCCESS, DELETE_PROJECT_FAILURE, DELETE_PROJECT_REQUEST, DELETE_PROJECT_SUCCESS, FETCH_ALL_USER_PROJECTS_SUCCESS, FETCH_PROJECTS_ERROR, FETCH_PROJECTS_REQUEST, FETCH_PROJECTS_SUCCESS, FETCH_PROJECT_SUCCESS } from "../actionTypes/projectsActionTypes"; import { CHANGE_MEMBER_ROLE_FAILURE,
CHANGE_MEMBER_ROLE_REQUEST,
CHANGE_MEMBER_ROLE_SUCCESS,
CREATE_MEMBER_SUCCESS,
CREATE_PROJECT_SUCCESS,
DELETE_MEMBER_FAILURE,
DELETE_MEMBER_REQUEST,
DELETE_MEMBER_SUCCESS,
DELETE_PROJECT_FAILURE,
DELETE_PROJECT_REQUEST,
DELETE_PROJECT_SUCCESS,
FETCH_ALL_USER_PROJECTS_SUCCESS,
FETCH_PROJECTS_ERROR,
FETCH_PROJECTS_REQUEST,
FETCH_PROJECTS_SUCCESS,
FETCH_PROJECT_SUCCESS,
FETCH_PROJECTS_NON_WATCHER_REQUEST,
FETCH_PROJECTS_NON_WATCHER_SUCCESS,
FETCH_PROJECTS_NON_WATCHER_FAILURE
} from "../actionTypes/projectsActionTypes";
import { showNotification } from "./commonActions"; import { showNotification } from "./commonActions";
const fetchProjectsRequest = () => { const fetchProjectsRequest = () => {
...@@ -164,6 +184,9 @@ export const changeMemberRole = (userId, data) => { ...@@ -164,6 +184,9 @@ export const changeMemberRole = (userId, data) => {
} }
} }
const fetchProjectsNonWatcherRequest = () => {
return { type: FETCH_PROJECTS_NON_WATCHER_REQUEST }
};
const fetchProjectsNonWatcherSuccess = (projects) => { const fetchProjectsNonWatcherSuccess = (projects) => {
return { type: FETCH_PROJECTS_NON_WATCHER_SUCCESS, projects } return { type: FETCH_PROJECTS_NON_WATCHER_SUCCESS, projects }
...@@ -175,7 +198,7 @@ const fetchProjectsNonWatcherSuccess = (projects) => { ...@@ -175,7 +198,7 @@ const fetchProjectsNonWatcherSuccess = (projects) => {
export const fetchProjectsNonWatcherForTaskCreate = (userId) => { export const fetchProjectsNonWatcherForTaskCreate = (userId) => {
return async (dispatch) => { return async (dispatch) => {
dispatch(fetchCalendarTasksRequest()); dispatch(fetchProjectsNonWatcherRequest());
try { try {
const response = await axios.get(`/projects/task_create/${userId}`); const response = await axios.get(`/projects/task_create/${userId}`);
dispatch(fetchProjectsNonWatcherSuccess(response.data.projects)) dispatch(fetchProjectsNonWatcherSuccess(response.data.projects))
......
...@@ -62,7 +62,8 @@ const projectsReducer = (state = initialState, action) => { ...@@ -62,7 +62,8 @@ const projectsReducer = (state = initialState, action) => {
case FETCH_PROJECTS_NON_WATCHER_REQUEST: case FETCH_PROJECTS_NON_WATCHER_REQUEST:
return { ...state, loading: true }; return { ...state, loading: true };
case FETCH_PROJECTS_NON_WATCHER_SUCCESS: case FETCH_PROJECTS_NON_WATCHER_SUCCESS:
return { ...state, loading: false, allUserProjectsForModalTask: action.projects }; const projectsNonWatcher = action.projects.map((project) => {return{value: project.id, text: project.title}})
return { ...state, loading: false, allUserProjectsForModalTask:projectsNonWatcher };
case FETCH_PROJECTS_NON_WATCHER_FAILURE: case FETCH_PROJECTS_NON_WATCHER_FAILURE:
return { ...state, loading: false, error: action.error }; return { ...state, loading: false, error: action.error };
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment