+
+
Мои отчеты:
+
+ {month}
+
+ {totalHours} {hourOfNum(totalHours)}{" "}
+
+
+
+
+
{
+ setValueHandler(prevMonth());
+ dispatch(setRequestDate(getReports(prevMonth())));
+ }}
+ >
+
+
{prevMonth().format("MMMM")}
-
-
-
+
+ {value.format("YYYY")}
-
-
-
-
Пн
-
Вт
-
Ср
-
Чт
-
Пт
-
Сб
-
Вс
-
-
-
- {calendar.map((week) =>
- week.map((day) => (
-
- ))
- )}
-
+
{
+ setValueHandler(nextMonth());
+ dispatch(setRequestDate(getReports(nextMonth())));
+ }}
+ >
+
{nextMonth().format("MMMM")}
+
+
- )
-})
+
+
+
+
+
+
+
Пн
+
Вт
+
Ср
+
Чт
+
Пт
+
Сб
+
Вс
+
+
+
+ {calendar.map((week) =>
+ week.map((day) => (
+
+ ))
+ )}
+
+
+
+ {shortReport &&
}
+
+ );
+ }
+);
diff --git a/src/components/ProfileCalendar/profileCalendar.scss b/src/components/ProfileCalendar/profileCalendar.scss
index c4af09df..3d766296 100644
--- a/src/components/ProfileCalendar/profileCalendar.scss
+++ b/src/components/ProfileCalendar/profileCalendar.scss
@@ -1,5 +1,5 @@
.profile__calendar {
- background: #F1F1F1;
+ background: #f1f1f1;
height: 100%;
min-height: 100vh;
font-family: "LabGrotesque", sans-serif;
@@ -32,7 +32,6 @@
}
}
-
.calendar__wrapper {
min-height: 719px;
diff --git a/src/components/ShortReport/ShortReport.jsx b/src/components/ShortReport/ShortReport.jsx
new file mode 100644
index 00000000..84eedd60
--- /dev/null
+++ b/src/components/ShortReport/ShortReport.jsx
@@ -0,0 +1,176 @@
+import React, { useEffect, useState } from "react";
+
+import { apiRequest } from "../../api/request";
+import {
+ getCorrectDate,
+ getCreatedDate,
+ hourOfNum,
+} from "../../components/Calendar/calendarHelper";
+import {
+ getReportDate,
+ getSendRequest,
+ setSendRequest,
+} from "../../redux/reportSlice";
+import { useDispatch, useSelector } from "react-redux";
+import { Link } from "react-router-dom";
+import { Loader } from "../Loader/Loader";
+
+import "./shortReport.scss";
+
+export const ShortReport = ({}) => {
+ const reportDate = useSelector(getReportDate);
+
+ const sendReport = useSelector(getSendRequest);
+ const dispatch = useDispatch();
+
+ const [taskText, setTaskText] = useState([]);
+ const [difficulties, setDifficulties] = useState([]);
+ const [tomorrowTask, setTomorrowTask] = useState([]);
+ const [totalHours, setTotalHours] = useState(0);
+ const [loader, setLoader] = useState(false);
+ const [dateCreate, setDateCreate] = useState("");
+
+ function getReportFromDate(day) {
+ setLoader(true);
+ setTaskText([]);
+ setDifficulties([]);
+ setTomorrowTask([]);
+ setTotalHours(0);
+ apiRequest(
+ `reports/find-by-date?user_card_id=${localStorage.getItem(
+ "cardId"
+ )}&date=${day}`
+ ).then((res) => {
+ let spendTime = 0;
+ for (const item of res) {
+ setDateCreate(item.created_at);
+ if (item.difficulties) {
+ setDifficulties((prevArray) => [...prevArray, item.difficulties]);
+ }
+ if (item.tomorrow) {
+ setTomorrowTask((prevArray) => [...prevArray, item.tomorrow]);
+ }
+ item.task.map((task) => {
+ const taskInfo = {
+ hours: task.hours_spent,
+ task: task.task,
+ id: task.id,
+ };
+ if (task.hours_spent) {
+ spendTime += Number(task.hours_spent);
+ }
+ setTaskText((prevArray) => [...prevArray, taskInfo]);
+ });
+ }
+
+ setTotalHours(spendTime);
+ setLoader(false);
+ });
+ }
+
+ if (sendReport) {
+ dispatch(setSendRequest(false));
+ getReportFromDate(getCreatedDate(reportDate));
+ }
+
+ return (
+
+
+
+
+ Ваши отчеты - просмотр отчета за день
+
+
+ Посмотреть подробнее об отчете
+
+
+
+
+
+ {getCorrectDate(reportDate)}
+
+
+ Вами потрачено на работу :{" "}
+
+ {totalHours} {hourOfNum(totalHours)}
+
+
+
+
+ {loader &&
}
+ {Boolean(taskText.length) && (
+
+
+
+
+
+
+ Какие задачи были выполнены?
+ |
+
+ Время
+ |
+
+
+
+ {taskText.length &&
+ taskText.map((task, index) => {
+ return (
+
+
+
+ {index + 1}. {task.task}
+
+ |
+
+
+ {task.hours}
+
+ {hourOfNum(task.hours)} на задачу
+
+
+ |
+
+ );
+ })}
+
+ |
+
+
+ Всего: {totalHours} {hourOfNum(totalHours)}
+
+ |
+
+
+
+
+ {Boolean(difficulties.length) && (
+
+
Какие сложности возникли?
+ {difficulties.map((item, index) => {
+ return
{item}
;
+ })}
+
+ )}
+ {Boolean(tomorrowTask.length) && (
+
+
Что планируется сделать завтра?
+ {tomorrowTask.map((item, index) => {
+ return
{item}
;
+ })}
+
+ )}
+
+ )}
+ {!Boolean(taskText.length) && !loader && (
+
+
+ В этот день вы не заполняли отчет
+
+
+ )}
+
+ );
+};
+
+export default ShortReport;
diff --git a/src/components/ShortReport/shortReport.scss b/src/components/ShortReport/shortReport.scss
new file mode 100644
index 00000000..e1afef85
--- /dev/null
+++ b/src/components/ShortReport/shortReport.scss
@@ -0,0 +1,15 @@
+.short-report {
+ margin-bottom: 30px;
+}
+
+.viewReport {
+ &__title-box {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+
+ a {
+ font-size: 16px;
+ }
+ }
+}
diff --git a/src/pages/ViewReport/ViewReport.js b/src/pages/ViewReport/ViewReport.js
deleted file mode 100644
index 82ddf051..00000000
--- a/src/pages/ViewReport/ViewReport.js
+++ /dev/null
@@ -1,175 +0,0 @@
-import React, {useEffect, useState} from 'react'
-import {Link, Navigate} 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 {apiRequest} from "../../api/request";
-import {getCorrectDate, getCreatedDate, hourOfNum} from '../../components/Calendar/calendarHelper'
-
-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);
-
- 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);
-
- function getReportFromDate(day) {
- setLoader(true);
- setTaskText([]);
- setDifficulties([]);
- setTomorrowTask([]);
- apiRequest(`reports/find-by-date?user_card_id=${localStorage.getItem('cardId')}&date=${day}`)
- .then(res => {
- let spendTime = 0;
- for (const item of res) {
- if(item.difficulties) {
- setDifficulties(prevArray => [...prevArray, item.difficulties])
- }
- if(item.tomorrow) {
- setTomorrowTask(prevArray => [...prevArray, item.tomorrow])
- }
- item.task.map((task) => {
- const taskInfo = {
- hours: task.hours_spent,
- task: task.task,
- id: task.id
- };
- if(task.hours_spent) {
- spendTime += Number(task.hours_spent)
- }
- setTaskText(prevArray => [...prevArray, taskInfo])
- })
- }
- setTotalHours(spendTime);
- setLoader(false)
- })
- }
-
- function nextDay() {
- reportDay.setDate(reportDay.getDate() + 1);
- getReportFromDate(getCreatedDate(reportDay))
- }
-
- function previousDay() {
- reportDay.setDate(reportDay.getDate() - 1);
- getReportFromDate(getCreatedDate(reportDay))
- }
-
- useEffect(() => {
- getReportFromDate(getCreatedDate(reportDate))
- }, []);
- return (
-
-
-
-
-
-
-
Ваши отчеты - просмотр отчета за день
-
-
Вернуться
-
-
-
{getCorrectDate(reportDay)}
-
Вами потрачено на работу : {totalHours} {hourOfNum(totalHours)}
- {/*
*/}
- {/* */}
- {/*
*/}
- {/*
122 часа из 160
*/}
-
-
-
-
previousDay()}>
-
-
-
{getCorrectDate(reportDay)}
-
nextDay()}>
-
-
-
- {loader &&
-
- }
- {Boolean(taskText.length) &&
-
-
-
-
-
- Какие задачи были выполнены? |
- Время |
-
-
-
- {taskText.length && taskText.map((task, index) => {
- return
-
- {index + 1}. {task.task}
- |
-
-
- {task.hours}
- {hourOfNum(task.hours)} на задачу
-
- |
-
- })}
-
- |
- Всего: {totalHours} {hourOfNum(totalHours)} |
-
-
-
-
- {Boolean(difficulties.length) &&
-
-
Какие сложности возникли?
- {difficulties.map((item, index) => {
- return
{item}
- }
- )}
-
- }
- {Boolean(tomorrowTask.length) &&
-
-
Что планируется сделать завтра?
- {tomorrowTask.map((item, index) => {
- return
{item}
- }
- )}
-
- }
-
- }
- {!Boolean(taskText.length) && !loader &&
-
-
В этот день вы не заполняли отчет
-
- }
-
-
-
- )
-};
diff --git a/src/pages/ViewReport/ViewReport.jsx b/src/pages/ViewReport/ViewReport.jsx
new file mode 100644
index 00000000..df84fca4
--- /dev/null
+++ b/src/pages/ViewReport/ViewReport.jsx
@@ -0,0 +1,225 @@
+import React, { useEffect, useState } from "react";
+import { Link, Navigate, useParams } from "react-router-dom";
+
+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 {
+ getCorrectDate,
+ getCreatedDate,
+ hourOfNum,
+} from "../../components/Calendar/calendarHelper";
+
+import arrow from "../../images/right-arrow.png";
+import arrowSwitchDate from "../../images/arrowViewReport.png";
+
+import "./viewReport.scss";
+
+export const ViewReport = () => {
+ if (localStorage.getItem("role_status") === "18") {
+ return
;
+ }
+
+ const dateReport = useParams();
+ 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 [currentDay] = useState(new Date());
+ const [loader, setLoader] = useState(false);
+
+ function getReportFromDate(day) {
+ setLoader(true);
+ setTaskText([]);
+ setDifficulties([]);
+ setTomorrowTask([]);
+ apiRequest(
+ `reports/find-by-date?user_card_id=${localStorage.getItem(
+ "cardId"
+ )}&date=${day}`
+ ).then((res) => {
+ let spendTime = 0;
+ for (const item of res) {
+ if (item.difficulties) {
+ setDifficulties((prevArray) => [...prevArray, item.difficulties]);
+ }
+ if (item.tomorrow) {
+ setTomorrowTask((prevArray) => [...prevArray, item.tomorrow]);
+ }
+ item.task.map((task) => {
+ const taskInfo = {
+ hours: task.hours_spent,
+ task: task.task,
+ id: task.id,
+ };
+ if (task.hours_spent) {
+ spendTime += Number(task.hours_spent);
+ }
+ setTaskText((prevArray) => [...prevArray, taskInfo]);
+ });
+ }
+ setTotalHours(spendTime);
+ setLoader(false);
+ });
+ previousReportDay.setDate(previousReportDay.getDate() - 1);
+ nextReportDay.setDate(nextReportDay.getDate() + 1);
+ }
+
+ function nextDay() {
+ getReportFromDate(getCreatedDate(nextReportDay));
+ previousReportDay.setDate(previousReportDay.getDate() + 2);
+ }
+
+ function previousDay() {
+ getReportFromDate(getCreatedDate(previousReportDay));
+ nextReportDay.setDate(nextReportDay.getDate() - 2);
+ }
+
+ useEffect(() => {
+ getReportFromDate(dateReport.id);
+ }, []);
+
+ return (
+
+
+
+
+
+
+
+ Ваши отчеты - просмотр отчета за день
+
+
+
+
Вернуться
+
+
+
+ {getCorrectDate(dateReport.id)}
+
+
+ Вами потрачено на работу :{" "}
+
+ {totalHours} {hourOfNum(totalHours)}
+
+
+
+
+
+
{
+ previousDay();
+ }}
+ >
+
+
+
+
+
+
+
+
{getCorrectDate(dateReport.id)}
+
+
nextDay()}
+ className={`${
+ getCreatedDate(currentDay) === dateReport.id ? "disable" : ""
+ }`}
+ >
+
+
+
+
+
+
+
+ {loader &&
}
+ {Boolean(taskText.length) && (
+
+
+
+
+
+
+ Какие задачи были выполнены?
+ |
+
+ Время
+ |
+
+
+
+ {taskText.length &&
+ taskText.map((task, index) => {
+ return (
+
+
+
+ {index + 1}. {task.task}
+
+ |
+
+
+ {task.hours}
+
+ {hourOfNum(task.hours)} на задачу
+
+
+ |
+
+ );
+ })}
+
+ |
+
+
+ Всего: {totalHours} {hourOfNum(totalHours)}
+
+ |
+
+
+
+
+ {Boolean(difficulties.length) && (
+
+
Какие сложности возникли?
+ {difficulties.map((item, index) => {
+ return
{item}
;
+ })}
+
+ )}
+ {Boolean(tomorrowTask.length) && (
+
+
Что планируется сделать завтра?
+ {tomorrowTask.map((item, index) => {
+ return
{item}
;
+ })}
+
+ )}
+
+ )}
+ {!Boolean(taskText.length) && !loader && (
+
+
+ В этот день вы не заполняли отчет
+
+
+ )}
+
+
+
+ );
+};
diff --git a/src/redux/reportSlice.js b/src/redux/reportSlice.js
index 15036e0d..4f3c49e7 100644
--- a/src/redux/reportSlice.js
+++ b/src/redux/reportSlice.js
@@ -1,13 +1,14 @@
-import { createSlice } from '@reduxjs/toolkit';
+import { createSlice } from "@reduxjs/toolkit";
const initialState = {
- dateSelected: '',
- reportDate: '',
- requestDates: ''
+ dateSelected: "",
+ reportDate: "",
+ requestDates: "",
+ sendRequest: "",
};
export const reportSlice = createSlice({
- name: 'report',
+ name: "report",
initialState,
reducers: {
dateSelected: (state, action) => {
@@ -17,17 +18,23 @@ export const reportSlice = createSlice({
state.reportDate = action.payload;
},
setRequestDate: (state, action) => {
- state.requestDates = action.payload
- }
+ state.requestDates = action.payload;
+ },
+ setSendRequest: (state, action) => {
+ state.sendRequest = action.payload;
+ },
},
});
-export const { dateSelected, setReportDate, setRequestDate} = reportSlice.actions;
+export const { dateSelected, setReportDate, setRequestDate, setSendRequest } =
+ reportSlice.actions;
export const selectDate = (state) => state.report.dateSelected;
export const getReportDate = (state) => state.report.reportDate;
-export const getRequestDates = (state) => state.report.requestDates
+export const getRequestDates = (state) => state.report.requestDates;
+
+export const getSendRequest = (state) => state.report.sendRequest;
export default reportSlice.reducer;