Commit 6a213935 authored by Нелли Ибрагимова's avatar Нелли Ибрагимова

Merge branch 'task-53-fix/put_task_repair' into 'development'

Task 53 fix/put task repair

See merge request !36
parents 87084c37 e5dc1552
...@@ -21,7 +21,7 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => { ...@@ -21,7 +21,7 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => {
const App = () => { const App = () => {
const user = useSelector(state => state.users?.user); const user = useSelector(state => state.users?.user);
console.log(user)
return ( return (
<BrowserRouter> <BrowserRouter>
<Routes> <Routes>
......
...@@ -10,7 +10,7 @@ const AdminMenu = () => { ...@@ -10,7 +10,7 @@ const AdminMenu = () => {
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const user = useSelector(state => state.users.user) const user = useSelector(state => state.users.user)
console.log(user)
const handleClick = (event) => { const handleClick = (event) => {
setAnchorEl(event.currentTarget); setAnchorEl(event.currentTarget);
}; };
......
...@@ -2,7 +2,13 @@ import * as React from "react"; ...@@ -2,7 +2,13 @@ import * as React from "react";
import TableCell from "@mui/material/TableCell"; import TableCell from "@mui/material/TableCell";
import Input from "@mui/material/Input"; import Input from "@mui/material/Input";
const CustomTableCell = ({ task, name, value, onChange, onModalOpen }) => { const CustomTableCell = ({task,
name,
value,
onChange,
onModalOpen,
placeholder,
}) => {
const styles = { width: "auto", height: "10px"}; const styles = { width: "auto", height: "10px"};
if (task) { if (task) {
...@@ -15,6 +21,7 @@ const CustomTableCell = ({ task, name, value, onChange, onModalOpen }) => { ...@@ -15,6 +21,7 @@ const CustomTableCell = ({ task, name, value, onChange, onModalOpen }) => {
> >
{task.isEditMode && onChange ? ( {task.isEditMode && onChange ? (
<Input <Input
placeholder={placeholder}
value={value} value={value}
name={name} name={name}
onChange={(e) => onChange(e, task)} onChange={(e) => onChange(e, task)}
......
...@@ -4,6 +4,7 @@ import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; ...@@ -4,6 +4,7 @@ import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker"; import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment"; import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
export default function MaterialUIPickers(props) { export default function MaterialUIPickers(props) {
return ( return (
<LocalizationProvider <LocalizationProvider
...@@ -11,6 +12,7 @@ export default function MaterialUIPickers(props) { ...@@ -11,6 +12,7 @@ export default function MaterialUIPickers(props) {
sx={{ width: "auto", fontSize: 5, fontWeight: "200" }} sx={{ width: "auto", fontSize: 5, fontWeight: "200" }}
> >
<DateTimePicker <DateTimePicker
inputFormat="DD-MM-YYYY hh:mm A"
disabled={props.task.readOnly} disabled={props.task.readOnly}
renderInput={(params) => ( renderInput={(params) => (
<TextField <TextField
......
...@@ -5,22 +5,26 @@ import Toolbar from '@mui/material/Toolbar'; ...@@ -5,22 +5,26 @@ import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect'; import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect';
import Add from "@mui/icons-material/Add";
import Close from "@mui/icons-material/Close";
export default function MyTaskToolBar(props) { export default function MyTaskToolBar({projects,onClose,projectName,setProjectName,formStatus,onClick}) {
let projectsFilter = let projectsFilter =
<></> <></>
if (props.projects) {
if (projects) {
projectsFilter= projectsFilter=
<MultipleSelect <MultipleSelect
projects={props.projects} projects={projects}
onClose={props.onClose} onClose={onClose}
projectName={props.projectName} projectName={projectName}
setProjectName={props.setProjectName} setProjectName={setProjectName}
/> />
} }
return ( return (
<Box sx={{ flexGrow: 1 }}> <Box sx={{ flexGrow: 1 }}>
<AppBar position="static"> <AppBar position="static">
<Toolbar> <Toolbar>
...@@ -28,9 +32,31 @@ export default function MyTaskToolBar(props) { ...@@ -28,9 +32,31 @@ export default function MyTaskToolBar(props) {
Мои задачи Мои задачи
</Typography> </Typography>
{projectsFilter} {projectsFilter}
<Button color="inherit" onClick={()=>(props.onClick)} >Добавить задачу</Button>
<Button
color={formStatus === true ? "info" : "inherit"}
style={{
backgroundColor: formStatus === true ? "white" : "inherit",
}}
onClick={onClick}
>
{formStatus === true ? (
<>
<Close />
<span style={{ lineHeight: "16px" }}>Скрыть задачу</span>
</>
) : (
<>
<Add />
<span style={{ lineHeight: "16px" }}>Добавить задачу</span>
</>
)}
</Button>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
</Box> </Box>
); );
} }
...@@ -28,16 +28,15 @@ function getStyles(name, personName, theme) { ...@@ -28,16 +28,15 @@ function getStyles(name, personName, theme) {
}; };
} }
export default function MultipleSelect(props) { export default function MultipleSelect({projects,projectName,onClose,setProjectName}) {
const theme = useTheme(); const theme = useTheme();
const handleChange = (event) => { const handleChange = (event) => {
const { const {
target: { value }, target: { value },
} = event; } = event;
props.setProjectName( setProjectName(
// On autofill we get a stringified value. // On autofill we get a stringified value.
typeof value === 'string' ? value.split(',') : value, typeof value === 'string' ? value.split(',') : value,
); );
...@@ -53,18 +52,18 @@ export default function MultipleSelect(props) { ...@@ -53,18 +52,18 @@ export default function MultipleSelect(props) {
name='Choose Project' name='Choose Project'
id="demo-multiple-name" id="demo-multiple-name"
multiple multiple
value={props.projectName} value={projectName}
onChange={handleChange} onChange={handleChange}
input={<OutlinedInput label="Name" />} input={<OutlinedInput label="Name" />}
MenuProps={MenuProps} MenuProps={MenuProps}
sx={{color:'white' }} sx={{color:'white' }}
onClose={(e)=>{props.onClose(props.projectName)}} onClose={(e)=>{onClose(projectName)}}
> >
{props.projects.map((project) => ( {projects?.map((project) => (
<MenuItem <MenuItem
key={project} key={project}
value={project} value={project}
style={getStyles(project, props.projectName, theme)} style={getStyles(project, projectName, theme)}
> >
{project} {project}
</MenuItem> </MenuItem>
......
...@@ -5,7 +5,8 @@ import MenuItem from "@mui/material/MenuItem"; ...@@ -5,7 +5,8 @@ import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl"; import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select"; import Select from "@mui/material/Select";
export default function BasicSelect(props) { export default function BasicSelect({value,label,name,onChange,task,items}) {
return ( return (
<Box sx={{ minWidth: 60 }}> <Box sx={{ minWidth: 60 }}>
<FormControl fullWidth> <FormControl fullWidth>
...@@ -13,17 +14,19 @@ export default function BasicSelect(props) { ...@@ -13,17 +14,19 @@ export default function BasicSelect(props) {
<Select <Select
labelId="demo-simple-select-label" labelId="demo-simple-select-label"
id="demo-simple-select" id="demo-simple-select"
value={props.task.accomplish} value={value}
label="" label={label}
name={"accomplish"} name={name}
onChange={(e) => props.onChange(e, props.task)} onChange={(e) => onChange(e, task)}
sx={{ marginTop: 2 }}
> >
{props.items.map((item) => ( {items.map((item) => (
<MenuItem value={item}>{item}</MenuItem> <MenuItem key={item.value} value={item.value}>
{item.title}
</MenuItem>
))} ))}
</Select> </Select>
</FormControl> </FormControl>
</Box> </Box>
); );
} }
import * as React from 'react'; import * as React from "react";
import PropTypes from 'prop-types'; import PropTypes from "prop-types";
import Box from '@mui/material/Box'; import Box from "@mui/material/Box";
import TableCell from '@mui/material/TableCell'; import TableCell from "@mui/material/TableCell";
import TableHead from '@mui/material/TableHead'; import TableHead from "@mui/material/TableHead";
import TableRow from '@mui/material/TableRow'; import TableRow from "@mui/material/TableRow";
import TableSortLabel from '@mui/material/TableSortLabel'; import TableSortLabel from "@mui/material/TableSortLabel";
import { visuallyHidden } from '@mui/utils'; import { visuallyHidden } from "@mui/utils";
const headCells = [ const headCells = [
{ {
id: 'id', id: "id",
numeric: true, numeric: true,
disablePadding: true, disablePadding: true,
label: '', label: "",
}, },
{ {
id: 'priority', id: "priority",
numeric: false, numeric: false,
disablePadding: true, disablePadding: true,
label: 'Приоритет', label: "Приоритет",
}, },
{ {
id: 'createdAt', id: "createdAt",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Дата создания', label: "Дата создания",
}, },
{ {
id: 'title', id: "title",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Заголовок', label: "Заголовок",
}, },
{ {
id: 'project', id: "projectName",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Проект', label: "Проект",
}, },
{ {
id: 'authorDisplayName', id: "authorDisplayName",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Автор', label: "Автор",
}, },
{ {
id: 'dateTimeStart', id: "dateTimeStart",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Дата начала', label: "Дата начала",
}, },
{ {
id: 'dateTimeDue', id: "dateTimeDue",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Дата завершения', label: "Дата завершения",
}, },
{ {
id: 'accomplish', id: "accomplish",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: 'Статус', label: "Статус",
}, },
{ {
id: 'change', id: "change",
numeric: false, numeric: false,
disablePadding: false, disablePadding: false,
label: '', label: "",
}, },
{ {
id: 'delete', id: "delete",
numeric: false, numeric: false,
disablePadding: false, disablePadding: false,
label: '', label: "",
}, },
]; ];
export default function EnhancedTableHead(props) { export default function EnhancedTableHead({ order, orderBy, rowCount, onRequestSort }) {
const { order, orderBy, rowCount, onRequestSort } =
props;
const createSortHandler = (property) => (event) => { const createSortHandler = (property) => (event) => {
onRequestSort(event, property); onRequestSort(event, property);
}; };
...@@ -88,23 +86,22 @@ export default function EnhancedTableHead(props) { ...@@ -88,23 +86,22 @@ export default function EnhancedTableHead(props) {
return ( return (
<TableHead> <TableHead>
<TableRow> <TableRow>
{headCells.map((headCell) => ( {headCells.map((headCell) => (
<TableCell <TableCell
key={headCell.id} key={headCell.id}
align={'center'} align={"center"}
padding={headCell.disablePadding ? 'none' : 'normal'} padding={headCell.disablePadding ? "none" : "normal"}
sortDirection={orderBy === headCell.id ? order : false} sortDirection={orderBy === headCell.id ? order : false}
> >
<TableSortLabel <TableSortLabel
active={orderBy === headCell.id} active={orderBy === headCell.id}
direction={orderBy === headCell.id ? order : 'asc'} direction={orderBy === headCell.id ? order : "asc"}
onClick={createSortHandler(headCell.id)} onClick={createSortHandler(headCell.id)}
> >
{headCell.label} {headCell.label}
{orderBy === headCell.id ? ( {orderBy === headCell.id ? (
<Box component="span" sx={visuallyHidden}> <Box component="span" sx={visuallyHidden}>
{order === 'desc' ? 'sorted descending' : 'sorted ascending'} {order === "desc" ? "sorted descending" : "sorted ascending"}
</Box> </Box>
) : null} ) : null}
</TableSortLabel> </TableSortLabel>
...@@ -117,7 +114,7 @@ export default function EnhancedTableHead(props) { ...@@ -117,7 +114,7 @@ export default function EnhancedTableHead(props) {
EnhancedTableHead.propTypes = { EnhancedTableHead.propTypes = {
onRequestSort: PropTypes.func.isRequired, onRequestSort: PropTypes.func.isRequired,
order: PropTypes.oneOf(['asc', 'desc']).isRequired, order: PropTypes.oneOf(["asc", "desc"]).isRequired,
orderBy: PropTypes.string.isRequired, orderBy: PropTypes.string.isRequired,
// rowCount: PropTypes.number.isRequired, rowCount: PropTypes.number.isRequired,
}; };
...@@ -69,6 +69,25 @@ const addTaskFailure = (error) => { ...@@ -69,6 +69,25 @@ const addTaskFailure = (error) => {
return {type: ADD_NEW_TASK_FAILURE, error} return {type: ADD_NEW_TASK_FAILURE, error}
}; };
// export const addTask = (task) => {
// return async (dispatch, getState) => {
// dispatch(addTaskRequest());
// const token = getState().users?.user?.token;
// try {
// await axios.post("/tasks", task, {
// headers: {
// Authorization: token,
// },
// });
// dispatch(addTaskSuccess());
// dispatch(fetchCalendarTasks());
// } catch (error) {
// dispatch(addTaskFailure(error.response.data));
// }
// };
// };
export const addTask = (task) => { export const addTask = (task) => {
return async (dispatch, getState) => { return async (dispatch, getState) => {
dispatch(addTaskRequest()); dispatch(addTaskRequest());
...@@ -76,6 +95,7 @@ export const addTask = (task) => { ...@@ -76,6 +95,7 @@ export const addTask = (task) => {
try { try {
await axios.post("/tasks", task); await axios.post("/tasks", task);
dispatch(addTaskSuccess()) dispatch(addTaskSuccess())
dispatch(fetchAllTasks())
dispatch(fetchCalendarTasks()) dispatch(fetchCalendarTasks())
} catch (error) { } catch (error) {
dispatch(addTaskFailure(error.response.data)); dispatch(addTaskFailure(error.response.data));
......
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