Merge branch 'task-167-enhance/projects_non_watcher' into 'development'

Task 167 enhance/projects non watcher

See merge request !135
parents cabc6242 f1324776
...@@ -17,6 +17,10 @@ router.get('/',async (req:Request, res:Response): Promise<Response>=> { ...@@ -17,6 +17,10 @@ router.get('/',async (req:Request, res:Response): Promise<Response>=> {
} }
}) })
/**get projects were user is member, by user token */ /**get projects were user is member, by user token */
router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> { router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
try{ try{
...@@ -26,7 +30,6 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> { ...@@ -26,7 +30,6 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
.from(Project, "project") .from(Project, "project")
.select(["project.id"]) .select(["project.id"])
.leftJoinAndSelect('project.members', 'member') .leftJoinAndSelect('project.members', 'member')
.loadRelationCountAndMap('project.tasks', 'project.tasks')
.leftJoinAndSelect('member.user', 'user' ) .leftJoinAndSelect('member.user', 'user' )
.where('member.userId = :userId',{userId:user.id}) .where('member.userId = :userId',{userId:user.id})
.getMany() .getMany()
...@@ -34,9 +37,7 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> { ...@@ -34,9 +37,7 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
if (rawProjects.length>0){ if (rawProjects.length>0){
for(let project of rawProjects){ for(let project of rawProjects){
projectIds.push(project.id projectIds.push(project.id
) )}}
}
}
const projects = await dataSource const projects = await dataSource
.createQueryBuilder() .createQueryBuilder()
.from(Project, "project") .from(Project, "project")
...@@ -53,27 +54,25 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> { ...@@ -53,27 +54,25 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
}) })
/**create new project */ /**create new project */
router.post('/',auth, async (req:Request, res:Response): Promise<Response> => { router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
try{ try{
if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'}) if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'})
const {user, title,color}= req.body; const {user, title,color}= req.body;
const titleTrimed = title.trim()
const projectCheck = await dataSource const projectCheck = await dataSource
.getRepository(Project) .getRepository(Project)
.find({ .find({
where:{ where:{
title:title title:titleTrimed
} }})
}) if(projectCheck.length>0) {return res.status(400).send({message:"such Project already exists"})}
if(projectCheck.length>0) {return res.status(400).send({message:"suchc Project already exists"})}
const member:Member = new Member; const member:Member = new Member;
member.user= user; member.user= user;
member.roleProject= MemberRole.ADMIN; member.roleProject= MemberRole.ADMIN;
await member.save(); await member.save();
const project : Project= new Project() const project : Project= new Project()
project.title = title; project.title = titleTrimed;
project.color = color; project.color = color;
project.members=[member] project.members=[member]
await project.save() await project.save()
...@@ -105,10 +104,7 @@ try{ ...@@ -105,10 +104,7 @@ try{
where:{ where:{
project:{ project:{
id:req.params.id id:req.params.id
} }}})
}
}
)
return res.send({project, tasks}) return res.send({project, tasks})
} catch(e) { } catch(e) {
return res.status(502).send({message:(e as Error).message}) return res.status(502).send({message:(e as Error).message})
...@@ -188,8 +184,7 @@ router.delete('/remove-user/:userId', authAdminProject,async (req: Request, res: ...@@ -188,8 +184,7 @@ router.delete('/remove-user/:userId', authAdminProject,async (req: Request, res:
project:{ project:{
id:projectId id:projectId
} }
} }})
})
if(!projectMember) return res.status(404).send({message:"this member is not present"}) if(!projectMember) return res.status(404).send({message:"this member is not present"})
await Member.delete({id:projectMember.id}) await Member.delete({id:projectMember.id})
return res.send({message:"User removed from project successfully" }) return res.send({message:"User removed from project successfully" })
...@@ -225,4 +220,27 @@ router.put('/change-project-role/:userId',authAdminProject, async (req: Request ...@@ -225,4 +220,27 @@ router.put('/change-project-role/:userId',authAdminProject, async (req: Request
}) })
/** return projects where user's member.role not equal 'watcher' */
router.get('/task_create/:userId', async (req : Request, res : Response): Promise<Response>=>{
try{
const userId = req.params.userId
const userProjects = await dataSource
.createQueryBuilder()
.select('project')
.from(Project, "project")
.leftJoinAndSelect('project.members', 'member')
.leftJoinAndSelect('member.user', 'user' )
.where("user.id = :id", { id: userId })
.andWhere("member.roleProject != :role", {role:MemberRole.WATCHER})
.getMany();
return res.send({userProjects})
} catch(e) {
return res.status(502).send({message:(e as Error).message})
}
})
export default router; export default router;
...@@ -40,23 +40,6 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{ ...@@ -40,23 +40,6 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
newTask.title = title; newTask.title = title;
newTask.description = description; newTask.description = description;
if (project) { if (project) {
const watcherOfProject = await dataSource
.getRepository(Project)
.findOne({
relations:{
members:true,
},
where:
{
id:project.id,
members:
{
user:{id:user.id},
roleProject:MemberRole.WATCHER,
},
}
})
if (watcherOfProject) return res.send({message:"watcher could nt make tasks"})
newTask.project = project; newTask.project = project;
} else { } else {
const personalProject = await dataSource const personalProject = await dataSource
...@@ -71,14 +54,9 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{ ...@@ -71,14 +54,9 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
}) })
if (personalProject) newTask.project = personalProject; if (personalProject) newTask.project = personalProject;
} }
newTask.dateTimeDeadLine= dateTimeDeadlineFinal; newTask.dateTimeDeadLine= dateTimeDeadlineFinal;
newTask.author= user; newTask.author= user;
if(newTask.project.title==="Личные дела"){ newTask.project.title==="Личные дела"? newTask.executor=user: newTask.executor= executor;
newTask.executor=user;
} else {
newTask.executor= executor;
}
newTask.priority = priority; newTask.priority = priority;
await newTask.save(); await newTask.save();
if (calendar) { if (calendar) {
...@@ -104,23 +82,6 @@ router.post('/users', auth, async(req:Request, res:Response):Promise<Response>=> ...@@ -104,23 +82,6 @@ router.post('/users', auth, async(req:Request, res:Response):Promise<Response>=>
newTask.title = title; newTask.title = title;
newTask.description = description; newTask.description = description;
if (project) { if (project) {
const watcherOfProject = await dataSource
.getRepository(Project)
.findOne({
relations:{
members:true,
},
where:
{
id:project.id,
members:
{
user:{id:user.id},
roleProject:MemberRole.WATCHER,
},
}
})
if (watcherOfProject) return res.send({message:"watcher could nt make tasks"})
newTask.project = project; newTask.project = project;
} else { } else {
const personalProject = await dataSource const personalProject = await dataSource
...@@ -396,19 +357,15 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp ...@@ -396,19 +357,15 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
tasks:{ tasks:{
author:true, author:true,
executor:true executor:true
} }},
},
where:{ where:{
members:{ members:{
roleProject:Not(Equal(MemberRole.WATCHER)),
user:{ user:{
id:user.id id:user.id
}, },
project:{ project:{
title:Not(Equal("Личные дела")) title:Not(Equal("Личные дела"))
} }}}})
}
}})
if (!projectsWithTasks) return res.status(404).send({Message:'projects not found'}) if (!projectsWithTasks) return res.status(404).send({Message:'projects not found'})
let tasks:Task[] = [] let tasks:Task[] = []
...@@ -416,10 +373,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp ...@@ -416,10 +373,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
for (const project of projectsWithTasks){ for (const project of projectsWithTasks){
if (project?.tasks) { if (project?.tasks) {
tasks=tasks.concat(project.tasks) tasks=tasks.concat(project.tasks)
} }}}
}
}
const projectIds= projectsWithTasks.map(project=> {return project.id}) const projectIds= projectsWithTasks.map(project=> {return project.id})
const projects = await dataSource const projects = await dataSource
.getRepository(Project) .getRepository(Project)
...@@ -432,9 +386,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp ...@@ -432,9 +386,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
id:In(projectIds), id:In(projectIds),
members:{ members:{
roleProject: Not(MemberRole.WATCHER) roleProject: Not(MemberRole.WATCHER)
} }},})
},
})
return res.send({projects, tasks}) return res.send({projects, tasks})
} catch(e){ } catch(e){
console.log('Error: ',(e as Error).message); console.log('Error: ',(e as Error).message);
......
...@@ -5,7 +5,7 @@ import MyTasksTableContainer from '../../components/MyTasksCompoments/MyTasksTab ...@@ -5,7 +5,7 @@ import MyTasksTableContainer from '../../components/MyTasksCompoments/MyTasksTab
import { activateCreateCopyTasksMode, fetchAllTasks, sortTaskByProjects, addTask, deleteTask, deleteDateTimeTask, editTask } from '../../store/actions/tasksActions'; import { activateCreateCopyTasksMode, fetchAllTasks, sortTaskByProjects, addTask, deleteTask, deleteDateTimeTask, editTask } from '../../store/actions/tasksActions';
import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { fetchAllUserProjects, fetchProjects } from '../../store/actions/projectsActions'; import { fetchAllUserProjects, fetchProjects,fetchProjectsNonWatcherForTaskCreate } from '../../store/actions/projectsActions';
import moment from 'moment'; import moment from 'moment';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
...@@ -17,7 +17,6 @@ export default function MyTasks() { ...@@ -17,7 +17,6 @@ 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)
const [newTask, setNewTask] = useState({ const [newTask, setNewTask] = useState({
priority: '', priority: '',
title: '', title: '',
...@@ -118,8 +117,11 @@ export default function MyTasks() { ...@@ -118,8 +117,11 @@ export default function MyTasks() {
dateTimeDeadLine: null dateTimeDeadLine: null
}) })
} }
dispatch(fetchProjectsNonWatcherForTaskCreate(user.id))
setAddFormStatus((prevState) => { return !prevState }) setAddFormStatus((prevState) => { return !prevState })
}, [addFormStatus]) }, [])
const createNewTaskHandler = useCallback(() => { const createNewTaskHandler = useCallback(() => {
const task = { const task = {
......
...@@ -5,15 +5,10 @@ import UsersTasksTableContainer from '../../components/UsersTasksCompoments/User ...@@ -5,15 +5,10 @@ import UsersTasksTableContainer from '../../components/UsersTasksCompoments/User
import { activateCreateCopyTasksMode, addTaskToUserTasksTable, deleteDateTimeTaskUsers, deleteTaskUsers, editTaskUsers, fetchAllTasksByMembership, sortTaskByProjects } from '../../store/actions/tasksActions'; import { activateCreateCopyTasksMode, addTaskToUserTasksTable, deleteDateTimeTaskUsers, deleteTaskUsers, editTaskUsers, fetchAllTasksByMembership, sortTaskByProjects } from '../../store/actions/tasksActions';
import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { fetchAllUserProjects, fetchProjects } from '../../store/actions/projectsActions'; import { fetchAllUserProjects, fetchProjects, fetchProjectsNonWatcherForTaskCreate } from '../../store/actions/projectsActions';
import moment from 'moment'; import moment from 'moment';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { lazy } from "react";
// const UsersTasksTableToolbar = lazy(() => import("../../components/UsersTasksCompoments/UsersTasksTableToolbar/UsersTasksTableToolbar"));
// const UsersTasksTablePagination = lazy(() => import("../../components/UsersTasksCompoments/UsersTasksTablePagination/UsersTasksTablePagination"));
// const UsersTasksTableContainer = lazy(() => import("../../components/UsersTasksCompoments/UsersTasksTableContainer/UsersTasksTableContainer"));
export default function UsersTasks() { export default function UsersTasks() {
const dispatch = useDispatch(); const dispatch = useDispatch();
...@@ -21,6 +16,7 @@ export default function UsersTasks() { ...@@ -21,6 +16,7 @@ export default function UsersTasks() {
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)
const { user } = useSelector((state) => state.users);
const [newTask, setNewTask] = useState({ const [newTask, setNewTask] = useState({
priority: '', priority: '',
...@@ -125,8 +121,9 @@ export default function UsersTasks() { ...@@ -125,8 +121,9 @@ export default function UsersTasks() {
dateTimeDeadLine: null dateTimeDeadLine: null
}) })
} }
dispatch(fetchProjectsNonWatcherForTaskCreate(user.id))
setAddFormStatus((prevState) => { return !prevState }) setAddFormStatus((prevState) => { return !prevState })
}, [addFormStatus]) }, [])
const createNewTaskHandler = useCallback(() => { const createNewTaskHandler = useCallback(() => {
if (newTask.priority === '' || newTask.project === '' || newTask.executor === '') { if (newTask.priority === '' || newTask.project === '' || newTask.executor === '') {
......
...@@ -19,4 +19,10 @@ export const DELETE_PROJECT_FAILURE = "DELETE_PROJECT_FAILURE"; ...@@ -19,4 +19,10 @@ export const DELETE_PROJECT_FAILURE = "DELETE_PROJECT_FAILURE";
export const CHANGE_MEMBER_ROLE_REQUEST = "CHANGE_MEMBER_ROLE_REQUEST"; export const CHANGE_MEMBER_ROLE_REQUEST = "CHANGE_MEMBER_ROLE_REQUEST";
export const CHANGE_MEMBER_ROLE_SUCCESS = "CHANGE_MEMBER_ROLE_SUCCESS"; export const CHANGE_MEMBER_ROLE_SUCCESS = "CHANGE_MEMBER_ROLE_SUCCESS";
export const CHANGE_MEMBER_ROLE_FAILURE = "CHANGE_MEMBER_ROLE_FAILURE"; export const CHANGE_MEMBER_ROLE_FAILURE = "CHANGE_MEMBER_ROLE_FAILURE";
\ No newline at end of file
export const FETCH_PROJECTS_NON_WATCHER_REQUEST = "FETCH_PROJECTS_NON_WATCHER_REQUEST";
export const FETCH_PROJECTS_NON_WATCHER_SUCCESS = "FETCH_PROJECTS_NON_WATCHER_SUCCESS";
export const FETCH_PROJECTS_NON_WATCHER_FAILURE = "FETCH_PROJECTS_NON_WATCHER_FAILURE";
...@@ -33,4 +33,9 @@ export const FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE = "FETCH_ALL_TASKS_BY_MEMBERS ...@@ -33,4 +33,9 @@ export const FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE = "FETCH_ALL_TASKS_BY_MEMBERS
export const ACTIVATE_CREATE_COPY_TASKS_MODE = "ACTIVATE_CREATE_COPY_TASKS_MODE" export const ACTIVATE_CREATE_COPY_TASKS_MODE = "ACTIVATE_CREATE_COPY_TASKS_MODE"
export const DEACTIVATE_CREATE_COPY_TASKS_MODE = "DEACTIVATE_CREATE_COPY_TASKS_MODE" export const DEACTIVATE_CREATE_COPY_TASKS_MODE = "DEACTIVATE_CREATE_COPY_TASKS_MODE"
export const SORT_TASKS = "SORT_TASKS" export const SORT_TASKS = "SORT_TASKS"
\ No newline at end of file
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,3 +184,26 @@ export const changeMemberRole = (userId, data) => { ...@@ -164,3 +184,26 @@ export const changeMemberRole = (userId, data) => {
} }
} }
const fetchProjectsNonWatcherRequest = () => {
return { type: FETCH_PROJECTS_NON_WATCHER_REQUEST }
};
const fetchProjectsNonWatcherSuccess = (projects) => {
return { type: FETCH_PROJECTS_NON_WATCHER_SUCCESS, projects }
};
const fetchProjectsNonWatcherFailure = (error) => {
return { type: FETCH_PROJECTS_NON_WATCHER_FAILURE, error }
};
export const fetchProjectsNonWatcherForTaskCreate = (userId) => {
return async (dispatch) => {
dispatch(fetchProjectsNonWatcherRequest());
try {
const response = await axios.get(`/projects/task_create/${userId}`);
dispatch(fetchProjectsNonWatcherSuccess(response.data.projects))
} catch (error) {
dispatch(fetchProjectsNonWatcherFailure(error));
}
}
};
\ No newline at end of file
...@@ -21,7 +21,9 @@ import { ...@@ -21,7 +21,9 @@ import {
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS, FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS,
DEACTIVATE_CREATE_COPY_TASKS_MODE, DEACTIVATE_CREATE_COPY_TASKS_MODE,
ACTIVATE_CREATE_COPY_TASKS_MODE, ACTIVATE_CREATE_COPY_TASKS_MODE,
SORT_TASKS SORT_TASKS,
FETCH_PROJECTS_NON_WATCHER_SUCCESS,
FETCH_PROJECTS_NON_WATCHER_FAILURE,
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner' import axios from '../../axiosPlanner'
...@@ -54,6 +56,7 @@ export const fetchCalendarTasks = (userId) => { ...@@ -54,6 +56,7 @@ export const fetchCalendarTasks = (userId) => {
} }
}; };
export const fetchAllTasks = () => { export const fetchAllTasks = () => {
return async (dispatch) => { return async (dispatch) => {
dispatch(fetchCalendarTasksRequest()); dispatch(fetchCalendarTasksRequest());
......
import { CHANGE_MEMBER_ROLE_FAILURE, CHANGE_MEMBER_ROLE_REQUEST, CHANGE_MEMBER_ROLE_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,
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";
const initialState = { const initialState = {
allUserProjectsForModalTask: [], allUserProjectsForModalTask: [],
...@@ -42,6 +59,13 @@ const projectsReducer = (state = initialState, action) => { ...@@ -42,6 +59,13 @@ const projectsReducer = (state = initialState, action) => {
return { ...state, loading: true }; return { ...state, loading: true };
case CHANGE_MEMBER_ROLE_FAILURE: case CHANGE_MEMBER_ROLE_FAILURE:
return { ...state, loading: false, error: action.error }; return { ...state, loading: false, error: action.error };
case FETCH_PROJECTS_NON_WATCHER_REQUEST:
return { ...state, loading: true };
case FETCH_PROJECTS_NON_WATCHER_SUCCESS:
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:
return { ...state, loading: false, error: action.error };
default: default:
return state; return state;
} }
......
...@@ -22,7 +22,8 @@ import { ...@@ -22,7 +22,8 @@ import {
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS, FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS,
ACTIVATE_CREATE_COPY_TASKS_MODE, ACTIVATE_CREATE_COPY_TASKS_MODE,
DEACTIVATE_CREATE_COPY_TASKS_MODE, DEACTIVATE_CREATE_COPY_TASKS_MODE,
SORT_TASKS SORT_TASKS,
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
const initialState = { const initialState = {
...@@ -168,6 +169,7 @@ const tasksReduсer = (state = initialState, action) => { ...@@ -168,6 +169,7 @@ const tasksReduсer = (state = initialState, action) => {
} }
} }
return { ...state, loading: false, sortedTasks: filteredTasks }; return { ...state, loading: false, sortedTasks: filteredTasks };
default: default:
return state; return state;
} }
......
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