+
+
Мои отчеты:
+
+ {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..fb6bba74
--- /dev/null
+++ b/src/components/ShortReport/ShortReport.jsx
@@ -0,0 +1,167 @@
+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 "./shortReport.scss";
+
+export const ShortReport = ({}) => {
+ const reportDate = useSelector(getReportDate);
+
+ const sendTest = 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 [reportDay] = useState(new Date(getCreatedDate(reportDate)));
+
+ function getReportFromDate(day) {
+ setLoader(true);
+ setTaskText([]);
+ setDifficulties([]);
+ setTomorrowTask([]);
+
+ apiRequest(
+ `reports/find-by-date?user_card_id=${localStorage.getItem(
+ "cardId"
+ )}&date=${day}`
+ ).then((res) => {
+ console.log(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);
+ });
+ }
+
+ if (sendTest) {
+ dispatch(setSendRequest(false));
+ getReportFromDate(getCreatedDate(reportDate));
+ }
+
+ return (
+
+
+
+ Ваши отчеты - просмотр отчета за день
+
+
+
+ {getCorrectDate(reportDate)}
+
+
+ Вами потрачено на работу :{" "}
+
+ {totalHours} {hourOfNum(totalHours)}
+
+
+
+
+ {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..e69de29b
diff --git a/src/pages/ViewReport/ViewReport.js b/src/pages/ViewReport/ViewReport.js
index 82ddf051..97374283 100644
--- a/src/pages/ViewReport/ViewReport.js
+++ b/src/pages/ViewReport/ViewReport.js
@@ -1,175 +1,219 @@
-import React, {useEffect, useState} from 'react'
-import {Link, Navigate} from "react-router-dom";
+import React, { useEffect, useState } from "react";
+import { Link, Navigate } from "react-router-dom";
-import {useSelector} from "react-redux";
-import {getReportDate} from "../../redux/reportSlice";
+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 { 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 { 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';
+import "./viewReport.scss";
+import { Navigation } from "../../components/Navigation/Navigation";
export const ViewReport = () => {
- if(localStorage.getItem('role_status') === '18') {
- return
- }
- const reportDate = useSelector(getReportDate);
+ 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);
+ 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 getReportFromDate(day) {
+ setLoader(true);
+ setTaskText([]);
+ setDifficulties([]);
+ setTomorrowTask([]);
+ apiRequest(
+ `reports/find-by-date?user_card_id=${localStorage.getItem(
+ "cardId"
+ )}&date=${day}`
+ ).then((res) => {
+ console.log(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 nextDay() {
+ reportDay.setDate(reportDay.getDate() + 1);
+ getReportFromDate(getCreatedDate(reportDay));
+ }
- function previousDay() {
- 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 &&
-
-
В этот день вы не заполняли отчет
-
- }
-
-
+ 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/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;