diff --git a/src/App.js b/src/App.js index b70c438c..d00ea2fe 100644 --- a/src/App.js +++ b/src/App.js @@ -18,6 +18,7 @@ import {InstructionPage} from './pages/quiz/InstructionPage' import {ResultPage} from './pages/quiz/ResultPage' import {Profile} from './pages/Profile/Profile.js' import {Summary} from './pages/Summary/Summary' +import {ViewReport} from './pages/ViewReport/ViewReport' import './fonts/stylesheet.css' import 'bootstrap/dist/css/bootstrap.min.css' @@ -56,6 +57,7 @@ const App = () => { }/> }/> }/> + }/> }/> diff --git a/src/components/ProfileCalendar/ProfileCalendar.js b/src/components/ProfileCalendar/ProfileCalendar.js index fbbe1232..dd40b413 100644 --- a/src/components/ProfileCalendar/ProfileCalendar.js +++ b/src/components/ProfileCalendar/ProfileCalendar.js @@ -1,13 +1,14 @@ import React, { useEffect, useState } from 'react' import {useDispatch, useSelector} from 'react-redux' +import {currentMonth, getReports} from '../Calendar/calendarHelper' import { Link } from 'react-router-dom' import moment from "moment"; -import {currentMonth, getReports} from '../Calendar/calendarHelper' import {ProfileCalendarComponent} from "./ProfileCalendarComponent"; -import { Footer } from '../Footer/Footer' +import {Loader} from "../Loader/Loader"; import {ProfileHeader} from "../ProfileHeader/ProfileHeader"; +import { Footer } from '../Footer/Footer' import {urlForLocal} from "../../helper"; @@ -25,6 +26,7 @@ export const ProfileCalendar = () => { const [reports, setReports] = useState([]); const [totalHours, setTotalHours] = useState(0); const [requestDates, setRequestDates] = useState(''); + const [loader, setLoader] = useState(false) useEffect(() => { @@ -32,19 +34,23 @@ export const ProfileCalendar = () => { },[]); useEffect( () => { + setLoader(true) if (!requestDates) { return } - apiRequest(`/reports/reports-by-date?${requestDates}&user_id=${localStorage.getItem('id')}`) + apiRequest(`/reports/reports-by-date?${requestDates}&user_card_id=${localStorage.getItem('cardId')}`) .then((reports) => { let spendTime = 0; - reports.map((report) => { - if (report.spendTime) { - spendTime += Number(report.spendTime) - } - }); + for (const report of reports) { + report.task.map((task) => { + if(task.hours_spent) { + spendTime += Number(task.hours_spent) + } + }) + } setTotalHours(spendTime); setReports(reports) + setLoader(false) }) }, [requestDates]); @@ -68,14 +74,18 @@ export const ProfileCalendar = () => { }}>Заполнить отчет за день -
-
- -

- {month} : {totalHours} часов -

+ {loader ? + + : +
+
+ +

+ {month} : {totalHours} часов +

+
-
+ }