#167 week-data-start added to the front in store/actions/commonActions

parent 251b2975
......@@ -47,7 +47,6 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
.leftJoinAndSelect('member.user', 'user')
.where('project.id IN(:...projectIds)', {projectIds})
.getMany()
console.log('projects \n',projects)
return res.send({projects})
} catch(e) {
return res.status(502).send({message:(e as Error).message})
......
......@@ -133,7 +133,6 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
id:userId
}},
})
console.log('tasks \n',tasks)
return res.send({tasks})
} catch(e){
return res.status(502).send({message:(e as Error).message})
......@@ -402,6 +401,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
* object with key displayName related to userId, list of Project related to user
*/
router.get('/week-data-start/:userId',auth, async (req: Request, res: Response):Promise<Response>=>{
console.log('week-data-start')
const {userId} = req.params
try{
const requesterUser= req.body.user
......@@ -436,18 +436,17 @@ router.get('/week-data-start/:userId',auth, async (req: Request, res: Response):
.getRepository(Task)
.find({
relations:{
project:true,
executor:true,
},
where:{
project:{
id:In(projectIds)
}
}
})
where:
{
executor:{
id:userId
}},
})
const {displayName} = user
if (!tasks) return res.status(404).send({Message:'tasks not found'})
console.log('tasks: ',tasks, "projects" ,projects , 'displayName' ,displayName)
console.log('tasks: ',tasks, "projects: " ,projects , 'displayName : ' ,displayName)
return res.send({displayName, projects, tasks})
} catch(e){
return res.status(502).send({message:(e as Error).message})
......
......@@ -51,7 +51,6 @@ return res.send({users})
.where("user.id = :userId", { userId })
.getOne()
if (!displayName) return res.status(404).send({message:'displayName not found'})
console.log('displayName \n',displayName)
return res.send(displayName)
} catch(e) {
return res.status(502).send({message:(e as Error).message})
......
......@@ -11,6 +11,7 @@ import DefaultModal from '../../components/UI/DefaultModal/DefaultModal';
import { AllHoursOneHourFormat, AllHoursTwoHourFormat } from '../../constants';
import { getWeekInfoString, getWeekFromCurrentDate, dateToISOLikeButLocal } from '../../helpers/CalendarHelpers';
import { fetchWeekDataStart } from '../../store/actions/commonActions';
import { fetchAllUserProjects } from '../../store/actions/projectsActions';
import { addCalendarTask, addCopyCalendarTask, deactivateCreateCopyTasksMode, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions';
import { fetchCurrentCalendarDisplayName } from '../../store/actions/usersActions';
......@@ -44,14 +45,17 @@ function WeekCalendar() {
useEffect(() => {
if (userCalendarId) {
setUserId(userCalendarId)
dispatch(fetchCalendarTasks(userCalendarId))
dispatch(fetchCurrentCalendarDisplayName(userCalendarId))
dispatch(fetchAllUserProjects())
// dispatch(fetchCalendarTasks(userCalendarId))
// dispatch(fetchCurrentCalendarDisplayName(userCalendarId))
// dispatch(fetchAllUserProjects())
dispatch(fetchWeekDataStart(userCalendarId))
} else {
setUserId(user.id)
dispatch(fetchCalendarTasks(user.id))
dispatch(fetchCurrentCalendarDisplayName(user.id))
dispatch(fetchAllUserProjects())
dispatch(fetchWeekDataStart(user.id))
// dispatch(fetchCalendarTasks(user.id))
// dispatch(fetchCurrentCalendarDisplayName(user.id))
// dispatch(fetchAllUserProjects())
}
}, [userCalendarId, dispatch, user.id])
......
......@@ -34,6 +34,10 @@ 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 FETCH_WEEK_DATA_START_REQUEST = "FETCH_WEEK_DATA_START_REQUEST";
export const FETCH_WEEK_DATA_START_SUCCESS = "FETCH_WEEK_DATA_START_SUCCESS";
export const FETCH_WEEK_DATA_START_FAILURE = "FETCH_WEEK_DATA_START_FAILURE";
......
import axios from '../../axiosPlanner';
import {
FETCH_WEEK_DATA_START_REQUEST,
FETCH_WEEK_DATA_START_SUCCESS,
FETCH_WEEK_DATA_START_FAILURE,
FETCH_CALENDAR_TASKS_REQUEST,
} from '../actionTypes/tasksTypes';
import {fetchAllUserProjectsSuccess} from './projectsActions';
import { fetchCalendarTasksSuccess } from './tasksActions';
import { fetchCurrentCalendarDisplayNameSuccess } from './usersActions';
export const showNotification = (message, variant="success") => {
return {type: "SHOW_NOTIFICATION", message, variant}
}
export const hideNotification = () => {
return {type: "HIDE_NOTIFICATION"};
};
\ No newline at end of file
};
/** weekDataStart, recieves userId returns type WEEK_DATA_START_REQUEST*/
const fetchWeekDataStartRequest = () => {
return { type: FETCH_WEEK_DATA_START_REQUEST }
}
/** weekDataStart, recieves userId returns type WEEK_DATA_START_SUCCESS*/
const fetchWeekDataStartSuccess = (weekData) => {
return { type: FETCH_WEEK_DATA_START_SUCCESS, weekData }
}
/** weekDataStart, recieves userId returns type WEEK_DATA_START_FAILURE*/
const fetchWeekDataStartFailure = (error) => {
return { type: FETCH_WEEK_DATA_START_FAILURE, error }
}
/**fetchWeekDataStart, recieves userId ,make GET request to 'tasks/week-data-start/{userId}, recieves weekdata */
export const fetchWeekDataStart = (userId) => {
return async (dispatch) => {
dispatch(fetchWeekDataStartRequest());
try {
console.log('fetchWeekDataStart front', userId)
const response = await axios.get(`/tasks/week-data-start/${userId}`);
dispatch(fetchCalendarTasksSuccess(response.data.tasks))
dispatch(fetchAllUserProjectsSuccess(response.data.projects));
dispatch(fetchCurrentCalendarDisplayNameSuccess(response.data.displayName));
} catch (error) {
dispatch(fetchWeekDataStartFailure(error.response.data));
}
}
}
\ No newline at end of file
......@@ -143,7 +143,7 @@ export const createMember = (memberData) => {
};
}
const fetchAllUserProjectsSuccess = (projects) => {
export const fetchAllUserProjectsSuccess = (projects) => {
return { type: FETCH_ALL_USER_PROJECTS_SUCCESS, projects };
};
......
......@@ -24,6 +24,10 @@ import {
SORT_TASKS,
FETCH_PROJECTS_NON_WATCHER_SUCCESS,
FETCH_PROJECTS_NON_WATCHER_FAILURE,
FETCH_PROJECTS_NON_WATCHER_REQUEST,
FETCH_WEEK_DATA_START_FAILURE,
FETCH_WEEK_DATA_START_REQUEST,
FETCH_WEEK_DATA_START_SUCCESS
} from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner'
......@@ -31,7 +35,7 @@ const fetchCalendarTasksRequest = () => {
return { type: FETCH_CALENDAR_TASKS_REQUEST }
};
const fetchCalendarTasksSuccess = (tasks) => {
export const fetchCalendarTasksSuccess = (tasks) => {
return { type: FETCH_CALENDAR_TASKS_SUCCESS, tasks }
};
......@@ -352,4 +356,7 @@ export const activateCreateCopyTasksMode = (task, navigate) => {
export const deactivateCreateCopyTasksMode = () => {
return { type: DEACTIVATE_CREATE_COPY_TASKS_MODE }
}
\ No newline at end of file
}
......@@ -137,7 +137,7 @@ export const fetchUsersAllFields = () => {
}
};
const fetchCurrentCalendarDisplayNameSuccess = (displayName) => {
export const fetchCurrentCalendarDisplayNameSuccess = (displayName) => {
return {type: FETCH_DISPLAYNAME_SUCCESS, displayName}
}
......
......@@ -23,6 +23,7 @@ import {
ACTIVATE_CREATE_COPY_TASKS_MODE,
DEACTIVATE_CREATE_COPY_TASKS_MODE,
SORT_TASKS,
FETCH_WEEK_DATA_START_FAILURE,
} from "../actionTypes/tasksTypes";
......@@ -156,6 +157,8 @@ const tasksReduсer = (state = initialState, action) => {
return { ...state, copyMode: { working: true, task: action.task } }
case DEACTIVATE_CREATE_COPY_TASKS_MODE:
return { ...state, copyMode: { working: false, task: null } }
case FETCH_WEEK_DATA_START_FAILURE:
return { ...state, loading: false, error: action.error };
case SORT_TASKS:
let filteredTasks = []
if (action.activeTasksOn) {
......
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