Merge branch 'task-123-fix/invalid_Date' into 'development'

Task 123 fix/invalid date

See merge request !106
parents fe112b78 f847a801
...@@ -34,6 +34,7 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{ ...@@ -34,6 +34,7 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
dateTimeDueFinal = dateTimeDeadLine dateTimeDueFinal = dateTimeDeadLine
dateTimeStartFinal = subtractHours(dateTimeDueFinal, 1) dateTimeStartFinal = subtractHours(dateTimeDueFinal, 1)
} }
console.log('datTeimeDeadLine ', dateTimeDeadLine)
const newTask = new Task(); const newTask = new Task();
newTask.title = title; newTask.title = title;
...@@ -216,7 +217,6 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{ ...@@ -216,7 +217,6 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
) )
const projectsList= projectsRawId.map(project=> {return project.id}) const projectsList= projectsRawId.map(project=> {return project.id})
const tasks = await dataSource const tasks = await dataSource
.getRepository(Task) .getRepository(Task)
.find( .find(
...@@ -229,6 +229,9 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{ ...@@ -229,6 +229,9 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
executor:{ executor:{
id:user.id id:user.id
}, },
project:{
id:In(projectsList)
}
} }
} }
) )
...@@ -310,6 +313,10 @@ router.put('/:taskId',auth,authAuthorOrExecutorOfTask,async(req:Request, res:Res ...@@ -310,6 +313,10 @@ router.put('/:taskId',auth,authAuthorOrExecutorOfTask,async(req:Request, res:Res
dateTimeDue,executor,accomplish,dateTimeDeadLine, dateTimeFactDeadLine,priority} = req.body; dateTimeDue,executor,accomplish,dateTimeDeadLine, dateTimeFactDeadLine,priority} = req.body;
const task = await taskFinderById(taskId) const task = await taskFinderById(taskId)
if (!task) return res.status(404).send({Message:'task not found'}) if (!task) return res.status(404).send({Message:'task not found'})
console.log ('dateTimeDeadLine ', dateTimeDeadLine,'authorStatus '
,authorStatus,'executorStatus ',executorStatus)
let dateTimeTask = null; let dateTimeTask = null;
if (dateTimeTaskId) { if (dateTimeTaskId) {
const dateTimeTaskData = await dataSource const dateTimeTaskData = await dataSource
...@@ -391,6 +398,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp ...@@ -391,6 +398,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
}, },
where:{ where:{
members:{ members:{
roleProject:Not(Equal(MemberRole.WATCHER)),
user:{ user:{
id:user.id id:user.id
}, },
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"moment": "^2.29.4", "moment": "^2.29.4",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-datepicker": "^4.8.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^8.0.4", "react-redux": "^8.0.4",
"react-router-dom": "^6.4.2", "react-router-dom": "^6.4.2",
...@@ -6217,6 +6218,11 @@ ...@@ -6217,6 +6218,11 @@
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz",
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==" "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA=="
}, },
"node_modules/classnames": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz",
"integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw=="
},
"node_modules/clean-css": { "node_modules/clean-css": {
"version": "5.3.1", "version": "5.3.1",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz",
...@@ -6922,6 +6928,18 @@ ...@@ -6922,6 +6928,18 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/date-fns": {
"version": "2.29.3",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz",
"integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==",
"engines": {
"node": ">=0.11"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/date-fns"
}
},
"node_modules/dayjs": { "node_modules/dayjs": {
"version": "1.11.6", "version": "1.11.6",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.6.tgz", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.6.tgz",
...@@ -15237,6 +15255,23 @@ ...@@ -15237,6 +15255,23 @@
"node": ">=14" "node": ">=14"
} }
}, },
"node_modules/react-datepicker": {
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-4.8.0.tgz",
"integrity": "sha512-u69zXGHMpxAa4LeYR83vucQoUCJQ6m/WBsSxmUMu/M8ahTSVMMyiyQzauHgZA2NUr9y0FUgOAix71hGYUb6tvg==",
"dependencies": {
"@popperjs/core": "^2.9.2",
"classnames": "^2.2.6",
"date-fns": "^2.24.0",
"prop-types": "^15.7.2",
"react-onclickoutside": "^6.12.0",
"react-popper": "^2.2.5"
},
"peerDependencies": {
"react": "^16.9.0 || ^17 || ^18",
"react-dom": "^16.9.0 || ^17 || ^18"
}
},
"node_modules/react-dev-utils": { "node_modules/react-dev-utils": {
"version": "12.0.1", "version": "12.0.1",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz",
...@@ -15371,11 +15406,43 @@ ...@@ -15371,11 +15406,43 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
"integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg=="
}, },
"node_modules/react-fast-compare": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz",
"integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA=="
},
"node_modules/react-is": { "node_modules/react-is": {
"version": "17.0.2", "version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
}, },
"node_modules/react-onclickoutside": {
"version": "6.12.2",
"resolved": "https://registry.npmjs.org/react-onclickoutside/-/react-onclickoutside-6.12.2.tgz",
"integrity": "sha512-NMXGa223OnsrGVp5dJHkuKxQ4czdLmXSp5jSV9OqiCky9LOpPATn3vLldc+q5fK3gKbEHvr7J1u0yhBh/xYkpA==",
"funding": {
"type": "individual",
"url": "https://github.com/Pomax/react-onclickoutside/blob/master/FUNDING.md"
},
"peerDependencies": {
"react": "^15.5.x || ^16.x || ^17.x || ^18.x",
"react-dom": "^15.5.x || ^16.x || ^17.x || ^18.x"
}
},
"node_modules/react-popper": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.3.0.tgz",
"integrity": "sha512-e1hj8lL3uM+sgSR4Lxzn5h1GxBlpa4CQz0XLF8kx4MDrDRWY0Ena4c97PUeSX9i5W3UAfDP0z0FXCTQkoXUl3Q==",
"dependencies": {
"react-fast-compare": "^3.0.1",
"warning": "^4.0.2"
},
"peerDependencies": {
"@popperjs/core": "^2.0.0",
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
}
},
"node_modules/react-redux": { "node_modules/react-redux": {
"version": "8.0.4", "version": "8.0.4",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.4.tgz", "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.4.tgz",
...@@ -17569,6 +17636,14 @@ ...@@ -17569,6 +17636,14 @@
"makeerror": "1.0.12" "makeerror": "1.0.12"
} }
}, },
"node_modules/warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"dependencies": {
"loose-envify": "^1.0.0"
}
},
"node_modules/watchpack": { "node_modules/watchpack": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
...@@ -22790,6 +22865,11 @@ ...@@ -22790,6 +22865,11 @@
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz",
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==" "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA=="
}, },
"classnames": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz",
"integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw=="
},
"clean-css": { "clean-css": {
"version": "5.3.1", "version": "5.3.1",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz",
...@@ -23298,6 +23378,11 @@ ...@@ -23298,6 +23378,11 @@
"whatwg-url": "^8.0.0" "whatwg-url": "^8.0.0"
} }
}, },
"date-fns": {
"version": "2.29.3",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz",
"integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA=="
},
"dayjs": { "dayjs": {
"version": "1.11.6", "version": "1.11.6",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.6.tgz", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.6.tgz",
...@@ -29181,6 +29266,19 @@ ...@@ -29181,6 +29266,19 @@
"whatwg-fetch": "^3.6.2" "whatwg-fetch": "^3.6.2"
} }
}, },
"react-datepicker": {
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-4.8.0.tgz",
"integrity": "sha512-u69zXGHMpxAa4LeYR83vucQoUCJQ6m/WBsSxmUMu/M8ahTSVMMyiyQzauHgZA2NUr9y0FUgOAix71hGYUb6tvg==",
"requires": {
"@popperjs/core": "^2.9.2",
"classnames": "^2.2.6",
"date-fns": "^2.24.0",
"prop-types": "^15.7.2",
"react-onclickoutside": "^6.12.0",
"react-popper": "^2.2.5"
}
},
"react-dev-utils": { "react-dev-utils": {
"version": "12.0.1", "version": "12.0.1",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz",
...@@ -29281,11 +29379,31 @@ ...@@ -29281,11 +29379,31 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
"integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg=="
}, },
"react-fast-compare": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz",
"integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA=="
},
"react-is": { "react-is": {
"version": "17.0.2", "version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
}, },
"react-onclickoutside": {
"version": "6.12.2",
"resolved": "https://registry.npmjs.org/react-onclickoutside/-/react-onclickoutside-6.12.2.tgz",
"integrity": "sha512-NMXGa223OnsrGVp5dJHkuKxQ4czdLmXSp5jSV9OqiCky9LOpPATn3vLldc+q5fK3gKbEHvr7J1u0yhBh/xYkpA==",
"requires": {}
},
"react-popper": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.3.0.tgz",
"integrity": "sha512-e1hj8lL3uM+sgSR4Lxzn5h1GxBlpa4CQz0XLF8kx4MDrDRWY0Ena4c97PUeSX9i5W3UAfDP0z0FXCTQkoXUl3Q==",
"requires": {
"react-fast-compare": "^3.0.1",
"warning": "^4.0.2"
}
},
"react-redux": { "react-redux": {
"version": "8.0.4", "version": "8.0.4",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.4.tgz", "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.4.tgz",
...@@ -30889,6 +31007,14 @@ ...@@ -30889,6 +31007,14 @@
"makeerror": "1.0.12" "makeerror": "1.0.12"
} }
}, },
"warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"requires": {
"loose-envify": "^1.0.0"
}
},
"watchpack": { "watchpack": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
import React, {useState} from 'react';
import DatePicker from "react-datepicker";
const DateTimePicker =({task,name,onChange}) => {
const [startDate, setStartDate] = useState(new Date());
return (
<>
<DatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
// locale="ru"
showTimeSelect
timeFormat="p"
timeIntervals={60}
dateFormat="Pp"
/>
</>
);
};
export default DateTimePicker;
...@@ -25,6 +25,15 @@ const CustomTableCell = ({ ...@@ -25,6 +25,15 @@ const CustomTableCell = ({
flexDirection: "column", flexDirection: "column",
fontSize: "12px", fontSize: "12px",
}; };
// if (name==='dateTimeDeadLine'){
// console.log('dateTimeDeadLine ', name, ' ', value)
// }
const divTwoStyle = {
display: "flex",
flexDirection: "row",
fontSize: "12px",
};
const duration = moment.duration( const duration = moment.duration(
moment(task?.dateTimeTasks[0]?.dateTimeDue).diff( moment(task?.dateTimeTasks[0]?.dateTimeDue).diff(
...@@ -55,10 +64,17 @@ const CustomTableCell = ({ ...@@ -55,10 +64,17 @@ const CustomTableCell = ({
/> />
) : name !== "dateTimeStart" ? ( ) : name !== "dateTimeStart" ? (
<span>{value}</span> <span>{value}</span>
) : ( ) :name === "dateTimeDeadLine"&& value==='Invalid date' ?
<span>''</span>
:(
<div style={divStyle}> <div style={divStyle}>
<span>{value}</span> <div style={divTwoStyle}>
<span>{value2}</span> <span title={
moment(task.dateTimeTasks[0]?.dateTimeStart)
.utc()
.format("DD/MM/YY")}
>{value}</span> <span> &nbsp;</span>
<span>({value2})</span></div>
<span>часы:{hours}</span> <span>часы:{hours}</span>
</div> </div>
)} )}
......
import * as React from "react"; import React, {useState} from "react";
import TextField from "@mui/material/TextField"; import TextField from "@mui/material/TextField";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; 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";
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import moment from "moment";
export default function MaterialUIPickers(props) {
export default function MaterialUIPickers({task, name,onChange, }) {
const [state, setState]=useState(null)
let fullYear = new Date().getFullYear()
let month = new Date().getMonth()
let day = new Date().getDate();
console.log('datepicker inside task', task, 'state ', state)
return ( return (
<LocalizationProvider <LocalizationProvider
dateAdapter={AdapterMoment} dateAdapter={AdapterMoment}
sx={{ width: "100%", fontSize: 5, fontWeight: "200" }} sx={{ width: "100%", fontSize: 5, fontWeight: "200" }}
adapterLocale={'ru-RU'}
> >
<DateTimePicker <DateTimePicker
inputFormat="DD-MM-YY kk:mm A" minTime={moment({year:fullYear,month:month,day:day ,hour:11,minute:0})}
disabled={props.task.readOnly} maxTime={moment({year:fullYear,month:month,day:day ,hour:20,minute:0})}
renderInput={(params) => ( disablePast={true}
showTimeSelect={true}
minutesStep={60}
ampm={false}
ampmInClock={false}
inputFormat="DD/MM/YY HH:mm"
disabled={task.readOnly}
renderInput={(params) =>{ return (
<TextField <TextField
{...params} {...params}
sx={{ width: "auto", fontWeight: "200", fontSize: 5 }} sx={{ width: "auto", fontWeight: "200", fontSize: 5 }}
name={props.name} name={name}
/> />
)} )}}
value={props.task[props.name]} value={state}
onChange={(newValue) => { onChange={(newValue) => {
props.onChange(props.task.id, newValue, props.name); setState(newValue)
console.log('newValue ', newValue)
onChange(task.id, newValue, name);
}} }}
/> />
</LocalizationProvider> </LocalizationProvider>
......
...@@ -13,15 +13,18 @@ import { ...@@ -13,15 +13,18 @@ import {
} from "@mui/material"; } from "@mui/material";
import { useState } from "react"; import { useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { AddBox } from "@mui/icons-material"; import { AddBox, Luggage } from "@mui/icons-material";
import moment from "moment"; import moment from "moment";
import CustomTableCell from "./CustomTableCell"; import CustomTableCell from "./CustomTableCell";
import MaterialUIPickers from "./DateTimePicker/DateTimePicker"; import MaterialUIPickers from "./DateTimePicker/DateTimePicker";
import BasicSelect from "../UI/Select/Select"; import BasicSelect from "../UI/Select/Select";
import { addTask } from "../../store/actions/tasksActions"; import { addTask } from "../../store/actions/tasksActions";
import TaskModal from "./TaskModal/TaskModal"; import TaskModal from "./TaskModal/TaskModal";
import {dateToISOLikeButLocal} from '../../helpers/CalendarHelpers';
import DateTimePicker from "../Calendars/UI/DateTimePicker/DateTimePicker";
export default function NewTaskForm({ projects, setAddTaskForm }) { export default function NewTaskForm({ projects, setAddTaskForm }) {
console.log('new task form')
const dispatch = useDispatch(); const dispatch = useDispatch();
const user = useSelector((state) => state.users.user); const user = useSelector((state) => state.users.user);
const currentDateTime = new Date(); const currentDateTime = new Date();
...@@ -39,8 +42,8 @@ export default function NewTaskForm({ projects, setAddTaskForm }) { ...@@ -39,8 +42,8 @@ export default function NewTaskForm({ projects, setAddTaskForm }) {
accomplish: "opened", accomplish: "opened",
priority: "B", priority: "B",
author: { id: user.id }, author: { id: user.id },
authorDisplayName: user.displayName, // authorDisplayName: user.displayName,
executors: [], executor:null,
isEditMode: true, isEditMode: true,
}); });
...@@ -71,14 +74,17 @@ export default function NewTaskForm({ projects, setAddTaskForm }) { ...@@ -71,14 +74,17 @@ export default function NewTaskForm({ projects, setAddTaskForm }) {
}; };
const onDateChange = (id, value, property) => { const onDateChange = (id, value, property) => {
const utcAvoidoffset = moment(value).utcOffset(0, true).format()
const newTask = { const newTask = {
...task, ...task,
[property]: moment.parseZone(value, "DD/MM/YYYY", true).format(), [property]: utcAvoidoffset,
// [property]: moment.parseZone(value, "DD/MM/YYYY", true).format(),
}; };
setTask(newTask); setTask(newTask);
}; };
const handleAddTask = () => { const handleAddTask = () => {
console.log('handle task new form ', task)
dispatch(addTask(task)); dispatch(addTask(task));
setAddTaskForm(); setAddTaskForm();
}; };
...@@ -160,6 +166,7 @@ export default function NewTaskForm({ projects, setAddTaskForm }) { ...@@ -160,6 +166,7 @@ export default function NewTaskForm({ projects, setAddTaskForm }) {
name="dateTimeDeadLine" name="dateTimeDeadLine"
onChange={onDateChange} onChange={onDateChange}
/> />
{/* <DateTimePicker/> */}
</TableCell> </TableCell>
<TableCell style={{ width: "5%" }}> <TableCell style={{ width: "5%" }}>
...@@ -212,7 +219,7 @@ export const header = [ ...@@ -212,7 +219,7 @@ export const header = [
}, },
{ {
id: "dateTimeDue", id: "dateTimeDeadLine",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: "Дедлайн", label: "Дедлайн",
......
...@@ -161,13 +161,6 @@ const TableRowTask= ({ ...@@ -161,13 +161,6 @@ const TableRowTask= ({
/> />
{task.isEditMode && task.author.id===user.id ? ( {task.isEditMode && task.author.id===user.id ? (
<TableCell> <TableCell>
{/* <MaterialUIPickers
task={task}
name="dateTimeStart"
onChange={onDateChange}
user={user}
/> */}
{/* <TableCell> */}
<Tooltip title="Перейти в календарь"> <Tooltip title="Перейти в календарь">
<IconButton <IconButton
onClick={() => { calendarOpen(task.id)}} onClick={() => { calendarOpen(task.id)}}
...@@ -197,25 +190,23 @@ const TableRowTask= ({ ...@@ -197,25 +190,23 @@ const TableRowTask= ({
name: "dateTimeStart", name: "dateTimeStart",
value: moment(task.dateTimeTasks[0]?.dateTimeStart) value: moment(task.dateTimeTasks[0]?.dateTimeStart)
.utc() .utc()
.format("DD-MM-YY "), .format("DD/MM "),
value2:moment(task.dateTimeTasks[0]?.dateTimeStart) value2:moment(task.dateTimeTasks[0]?.dateTimeStart)
.utc() .utc()
.format("kk:mm")+" - "+ .format("kk:00")+" - "+
moment(task.dateTimeTasks[0]?.dateTimeDue) moment(task.dateTimeTasks[0]?.dateTimeDue)
.utc() .utc()
.format("kk:mm"), .format("kk:00"),
user:user user:user
}}> }}>
</CustomTableCell> </CustomTableCell>
)} )}
{task.isEditMode && task.author.id===user.id ? ( {task.isEditMode && task.author.id===user.id ? (
<TableCell> <TableCell>
<MaterialUIPickers <MaterialUIPickers
task={task} task={task}
name="dateTimeDue" name="dateTimeDeadLine"
onChange={onDateChange} onChange={onDateChange}
user={user} user={user}
/> />
...@@ -228,7 +219,7 @@ const TableRowTask= ({ ...@@ -228,7 +219,7 @@ const TableRowTask= ({
value: moment(task.dateTimeDeadLine value: moment(task.dateTimeDeadLine
) )
.utc() .utc()
.format("DD-MM-YY kk:mm"), .format("DD/MM kk:mm"),
user:user user:user
}} }}
/> />
......
...@@ -6,11 +6,11 @@ import FormControl from "@mui/material/FormControl"; ...@@ -6,11 +6,11 @@ import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select"; import Select from "@mui/material/Select";
export default function BasicSelect({value,label,name,onChange,task,items}) { export default function BasicSelect({value,label,name,onChange,task,items}) {
console.log('select value ', value) // console.log('select value ', value)
console.log('select label ', label) // console.log('select label ', label)
console.log('select name ', name) // console.log('select name ', name)
console.log('select task ', task) // console.log('select task ', task)
console.log('select items ', items) // console.log('select items ', items)
return ( return (
<Box sx={{ minWidth: 60, m: 0}}> <Box sx={{ minWidth: 60, m: 0}}>
<FormControl fullWidth> <FormControl fullWidth>
...@@ -20,6 +20,7 @@ export default function BasicSelect({value,label,name,onChange,task,items}) { ...@@ -20,6 +20,7 @@ export default function BasicSelect({value,label,name,onChange,task,items}) {
id="demo-simple-select" id="demo-simple-select"
value={value} value={value}
defaultValue='' defaultValue=''
// displayEmpty={true}
label={label} label={label}
name={name} name={name}
onChange={(e) => onChange(e, task)} onChange={(e) => onChange(e, task)}
......
...@@ -93,11 +93,17 @@ export default function EnhancedTable() { ...@@ -93,11 +93,17 @@ export default function EnhancedTable() {
}; };
const onDateChange = (id, value, property) => { const onDateChange = (id, value, property) => {
const utcAvoidoffset = moment(value).utcOffset(0, true).format()
if(property==='dateTimeDeadLine') {
console.log('In edit mode datedLine ad onDate ', value)
}
const newTasks = recievedTasks.map((task) => { const newTasks = recievedTasks.map((task) => {
if (task.id === id) { if (task.id === id) {
return { return {
...task, ...task,
[property]: moment.parseZone(value, "DD/MM/YY", true).format(), [property]: utcAvoidoffset,
// [property]: moment.parseZone(value, "DD/MM/YY", true).format(),
}; };
} }
return task; return task;
...@@ -211,7 +217,7 @@ export default function EnhancedTable() { ...@@ -211,7 +217,7 @@ export default function EnhancedTable() {
) : null} ) : null}
<TableContainer> <TableContainer>
<Table sx={{ minWidth: 600 }} aria-labelledby="tableTitle"> <Table sx={{ minWidth: 600 }} aria-labelledby="tableTitle" size='small'>
<EnhancedTableHead <EnhancedTableHead
order={order} order={order}
orderBy={orderBy} orderBy={orderBy}
......
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