Compare commits

...

3 Commits

Author SHA1 Message Date
Victor Batischev
dea1eb6104 resolve 2024-04-22 17:03:14 +03:00
Victor Batischev
ee20b49993 fix total hours 2024-04-22 17:01:37 +03:00
Victor Batischev
0e04e19c1b total day hours 2024-04-22 17:00:37 +03:00

View File

@ -14,7 +14,6 @@ import {
import {
calendarHelper,
correctDay,
currentMonthAndDay,
getCorrectDate,
getReports,
hourOfNum
@ -29,7 +28,6 @@ import BaseButton from "@components/Common/BaseButton/BaseButton";
import arrowLeft from "assets/icons/arrows/arrowCalendar_left.png";
import arrowRight from "assets/icons/arrows/arrowCalendar_right.png";
import calendarIcon from "assets/icons/calendar.svg";
// import close from "assets/icons/closeProjectPersons.svg";
import rectangle from "assets/images/rectangle__calendar.png";
export const ProfileCalendarComponent = React.memo(
@ -175,26 +173,13 @@ export const ProfileCalendarComponent = React.memo(
});
}
// function dddd(day) {
// let index = day.format("D") - l;
// console.log(`d ${day.format("d")}`);
// if (day.format("d") != 0 && day.format("d") != 6) {
// let elementAtIndex1 = reports[index];
// if (elementAtIndex1 && elementAtIndex1.task) {
// let totalHoursSpent = elementAtIndex1.task.reduce(
// (total, task) => total + task.hours_spent,
// 0
// );
// console.log(`index ${index}`);
// console.log(elementAtIndex1);
// console.log(`h ${totalHoursSpent}`);
// return totalHoursSpent;
// }
// } else {
// setL(l + 1);
// console.log(`l ${l}`);
// }
// }
const countHours = (day) => {
let hours =
reports
.find((item) => moment(item.created_at).isSame(day, "date"))
?.task.reduce((acc, task) => acc + task.hours_spent, 0) || 0;
return `${hours} ${hourOfNum(hours)}`;
};
return (
<div className="calendar-component">
@ -284,10 +269,9 @@ export const ProfileCalendarComponent = React.memo(
<div className="form-date">{day.format("D")}</div>
<div className="form-box">
<div className="form-hours">
<span>7/</span>
<span>{countHours(day)}</span>
</div>
</div>
{/* {currentMonthAndDay(day)} */}
</Link>
</button>
))
@ -308,16 +292,16 @@ export const ProfileCalendarComponent = React.memo(
? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}`
: `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}`
: activePeriod
? "Выберите диапазон на календаре"
: "Выбрать диапазон"}
? "Выберите диапазон на календаре"
: "Выбрать диапазон"}
</span>
<span>
{totalRangeHours
? `${totalRangeHours} ${hourOfNum(totalRangeHours)}`
: endDate
? "0 часов"
: ""}
? "0 часов"
: ""}
</span>
{endDate && (
<BaseButton