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