Commit 2ccfde5b authored by Ermolaev Timur's avatar Ermolaev Timur

#102 Сделал кнопки не активными, при неверных значениях + чуть подправил…

#102 Сделал кнопки не активными, при неверных значениях + чуть подправил отправляемые данные на редактирование задач
parent 12c66ab3
...@@ -4,7 +4,24 @@ import { priorities } from "../../../constants"; ...@@ -4,7 +4,24 @@ import { priorities } from "../../../constants";
import CustomSelect from '../../UI/СustomSelect/СustomSelect' import CustomSelect from '../../UI/СustomSelect/СustomSelect'
function CalendarModalContent({ title, onChangeCurrentTaskHandler, description, priority, sendNewTaskHandler, deleteTaskHandler, startHour, endHour, id }) { function CalendarModalTaskContent({ title, onChangeCurrentTaskHandler, description, priority, sendNewTaskHandler, deleteTaskHandler, startHour, endHour, id }) {
const isValidate = () => {
if (title) {
const startHourInt = parseInt(startHour)
const endHourInt = parseInt(endHour)
if (startHourInt >= 8 && startHourInt <= 22) {
if (endHourInt >= 8 && endHourInt <= 22) {
if (startHourInt < endHourInt) {
return true
}
}
} else {
return false
}
}
}
return (<> return (<>
<TextField <TextField
id="task-description-title" id="task-description-title"
...@@ -55,10 +72,10 @@ function CalendarModalContent({ title, onChangeCurrentTaskHandler, description, ...@@ -55,10 +72,10 @@ function CalendarModalContent({ title, onChangeCurrentTaskHandler, description,
/> />
</div> </div>
<div style={{ display: 'flex', gap: '20px', margin: '10px 0' }}> <div style={{ display: 'flex', gap: '20px', margin: '10px 0' }}>
<Button id='test_button_save_task' onClick={sendNewTaskHandler}>Сохранить</Button> <Button id='test_button_save_task' onClick={sendNewTaskHandler} disabled={!isValidate()}>Сохранить</Button>
{id ? <Button onClick={deleteTaskHandler}>Удалить</Button> : null} <Button onClick={deleteTaskHandler} disabled={!id}>Удалить</Button>
</div> </div>
</>); </>);
} }
export default memo(CalendarModalContent); export default memo(CalendarModalTaskContent);
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ import CalendarRow from "../../CalendarRow/CalendarRow"; ...@@ -4,7 +4,7 @@ import CalendarRow from "../../CalendarRow/CalendarRow";
import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell"; import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell"; import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell";
import ModalTask from "../../../UI/ModalTask/ModalTask" import ModalTask from "../../../UI/ModalTask/ModalTask"
import MonthCalendarModalContent from "../../CalendarModalContent/CalendarModalContent"; import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay"; import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
......
...@@ -106,7 +106,7 @@ function MonthCalendar() { ...@@ -106,7 +106,7 @@ function MonthCalendar() {
...prevState, ...prevState,
infoForCell: { infoForCell: {
...prevState.infoForCell, ...prevState.infoForCell,
[name]: parseInt(value) [name]: value
} }
} }
}); });
...@@ -160,6 +160,7 @@ function MonthCalendar() { ...@@ -160,6 +160,7 @@ function MonthCalendar() {
const start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, hour, 0)) const start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, hour, 0))
const newTask = { const newTask = {
...currentTask, ...currentTask,
taskId: currentTask.mainTaskId,
dateTimeStart: start, dateTimeStart: start,
dateTimeDue: due dateTimeDue: due
} }
...@@ -198,7 +199,6 @@ function MonthCalendar() { ...@@ -198,7 +199,6 @@ function MonthCalendar() {
await dispatch(addCalendarTask(newTask, userId)) await dispatch(addCalendarTask(newTask, userId))
} }
} }
console.log(userId)
const createCopyTask = async (dayNumber, hour) => { const createCopyTask = async (dayNumber, hour) => {
const hourDiff = copyTask.infoForCell.endHour - copyTask.infoForCell.startHour const hourDiff = copyTask.infoForCell.endHour - copyTask.infoForCell.startHour
......
...@@ -141,7 +141,8 @@ export const editCalendarTask = (task, taskId, userId) => { ...@@ -141,7 +141,8 @@ export const editCalendarTask = (task, taskId, userId) => {
return async (dispatch) => { return async (dispatch) => {
dispatch(editTaskRequest()); dispatch(editTaskRequest());
try { try {
await axios.put(`/copy-tasks/change-copy/${taskId}`, task); const response = await axios.put(`/copy-tasks/change-copy/${taskId}`, task);
console.log(response.data)
dispatch(editTaskSuccess()) dispatch(editTaskSuccess())
dispatch(fetchCalendarTasks(userId)) dispatch(fetchCalendarTasks(userId))
} catch (error) { } catch (error) {
......
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