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

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

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