Bugs fixed

This commit is contained in:
MaxOvs19 2023-05-18 19:52:37 +03:00
parent 973f140451
commit c62ae06d20
3 changed files with 7 additions and 11 deletions

View File

@ -24,10 +24,10 @@ import "./../Calendar/calendarComponent.scss";
export const ProfileCalendarComponent = React.memo( export const ProfileCalendarComponent = React.memo(
({ value, setValueHandler, reports, totalHours }) => { ({ value, setValueHandler, reports, totalHours }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [currentDay] = useState(moment()); const [currentDay] = useState(moment());
const [calendar, setCalendar] = useState([]); const [calendar, setCalendar] = useState([]);
const [month, setMonth] = useState(""); const [month, setMonth] = useState("");
const [dayReport, setDayReport] = useState("");
const [shortReport, setShortReport] = useState(false); const [shortReport, setShortReport] = useState(false);
useEffect(() => { useEffect(() => {
@ -146,20 +146,15 @@ export const ProfileCalendarComponent = React.memo(
<button <button
onClick={() => { onClick={() => {
dispatch(setReportDate(day)); dispatch(setReportDate(day));
setShortReport(true);
dispatch(setSendRequest(true));
}} }}
key={day} key={day}
className={dayStyles(day)} className={dayStyles(day)}
name={day.format("dddd")} name={day.format("dddd")}
id="btn" id="btn"
> >
<Link <Link to={correctRoute(day)}>
to={correctRoute(day)}
onClick={() => {
setShortReport(true);
setDayReport(day);
dispatch(setSendRequest(true));
}}
>
<img <img
className={"calendar__icon"} className={"calendar__icon"}
src={calendarIcon} src={calendarIcon}

View File

@ -13,6 +13,7 @@ import {
} from "../../redux/reportSlice"; } from "../../redux/reportSlice";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Loader } from "../Loader/Loader";
import "./shortReport.scss"; import "./shortReport.scss";
@ -34,6 +35,7 @@ export const ShortReport = ({}) => {
setTaskText([]); setTaskText([]);
setDifficulties([]); setDifficulties([]);
setTomorrowTask([]); setTomorrowTask([]);
setTotalHours(0);
apiRequest( apiRequest(
`reports/find-by-date?user_card_id=${localStorage.getItem( `reports/find-by-date?user_card_id=${localStorage.getItem(
"cardId" "cardId"
@ -95,6 +97,7 @@ export const ShortReport = ({}) => {
</p> </p>
</div> </div>
</div> </div>
{loader && <Loader style="green" />}
{Boolean(taskText.length) && ( {Boolean(taskText.length) && (
<div className="viewReport__content"> <div className="viewReport__content">
<div className="table__container"> <div className="table__container">

View File

@ -45,9 +45,7 @@ export const ViewReport = () => {
"cardId" "cardId"
)}&date=${day}` )}&date=${day}`
).then((res) => { ).then((res) => {
console.log(res);
let spendTime = 0; let spendTime = 0;
for (const item of res) { for (const item of res) {
if (item.difficulties) { if (item.difficulties) {
setDifficulties((prevArray) => [...prevArray, item.difficulties]); setDifficulties((prevArray) => [...prevArray, item.difficulties]);