Commit ec3efe63 authored by “Yevgeniy's avatar “Yevgeniy

Merge branch 'development' of…

Merge branch 'development' of ssh://git.attractor-school.com:30022/apollo64/crm-team-one into task-36-fix/fix_back_put_task
parents 91a3ef91 354ab632
import {Button} from "@mui/material"; import {Button, Menu, MenuItem} from "@mui/material";
import {NavLink} from "react-router-dom"; import { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import {NavLink, useNavigate} from "react-router-dom";
import { logoutUser } from "../../../store/actions/usersActions";
const AdminMenu = () => { const AdminMenu = () => {
const dispatch = useDispatch();
const navigate = useNavigate()
const [anchorEl, setAnchorEl] = useState(null);
const open = Boolean(anchorEl);
const user = useSelector(state => state.users.user)
console.log(user)
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const logout = () => {
dispatch(logoutUser(navigate));
handleClose()
}
return <> return <>
<Button <Button
component={NavLink} component={NavLink}
...@@ -44,13 +64,20 @@ const AdminMenu = () => { ...@@ -44,13 +64,20 @@ const AdminMenu = () => {
Создать сотрудника Создать сотрудника
</Button> </Button>
<Button <Button
component={NavLink}
to="/profile/test"
color="inherit" color="inherit"
size="large" onClick={handleClick}
> >
Профиль Hello, {user?.displayName}
</Button> </Button>
<Menu
anchorEl={anchorEl}
open={open}
onClose={handleClose}
>
<MenuItem component={NavLink} to="/profile/test" color="inherit" onClick={handleClose}>Profile</MenuItem>
<MenuItem onClick={logout}>Logout</MenuItem>
</Menu>
</> </>
}; };
......
import {Button} from "@mui/material"; import {Button, Menu, MenuItem} from "@mui/material";
import {NavLink} from "react-router-dom"; import { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import {NavLink, useNavigate} from "react-router-dom";
import { logoutUser } from "../../../store/actions/usersActions";
const WorkerMenu = ({user}) => { const WorkerMenu = () => {
const dispatch = useDispatch();
const navigate = useNavigate()
const [anchorEl, setAnchorEl] = useState(null);
const open = Boolean(anchorEl);
const user = useSelector(state => state.users.user)
console.log(user)
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const logout = () => {
dispatch(logoutUser(navigate));
handleClose()
}
return <> return <>
<Button <Button
component={NavLink} component={NavLink}
...@@ -28,13 +48,20 @@ const WorkerMenu = ({user}) => { ...@@ -28,13 +48,20 @@ const WorkerMenu = ({user}) => {
Мои задачи Мои задачи
</Button> </Button>
<Button <Button
component={NavLink}
to="/profile/test"
color="inherit" color="inherit"
size="large" onClick={handleClick}
> >
Профиль Hello, {user?.displayName}
</Button> </Button>
<Menu
anchorEl={anchorEl}
open={open}
onClose={handleClose}
>
<MenuItem component={NavLink} to="/profile/test" color="inherit" onClick={handleClose}>Profile</MenuItem>
<MenuItem onClick={logout}>Logout</MenuItem>
</Menu>
</> </>
}; };
......
import * as React from 'react'; import * as React from "react";
import TableCell from '@mui/material/TableCell'; import TableCell from "@mui/material/TableCell";
import IconButton from '@mui/material/IconButton'; import Input from "@mui/material/Input";
import Input from '@mui/material/Input';
import { Done, CalendarToday } from '@mui/icons-material';
import MaterialUIPickers from '../UI/DateTimePicker/DateTimePicker';
const CustomTableCell = ({ task, name, value, onChange, onModalOpen }) => {
const styles = { width: "auto", height: "10px"};
const CustomTableCell = ({ task, name, onChange, onModalOpen }) => { if (task) {
const styles = { width: "auto", height: "40px" };
return ( return (
<> <>
{task.isEditMode && name === "title" ? (
<TableCell <TableCell
onClick={(e) => onModalOpen(e, task)} align="left" style={styles}> onClick={(e) => (onModalOpen ? onModalOpen(e, task) : null)}
<Input align="left"
value={task[name]}
name={name}
onChange={(e) => onChange(e, task)}
style={styles} style={styles}
/> >
</TableCell> {task.isEditMode && onChange ? (
) : task.isEditMode && name !== "title"? (
<TableCell align="left" style={styles}>
<Input <Input
value={task[name]} value={value}
name={name} name={name}
onChange={(e) => onChange(e, task)} onChange={(e) => onChange(e, task)}
style={styles} style={styles}
/> />
</TableCell>
) : onModalOpen ? (
<TableCell align="left" style={styles} onClick={(e) => onModalOpen(e, task)}>
<span style={{ width: "100%" }} >
{task[name]}
</span>
</TableCell>
) : ( ) : (
<TableCell align="left" style={styles}> <span>{value}</span>
{task[name]}
</TableCell>
)} )}
</> </TableCell>
</>
); );
}
}; };
export default CustomTableCell; export default CustomTableCell;
\ No newline at end of file
import * as React from "react";
import TextField from "@mui/material/TextField";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
export default function MaterialUIPickers(props) {
return (
<LocalizationProvider
dateAdapter={AdapterMoment}
sx={{ width: "auto", fontSize: 5, fontWeight: "200" }}
>
<DateTimePicker
disabled={props.task.readOnly}
renderInput={(params) => (
<TextField
{...params}
sx={{ width: "auto", fontWeight: "200", fontSize: 5 }}
name={props.name}
/>
)}
value={props.task[props.name]}
onChange={(newValue) => {
props.onChange(props.task.id, newValue, props.name);
}}
/>
</LocalizationProvider>
);
}
import { Modal, IconButton } from '@mui/material'; import { Modal, IconButton } from "@mui/material";
import './TaskModal.css'; import "./TaskModal.css";
import { Done } from '@mui/icons-material'; import { Done } from "@mui/icons-material";
import Input from '@mui/material/Input'; import Input from "@mui/material/Input";
import { useState, useEffect } from "react";
const TaskModal = (props) => { const TaskModal = (props) => {
const [taskContent, setTaskContent] = useState();
useEffect(() => {
if (props.task !== null) {
setTaskContent({
title: props.task.title,
description: props.task.description,
});
}
}, [props.task]);
const inputChangeHandler = (e) => {
const { name, value } = e.target;
setTaskContent((prevState) => {
return { ...prevState, [name]: value };
});
props.onChange(e, props.task);
};
const saveModalData=()=>{
props.handleClose()
};
return ( return (
<Modal <Modal
aria-labelledby="transition-modal-title" aria-labelledby="transition-modal-title"
...@@ -39,37 +13,38 @@ const TaskModal = (props) => { ...@@ -39,37 +13,38 @@ const TaskModal = (props) => {
onClose={props.handleClose} onClose={props.handleClose}
open={props.open} open={props.open}
> >
{ props?.task?.isEditMode ? {props?.task?.isEditMode ? (
<div className="modalBox"> <div className="modalBox">
<Input <Input
value={taskContent?.title} value={props.task.title}
name={"title"} name="title"
onChange={inputChangeHandler} onChange={(e) => props.onChange(e, props.task)}
style={{ width: "auto", fontSize:"12px",color: "white",fontWeight: "600" }} style={{
width: "auto",
fontSize: "12px",
color: "white",
fontWeight: "600",
}}
/> />
<Input <Input
value={taskContent?.description} value={props.task.description}
name={"description"} name="description"
onChange={inputChangeHandler} onChange={(e) => props.onChange(e, props.task)}
style={{ width: "auto", fontSize:"12px",color: "white" }} style={{ width: "auto", fontSize: "12px", color: "white" }}
/> />
<IconButton <IconButton aria-label="done" onClick={props.handleClose}>
aria-label="done" <Done />
onClick={saveModalData}
>
<Done/>
</IconButton> </IconButton>
</div>: </div>
) : (
<div className="modalBox"> <div className="modalBox">
{ props.task && props.task.title && ( {props.task && props.task.title && (
<div <div
style={{ style={{
width: "200px", width: "200px",
height: "200px", height: "200px",
color: "white", color: "white",
fontWeight: "600" fontWeight: "600",
}} }}
> >
{props.task.title} {props.task.title}
...@@ -88,9 +63,9 @@ const TaskModal = (props) => { ...@@ -88,9 +63,9 @@ const TaskModal = (props) => {
X X
</IconButton> </IconButton>
</div> </div>
} )}
</Modal> </Modal>
); );
}; };
export default TaskModal; export default TaskModal;
import * as React from 'react';
import TextField from '@mui/material/TextField';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
import { useState, useEffect } from "react";
import dayjs from 'dayjs';
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
export default function MaterialUIPickers(props) {
console.log(props)
if (props.task.dateTimeStart!==undefined)
return (
<LocalizationProvider dateAdapter={AdapterMoment}>
<DateTimePicker
renderInput={(params) => (
<TextField {...params} name="dateCreated" />
)}
value={
props.newStartedDate && props.newStartedDate.id === props.task.id? props.newStartedDate.date
: props.task.dateTimeStart
}
onChange={(newValue) => {
props.setNewStartedDate({
id: props.task.id,
date: newValue,
});
}}
/>
</LocalizationProvider>
);
else if(props.task.dateTimeDue!==undefined) {
return (
<LocalizationProvider dateAdapter={AdapterMoment}>
<DateTimePicker
renderInput={(params) => (
<TextField {...params} name="dateCreated" />
)}
value={
props.newDueDate && props.newDueDate.id === props.task.id? props.newDueDate.date
: props.task.dateTimeDue
}
onChange={(newValue) => {
props.setNewDueDate({
id: props.task.id,
date: newValue,
});
}}
/>
</LocalizationProvider>
);
}
}
\ No newline at end of file
import * as React from "react";
import Box from "@mui/material/Box";
import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select";
export default function BasicSelect(props) {
return (
<Box sx={{ minWidth: 60 }}>
<FormControl fullWidth>
<InputLabel id="demo-simple-select-label"></InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={props.task.accomplish}
label=""
name={"accomplish"}
onChange={(e) => props.onChange(e, props.task)}
sx={{ marginTop: 2 }}
>
{props.items.map((item) => (
<MenuItem value={item}>{item}</MenuItem>
))}
</Select>
</FormControl>
</Box>
);
}
...@@ -40,12 +40,14 @@ const UserRegistrationForm = ({ state, onChange, onSubmit, getFieldError, button ...@@ -40,12 +40,14 @@ const UserRegistrationForm = ({ state, onChange, onSubmit, getFieldError, button
state={state} state={state}
error={getFieldError?.("password")} error={getFieldError?.("password")}
/> />
{/* <FormElement <FormElement
onChange={onChange} onChange={onChange}
name="displayName" name="confirmPassword"
label="DisplayName" label="Confirm password"
type="password"
state={state} state={state}
/> */} error={getFieldError?.("password")}
/>
{/* <FormElement {/* <FormElement
onChange={fileChangeHandler} onChange={fileChangeHandler}
name="avatar" name="avatar"
......
...@@ -22,41 +22,41 @@ const headCells = [ ...@@ -22,41 +22,41 @@ const headCells = [
label: 'Приоритет', label: 'Приоритет',
}, },
{ {
id: 'date', id: 'createdAt',
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Дата', label: 'Дата создания',
}, },
{ {
id: 'task', id: 'title',
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Задача', label: 'Заголовок',
}, },
{ {
id: 'author', id: 'authorDisplayName',
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Автор', label: 'Автор',
}, },
{ {
id: 'startDate', id: 'dateTimeStart',
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Дата начала', label: 'Дата начала',
}, },
{ {
id: 'endDate', id: 'dateTimeDue',
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Дата завершения', label: 'Дата завершения',
}, },
{ {
id: 'done', id: 'accomplish',
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Выполнено', label: 'Статус',
}, },
{ {
id: 'change', id: 'change',
...@@ -115,4 +115,3 @@ EnhancedTableHead.propTypes = { ...@@ -115,4 +115,3 @@ EnhancedTableHead.propTypes = {
orderBy: PropTypes.string.isRequired, orderBy: PropTypes.string.isRequired,
rowCount: PropTypes.number.isRequired, rowCount: PropTypes.number.isRequired,
}; };
...@@ -3,7 +3,7 @@ import { useDispatch, useSelector } from "react-redux"; ...@@ -3,7 +3,7 @@ import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import Loader from "../../components/UI/Loader/Loader"; import Loader from "../../components/UI/Loader/Loader";
import UserForm from "../../components/UserForm/UserRegistrationForm"; import UserForm from "../../components/UserForm/UserRegistrationForm";
import { loginUser, registerUser } from "../../store/actions/usersActions"; import { registerUser } from "../../store/actions/usersActions";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { Avatar, Container, Typography } from "@mui/material"; import { Avatar, Container, Typography } from "@mui/material";
import LockIcon from "@mui/icons-material/Lock"; import LockIcon from "@mui/icons-material/Lock";
...@@ -28,6 +28,7 @@ const Register = () => { ...@@ -28,6 +28,7 @@ const Register = () => {
email: "", email: "",
// number: "", // number: "",
password: '', password: '',
confirmPassword: "",
// avatar: "", // avatar: "",
}); });
...@@ -64,8 +65,12 @@ const Register = () => { ...@@ -64,8 +65,12 @@ const Register = () => {
formData.append(key, state[key]); formData.append(key, state[key]);
console.log("key " + key + "state " + state[key]) console.log("key " + key + "state " + state[key])
}) })
if (state["password"] === state["confirmPassword"]) {
await dispatch(registerUser(formData, navigate)); await dispatch(registerUser(formData, navigate));
// dispatch(loginUser(state, navigate)) } else {
alert("Пароли не совпадают")
}
}; };
const getFieldError = (fieldname) => { const getFieldError = (fieldname) => {
......
...@@ -2,6 +2,8 @@ export const FETCH_CALENDAR_TASKS_REQUEST = "FETCH_CALENDAR_TASKS_REQUEST"; ...@@ -2,6 +2,8 @@ export const FETCH_CALENDAR_TASKS_REQUEST = "FETCH_CALENDAR_TASKS_REQUEST";
export const FETCH_CALENDAR_TASKS_SUCCESS = "FETCH_CALENDAR_TASKS_SUCCESS"; export const FETCH_CALENDAR_TASKS_SUCCESS = "FETCH_CALENDAR_TASKS_SUCCESS";
export const FETCH_CALENDAR_TASKS_FAILURE = "FETCH_CALENDAR_TASKS_FAILURE"; export const FETCH_CALENDAR_TASKS_FAILURE = "FETCH_CALENDAR_TASKS_FAILURE";
export const FETCH_ALL_TASKS_SUCCESS = "FETCH_ALL_TASKS_SUCCESS";
export const ADD_NEW_TASK_REQUEST = "ADD_NEW_TASK_REQUEST"; export const ADD_NEW_TASK_REQUEST = "ADD_NEW_TASK_REQUEST";
export const ADD_NEW_TASK_SUCCESS = "ADD_NEW_TASK_SUCCESS"; export const ADD_NEW_TASK_SUCCESS = "ADD_NEW_TASK_SUCCESS";
export const ADD_NEW_TASK_FAILURE = "ADD_NEW_TASK_FAILURE"; export const ADD_NEW_TASK_FAILURE = "ADD_NEW_TASK_FAILURE";
......
...@@ -10,7 +10,8 @@ import { ...@@ -10,7 +10,8 @@ import {
EDIT_TASK_SUCCESS, EDIT_TASK_SUCCESS,
FETCH_CALENDAR_TASKS_FAILURE, FETCH_CALENDAR_TASKS_FAILURE,
FETCH_CALENDAR_TASKS_REQUEST, FETCH_CALENDAR_TASKS_REQUEST,
FETCH_CALENDAR_TASKS_SUCCESS} from "../actionTypes/tasksTypes"; FETCH_CALENDAR_TASKS_SUCCESS,
FETCH_ALL_TASKS_SUCCESS} from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner' import axios from '../../axiosPlanner'
const fetchCalendarTasksRequest = () => { const fetchCalendarTasksRequest = () => {
...@@ -21,6 +22,11 @@ const fetchCalendarTasksSuccess = (tasks) => { ...@@ -21,6 +22,11 @@ const fetchCalendarTasksSuccess = (tasks) => {
return {type: FETCH_CALENDAR_TASKS_SUCCESS, tasks} return {type: FETCH_CALENDAR_TASKS_SUCCESS, tasks}
}; };
const fetchAllTasksSuccess = (tasks) => {
return {type: FETCH_ALL_TASKS_SUCCESS, tasks}
};
const fetchCalendarTasksFailure = (error) => { const fetchCalendarTasksFailure = (error) => {
return {type: FETCH_CALENDAR_TASKS_FAILURE, error} return {type: FETCH_CALENDAR_TASKS_FAILURE, error}
}; };
...@@ -35,8 +41,18 @@ export const fetchCalendarTasks = () => { ...@@ -35,8 +41,18 @@ export const fetchCalendarTasks = () => {
dispatch(fetchCalendarTasksFailure(error.response.data)); dispatch(fetchCalendarTasksFailure(error.response.data));
} }
} }
} };
export const fetchAllTasks = () => {
return async (dispatch) => {
dispatch(fetchCalendarTasksRequest());
try {
const response = await axios.get("/tasks");
dispatch(fetchAllTasksSuccess(response.data.tasks))
} catch (error) {
dispatch(fetchCalendarTasksFailure(error.response.data));
}
}
};
const addTaskRequest = () => { const addTaskRequest = () => {
return {type: ADD_NEW_TASK_REQUEST} return {type: ADD_NEW_TASK_REQUEST}
}; };
...@@ -84,12 +100,15 @@ export const editTask = (task) => { ...@@ -84,12 +100,15 @@ export const editTask = (task) => {
dispatch(editTaskRequest()); dispatch(editTaskRequest());
const token = getState().users?.user?.token; const token = getState().users?.user?.token;
try { try {
await axios.put("/tasks", task, { console.log(task)
const r=await axios.put("/tasks", task, {
headers: { headers: {
'Authorization': 'IwGVRaksGTWtnKlOZd7zJ' 'Authorization': 'IwGVRaksGTWtnKlOZd7zJ'
} }
}); });
console.log(r)
dispatch(editTaskSuccess()) dispatch(editTaskSuccess())
dispatch(fetchAllTasks())
dispatch(fetchCalendarTasks()) dispatch(fetchCalendarTasks())
} catch (error) { } catch (error) {
dispatch(editTaskFailure(error.response.data)); dispatch(editTaskFailure(error.response.data));
...@@ -121,6 +140,7 @@ export const deleteTask = (taskId) => { ...@@ -121,6 +140,7 @@ export const deleteTask = (taskId) => {
}); });
dispatch(deleteTaskSuccess()) dispatch(deleteTaskSuccess())
dispatch(fetchCalendarTasks()) dispatch(fetchCalendarTasks())
dispatch(fetchAllTasks())
} catch (error) { } catch (error) {
dispatch(deleteTaskFailure(error.response.data)); dispatch(deleteTaskFailure(error.response.data));
} }
......
...@@ -20,6 +20,7 @@ export const registerUser = (userData, navigate) => { ...@@ -20,6 +20,7 @@ export const registerUser = (userData, navigate) => {
try { try {
console.log("register " + userData) console.log("register " + userData)
const response = await axios.post("/users", userData); const response = await axios.post("/users", userData);
console.log(response)
dispatch(registerUserSuccess()) dispatch(registerUserSuccess())
navigate("/") navigate("/")
} catch (error) { } catch (error) {
......
...@@ -10,7 +10,8 @@ import { ...@@ -10,7 +10,8 @@ import {
FETCH_CALENDAR_TASKS_SUCCESS, FETCH_CALENDAR_TASKS_SUCCESS,
DELETE_TASK_SUCCESS, DELETE_TASK_SUCCESS,
DELETE_TASK_REQUEST, DELETE_TASK_REQUEST,
DELETE_TASK_FAILURE} from "../actionTypes/tasksTypes"; DELETE_TASK_FAILURE,
FETCH_ALL_TASKS_SUCCESS} from "../actionTypes/tasksTypes";
const initialState = { const initialState = {
calendarTasks: [], calendarTasks: [],
...@@ -51,6 +52,8 @@ const tasksReduсer = (state = initialState, action) => { ...@@ -51,6 +52,8 @@ const tasksReduсer = (state = initialState, action) => {
} }
}) })
return {...state, loading: false, calendarTasks: newArr}; return {...state, loading: false, calendarTasks: newArr};
case FETCH_ALL_TASKS_SUCCESS:
return {...state, loading: false, tasks: action.tasks};
case FETCH_CALENDAR_TASKS_FAILURE: case FETCH_CALENDAR_TASKS_FAILURE:
return {...state, loading: false, error: action.error}; return {...state, loading: false, error: action.error};
case ADD_NEW_TASK_SUCCESS: case ADD_NEW_TASK_SUCCESS:
......
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