From 8b9351e3f7c24ff2a3b8cd7216a8e2c3bf6cde1a Mon Sep 17 00:00:00 2001 From: M1kola Date: Fri, 7 Jul 2023 17:38:31 +0300 Subject: [PATCH] task deadLine --- .../Modal/Tracker/ModalTicket/ModalTicket.jsx | 50 ++++++++------- .../TicketFullScreen/TicketFullScreen.jsx | 62 +++++++++++-------- src/pages/ProjectTracker/ProjectTracker.js | 12 ++-- 3 files changed, 69 insertions(+), 55 deletions(-) diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index ab07c8a5..fda057ab 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -1,15 +1,11 @@ import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; import { CKEditor } from "@ckeditor/ckeditor5-react"; -import React, { useEffect, useState } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { Link } from "react-router-dom"; import ru from "date-fns/locale/ru"; +import React, { useEffect, useState } from "react"; import DatePicker, { registerLocale } from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; - -import { - getCorrectDate -} from "../../../Calendar/calendarHelper"; +import { useDispatch, useSelector } from "react-redux"; +import { Link } from "react-router-dom"; import { getProfileInfo } from "@redux/outstaffingSlice"; import { setProjectBoardFetch } from "@redux/projectsTrackerSlice"; @@ -24,6 +20,7 @@ import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskCommen import archive from "assets/icons/archive.svg"; import arrow from "assets/icons/arrows/arrowStart.png"; import fullScreen from "assets/icons/arrows/inFullScreen.svg"; +import calendarIcon from "assets/icons/calendar.svg"; import category from "assets/icons/category.svg"; import close from "assets/icons/closeProjectPersons.svg"; import del from "assets/icons/delete.svg"; @@ -33,8 +30,8 @@ import link from "assets/icons/link.svg"; import send from "assets/icons/send.svg"; import watch from "assets/icons/watch.svg"; import avatarMok from "assets/images/avatarMok.png"; -import calendarIcon from "assets/icons/calendar.svg"; +import { getCorrectDate } from "../../../Calendar/calendarHelper"; import "./modalTicket.scss"; registerLocale("ru", ru); @@ -59,7 +56,7 @@ export const ModalTiсket = ({ const [deadLine, setDeadLine] = useState(task.dead_line); const [datePickerOpen, setDatePickerOpen] = useState(false); const [startDate, setStartDate] = useState( - task.dead_line ? new Date(task.dead_line) : new Date() + task.dead_line ? new Date(task.dead_line) : new Date() ); const [dropListOpen, setDropListOpen] = useState(false); const [dropListMembersOpen, setDropListMembersOpen] = useState(false); @@ -361,7 +358,7 @@ export const ModalTiсket = ({ method: "PUT", data: { task_id: task.id, - dead_line: getCorrectRequestDate(date) + dead_line: getCorrectRequestDate(date), }, }).then(() => { dispatch(setProjectBoardFetch(projectId)); @@ -620,22 +617,27 @@ export const ModalTiсket = ({
-
-
setDatePickerOpen(!datePickerOpen)}> - calendar - {deadLine ? getCorrectDate(deadLine) : 'Срок исполнения:'} +
+
setDatePickerOpen(!datePickerOpen)} + > + calendar + + {deadLine ? getCorrectDate(deadLine) : "Срок исполнения:"} +
{ - setDatePickerOpen(false); - setStartDate(date); - setDeadLine(date) - selectDeadLine(date) - }} + className="datePicker" + open={datePickerOpen} + locale="ru" + selected={startDate} + onChange={(date) => { + setDatePickerOpen(false); + setStartDate(date); + setDeadLine(date); + selectDeadLine(date); + }} />
diff --git a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx index 70b989f2..38e0af38 100644 --- a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx +++ b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx @@ -1,25 +1,24 @@ import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; import { CKEditor } from "@ckeditor/ckeditor5-react"; +import ru from "date-fns/locale/ru"; import React, { useEffect, useState } from "react"; +import DatePicker, { registerLocale } from "react-datepicker"; import { useDispatch, useSelector } from "react-redux"; import { Link, useNavigate, useParams } from "react-router-dom"; import { deletePersonOnProject, getBoarderLoader, - modalToggle, setProjectBoardFetch, + modalToggle, + setProjectBoardFetch, setToggleTab, } from "@redux/projectsTrackerSlice"; import { caseOfNum, getCorrectRequestDate, urlForLocal } from "@utils/helper"; -import calendarIcon from "assets/icons/calendar.svg"; -import {getCorrectDate} from "@components/Calendar/calendarHelper"; -import DatePicker, { registerLocale } from "react-datepicker"; -import ru from "date-fns/locale/ru"; -registerLocale("ru", ru); import { apiRequest } from "@api/request"; +import { getCorrectDate } from "@components/Calendar/calendarHelper"; import BaseButton from "@components/Common/BaseButton/BaseButton"; import { Footer } from "@components/Common/Footer/Footer"; import { Loader } from "@components/Common/Loader/Loader"; @@ -31,6 +30,7 @@ import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskCommen import arrow from "assets/icons/arrows/arrowCalendar.png"; import arrowStart from "assets/icons/arrows/arrowStart.png"; +import calendarIcon from "assets/icons/calendar.svg"; import close from "assets/icons/close.png"; import del from "assets/icons/delete.svg"; import edit from "assets/icons/edit.svg"; @@ -45,6 +45,8 @@ import avatarMok from "assets/images/avatarMok.png"; import "./ticketFullScreen.scss"; +registerLocale("ru", ru); + export const TicketFullScreen = () => { const [modalAddWorker, setModalAddWorker] = useState(false); const ticketId = useParams(); @@ -70,15 +72,17 @@ export const TicketFullScreen = () => { const [correctProjectUsers, setCorrectProjectUsers] = useState([]); const [dropListMembersOpen, setDropListMembersOpen] = useState(false); const [users, setUsers] = useState([]); - const [deadLine, setDeadLine] = useState(''); + const [deadLine, setDeadLine] = useState(""); const [datePickerOpen, setDatePickerOpen] = useState(false); const [startDate, setStartDate] = useState(null); useEffect(() => { apiRequest(`/task/get-task?task_id=${ticketId.id}`).then((taskInfo) => { setTaskInfo(taskInfo); - setDeadLine(taskInfo.dead_line) - setStartDate(taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date()) + setDeadLine(taskInfo.dead_line); + setStartDate( + taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date() + ); setInputsValue({ title: taskInfo.title, description: taskInfo.description, @@ -378,10 +382,9 @@ export const TicketFullScreen = () => { method: "PUT", data: { task_id: taskInfo.id, - dead_line: getCorrectRequestDate(date) + dead_line: getCorrectRequestDate(date), }, - }).then(() => { - }); + }).then(() => {}); } return ( @@ -772,22 +775,29 @@ export const TicketFullScreen = () => {
-
-
setDatePickerOpen(!datePickerOpen)}> - calendar - {deadLine ? getCorrectDate(deadLine) : 'Срок исполнения:'} +
+
setDatePickerOpen(!datePickerOpen)} + > + calendar + + {deadLine + ? getCorrectDate(deadLine) + : "Срок исполнения:"} +
{ - setDatePickerOpen(false); - setStartDate(date); - setDeadLine(date) - selectDeadLine(date) - }} + className="datePicker" + open={datePickerOpen} + locale="ru" + selected={startDate} + onChange={(date) => { + setDatePickerOpen(false); + setStartDate(date); + setDeadLine(date); + selectDeadLine(date); + }} />
diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 3159d697..f9094701 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -33,9 +33,6 @@ import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal"; import { Navigation } from "@components/Navigation/Navigation"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; -import { - getCorrectDate -} from "../../components/Calendar/calendarHelper"; import arrow from "assets/icons/arrows/arrowCalendar.png"; import arrowDown from "assets/icons/arrows/selectArrow.png"; @@ -51,6 +48,8 @@ import accept from "assets/images/accept.png"; import archive from "assets/images/archiveIcon.png"; import avatarMok from "assets/images/avatarMok.png"; +import { getCorrectDate } from "../../components/Calendar/calendarHelper"; + export const ProjectTracker = () => { const dispatch = useDispatch(); const projectId = useParams(); @@ -552,7 +551,7 @@ export const ProjectTracker = () => { >
{column.title} -
+
@@ -657,7 +656,10 @@ export const ProjectTracker = () => {

Срок исполнения:

- {task.dead_line ? getCorrectDate(task.dead_line) : 'Не выбран'} + + {task.dead_line + ? getCorrectDate(task.dead_line) + : "Не выбран"}