From b45dc0283c15f29556ef57e64750f83f3ecd94d9 Mon Sep 17 00:00:00 2001 From: MaxOvs19 Date: Thu, 18 May 2023 18:21:20 +0300 Subject: [PATCH] Fixed nextDay --- .../ProfileCalendarComponent.js | 13 -------- src/pages/ViewReport/ViewReport.jsx | 30 ++++++++----------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/components/ProfileCalendar/ProfileCalendarComponent.js b/src/components/ProfileCalendar/ProfileCalendarComponent.js index 7fbdd769..1e57cea5 100644 --- a/src/components/ProfileCalendar/ProfileCalendarComponent.js +++ b/src/components/ProfileCalendar/ProfileCalendarComponent.js @@ -65,19 +65,6 @@ export const ProfileCalendarComponent = React.memo( return "pass"; } - // function correctRoute(day) { - // for (const date of reports) { - // if ( - // `${new Date(day).getFullYear()}-${correctDay( - // new Date(day).getMonth() + 1 - // )}-${correctDay(new Date(day).getDate())}` === date.created_at - // ) { - // return `../view/${day}`; - // } - // } - // return "../../report"; - // } - function correctRoute(day) { for (const date of reports) { if ( diff --git a/src/pages/ViewReport/ViewReport.jsx b/src/pages/ViewReport/ViewReport.jsx index f69deb4b..224e0702 100644 --- a/src/pages/ViewReport/ViewReport.jsx +++ b/src/pages/ViewReport/ViewReport.jsx @@ -1,13 +1,11 @@ import React, { useEffect, useState } from "react"; import { Link, Navigate, useParams } from "react-router-dom"; -import { useSelector } from "react-redux"; -import { getReportDate } from "../../redux/reportSlice"; - import { Loader } from "../../components/Loader/Loader"; import { ProfileHeader } from "../../components/ProfileHeader/ProfileHeader"; import { ProfileBreadcrumbs } from "../../components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { Footer } from "../../components/Footer/Footer"; +import { Navigation } from "../../components/Navigation/Navigation"; import { apiRequest } from "../../api/request"; import { @@ -20,22 +18,20 @@ import arrow from "../../images/right-arrow.png"; import arrowSwitchDate from "../../images/arrowViewReport.png"; import "./viewReport.scss"; -import { Navigation } from "../../components/Navigation/Navigation"; export const ViewReport = () => { if (localStorage.getItem("role_status") === "18") { return ; } - const reportDate = useSelector(getReportDate); // :D const dateReport = useParams(); - const [testReportDay] = useState(new Date(dateReport.id)); + const [previousReportDay] = useState(new Date(dateReport.id)); + const [nextReportDay] = useState(new Date(dateReport.id)); const [taskText, setTaskText] = useState([]); const [difficulties, setDifficulties] = useState([]); const [tomorrowTask, setTomorrowTask] = useState([]); const [totalHours, setTotalHours] = useState(0); - const [reportDay] = useState(new Date(getCreatedDate(reportDate))); /// const [currentDay] = useState(new Date()); const [loader, setLoader] = useState(false); @@ -74,21 +70,22 @@ export const ViewReport = () => { setTotalHours(spendTime); setLoader(false); }); - testReportDay.setDate(testReportDay.getDate() - 1); + previousReportDay.setDate(previousReportDay.getDate() - 1); + nextReportDay.setDate(nextReportDay.getDate() + 1); } function nextDay() { - reportDay.setDate(reportDay.getDate() + 1); - getReportFromDate(getCreatedDate(reportDay)); + getReportFromDate(getCreatedDate(nextReportDay)); + previousReportDay.setDate(previousReportDay.getDate() + 2); } function previousDay() { - getReportFromDate(getCreatedDate(testReportDay)); + getReportFromDate(getCreatedDate(previousReportDay)); + nextReportDay.setDate(nextReportDay.getDate() - 2); } useEffect(() => { getReportFromDate(dateReport.id); - console.log(dateReport.id); }, []); return ( @@ -129,7 +126,7 @@ export const ViewReport = () => { previousDay(); }} > - +
arrow
@@ -138,15 +135,14 @@ export const ViewReport = () => {

{getCorrectDate(dateReport.id)}

-
- +
nextDay()}> +
nextDay()} > arrow