trackerTask #15
@ -15,7 +15,10 @@ export const PartnerPersonCard = ({ name, img, userId }) => {
|
||||
</div>
|
||||
<div className="partnerPersonCard__info">
|
||||
<h2 className="partnerPersonCard__name">{name}</h2>
|
||||
<Link className="partnerPersonCard__report" to={`/profile/employees/report/${userId}`}>
|
||||
<Link
|
||||
className="partnerPersonCard__report"
|
||||
to={`/profile/employees/report/${userId}`}
|
||||
>
|
||||
Подробный отчет
|
||||
<div className="partnerPersonCard__more">
|
||||
<img src={rightArrow} alt="arrow" />
|
||||
|
@ -96,14 +96,14 @@ export const ProfileCalendarComponent = React.memo(
|
||||
)}-${correctDay(new Date(day).getDate())}` === date.created_at
|
||||
) {
|
||||
if (userId) {
|
||||
return `../view/${date.created_at}/${userId}`
|
||||
return `../view/${date.created_at}/${userId}`;
|
||||
}
|
||||
return `../view/${date.created_at}/${localStorage.getItem("id")}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
return "#"
|
||||
return "#";
|
||||
}
|
||||
|
||||
return "../../report";
|
||||
@ -123,7 +123,9 @@ export const ProfileCalendarComponent = React.memo(
|
||||
startDate._d
|
||||
)}`;
|
||||
apiRequest(
|
||||
`/reports/index?${requestDates}&user_id=${userId ? userId : localStorage.getItem("id")}`
|
||||
`/reports/index?${requestDates}&user_id=${
|
||||
userId ? userId : localStorage.getItem("id")
|
||||
}`
|
||||
).then((reports) => {
|
||||
let spendTime = 0;
|
||||
reports.map((report) => {
|
||||
@ -172,9 +174,7 @@ export const ProfileCalendarComponent = React.memo(
|
||||
<div className="calendar-component">
|
||||
<div className="calendar-component__header">
|
||||
<div className="calendar-component__header-info">
|
||||
{!userId &&
|
||||
<h3>Мои отчеты за </h3>
|
||||
}
|
||||
{!userId && <h3>Мои отчеты за </h3>}
|
||||
<p className="calendar__hours">
|
||||
{month}
|
||||
<span>
|
||||
|
@ -1,20 +1,21 @@
|
||||
import moment from "moment/moment";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Navigate, useParams } from "react-router-dom";
|
||||
|
||||
import { Footer } from "@components/Common/Footer/Footer";
|
||||
import { Navigation } from "@components/Navigation/Navigation";
|
||||
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
|
||||
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
||||
import { ProfileCalendarComponent } from "@components/ProfileCalendar/ProfileCalendarComponent";
|
||||
import { getRequestDates, setRequestDate } from "@redux/reportSlice";
|
||||
|
||||
import { apiRequest } from "@api/request";
|
||||
|
||||
import "./partnerEmployeeReport.scss";
|
||||
import moment from "moment/moment";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { getRequestDates, setRequestDate } from "@redux/reportSlice";
|
||||
import { getReports } from "@components/Calendar/calendarHelper";
|
||||
import { Footer } from "@components/Common/Footer/Footer";
|
||||
import { Loader } from "@components/Common/Loader/Loader";
|
||||
import { Navigation } from "@components/Navigation/Navigation";
|
||||
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
|
||||
import { ProfileCalendarComponent } from "@components/ProfileCalendar/ProfileCalendarComponent";
|
||||
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
||||
|
||||
import "./partnerEmployeeReport.scss";
|
||||
|
||||
export const PartnerEmployeeReport = () => {
|
||||
// if (
|
||||
@ -25,7 +26,7 @@ export const PartnerEmployeeReport = () => {
|
||||
|
||||
const params = useParams();
|
||||
const dispatch = useDispatch();
|
||||
const [userInfo, setUserInfo] = useState({})
|
||||
const [userInfo, setUserInfo] = useState({});
|
||||
const [value, setValue] = useState(moment());
|
||||
const [reports, setReports] = useState([]);
|
||||
const [totalHours, setTotalHours] = useState(0);
|
||||
@ -39,38 +40,36 @@ export const PartnerEmployeeReport = () => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
apiRequest(
|
||||
`/resume?userId=${params.uuid}`
|
||||
).then((res) => {
|
||||
setUserInfo(res)
|
||||
apiRequest(`/resume?userId=${params.uuid}`).then((res) => {
|
||||
setUserInfo(res);
|
||||
});
|
||||
}, [])
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setLoader(true);
|
||||
if (!requestDates) {
|
||||
return;
|
||||
}
|
||||
apiRequest(
|
||||
`/reports/index?${requestDates}&user_id=${params.uuid}`
|
||||
).then((reports) => {
|
||||
let spendTime = 0;
|
||||
apiRequest(`/reports/index?${requestDates}&user_id=${params.uuid}`).then(
|
||||
(reports) => {
|
||||
let spendTime = 0;
|
||||
|
||||
reports
|
||||
.filter(
|
||||
(item) => new Date(item.created_at).getMonth() === value.month()
|
||||
)
|
||||
.map((report) => {
|
||||
spendTime += report.task.reduce(
|
||||
(acc, task) => acc + task.hours_spent,
|
||||
0
|
||||
);
|
||||
});
|
||||
reports
|
||||
.filter(
|
||||
(item) => new Date(item.created_at).getMonth() === value.month()
|
||||
)
|
||||
.map((report) => {
|
||||
spendTime += report.task.reduce(
|
||||
(acc, task) => acc + task.hours_spent,
|
||||
0
|
||||
);
|
||||
});
|
||||
|
||||
setTotalHours(Math.floor(spendTime));
|
||||
setReports(reports);
|
||||
setLoader(false);
|
||||
});
|
||||
setTotalHours(Math.floor(spendTime));
|
||||
setReports(reports);
|
||||
setLoader(false);
|
||||
}
|
||||
);
|
||||
}, [requestDates]);
|
||||
|
||||
return (
|
||||
@ -84,11 +83,11 @@ export const PartnerEmployeeReport = () => {
|
||||
{ name: "Данные моего персонала", link: "/profile/employees" }
|
||||
]}
|
||||
/>
|
||||
{!Object.keys(userInfo).length ?
|
||||
{!Object.keys(userInfo).length ? (
|
||||
<div className="employeeReport__loader">
|
||||
<Loader style={'green'} height={80} width={80} />
|
||||
<Loader style={"green"} height={80} width={80} />
|
||||
</div>
|
||||
:
|
||||
) : (
|
||||
<>
|
||||
<div className="employeeReport__info">
|
||||
<div className="employeeReport__name">
|
||||
@ -96,15 +95,16 @@ export const PartnerEmployeeReport = () => {
|
||||
<p>{userInfo.position}</p>
|
||||
</div>
|
||||
<div className="employeeReport__skills">
|
||||
{userInfo?.stack && userInfo.stack.map((skill, index) => {
|
||||
return <span key={index}>{skill}</span>
|
||||
})}
|
||||
{userInfo?.stack &&
|
||||
userInfo.stack.map((skill, index) => {
|
||||
return <span key={index}>{skill}</span>;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="employeeReport__wrapper">
|
||||
{loader ? (
|
||||
<div className="employeeReport__loader">
|
||||
<Loader style={'green'} height={80} width={80} />
|
||||
<Loader style={"green"} height={80} width={80} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="employeeReport__calendar ">
|
||||
@ -123,7 +123,7 @@ export const PartnerEmployeeReport = () => {
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
|
@ -7,6 +7,7 @@ import { apiRequest } from "@api/request";
|
||||
|
||||
// import { setPartnerEmployees } from "@redux/outstaffingSlice";
|
||||
import { Footer } from "@components/Common/Footer/Footer";
|
||||
import { Loader } from "@components/Common/Loader/Loader";
|
||||
import { Navigation } from "@components/Navigation/Navigation";
|
||||
import PartnerPersonCard from "@components/PartnerPersonCard/PartnerPersonCard";
|
||||
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
|
||||
@ -24,7 +25,6 @@ import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
||||
// import TestImg from "assets/images/partnerProfile/PersonalTesters.svg";
|
||||
// import BackEndImg from "assets/images/partnerProfile/personalBackEnd.svg";
|
||||
import "./partnerСategories.scss";
|
||||
import { Loader } from "@components/Common/Loader/Loader";
|
||||
|
||||
export const PartnerCategories = () => {
|
||||
// const dispatch = useDispatch();
|
||||
@ -33,12 +33,12 @@ export const PartnerCategories = () => {
|
||||
}
|
||||
|
||||
const [staff, setStaff] = useState([]);
|
||||
const [loader, setLoader] = useState(false)
|
||||
const [loader, setLoader] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setLoader(true)
|
||||
setLoader(true);
|
||||
apiRequest("/project/my-employee").then((el) => {
|
||||
setLoader(false)
|
||||
setLoader(false);
|
||||
setStaff(el.managerEmployees);
|
||||
});
|
||||
}, []);
|
||||
@ -157,9 +157,9 @@ export const PartnerCategories = () => {
|
||||
]}
|
||||
/>
|
||||
<h2 className="partnerCategories__title">Данные персонала</h2>
|
||||
{loader ?
|
||||
<Loader style={'green'} height={80} width={80} />
|
||||
:
|
||||
{loader ? (
|
||||
<Loader style={"green"} height={80} width={80} />
|
||||
) : (
|
||||
<div className="partnerCategories__items">
|
||||
{staff.map((card) => {
|
||||
return (
|
||||
@ -205,7 +205,7 @@ export const PartnerCategories = () => {
|
||||
{/* );*/}
|
||||
{/*})}*/}
|
||||
</div>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
|
@ -20,7 +20,6 @@ import arrow from "assets/icons/arrows/left-arrow.png";
|
||||
import "./viewReport.scss";
|
||||
|
||||
export const ViewReport = () => {
|
||||
|
||||
const params = useParams();
|
||||
const [previousReportDay] = useState(new Date(params.date));
|
||||
const [nextReportDay] = useState(new Date(params.date));
|
||||
@ -37,31 +36,31 @@ export const ViewReport = () => {
|
||||
setTaskText([]);
|
||||
setDifficulties([]);
|
||||
setTomorrowTask([]);
|
||||
apiRequest(
|
||||
`reports/find-by-date?user_id=${params.id}&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
|
||||
};
|
||||
spendTime += Math.floor(task.hours_spent);
|
||||
apiRequest(`reports/find-by-date?user_id=${params.id}&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
|
||||
};
|
||||
spendTime += Math.floor(task.hours_spent);
|
||||
|
||||
setTaskText((prevArray) => [...prevArray, taskInfo]);
|
||||
});
|
||||
setTaskText((prevArray) => [...prevArray, taskInfo]);
|
||||
});
|
||||
}
|
||||
setTotalHours(Math.floor(spendTime));
|
||||
setLoader(false);
|
||||
}
|
||||
setTotalHours(Math.floor(spendTime));
|
||||
setLoader(false);
|
||||
});
|
||||
);
|
||||
previousReportDay.setDate(previousReportDay.getDate() - 1);
|
||||
nextReportDay.setDate(nextReportDay.getDate() + 1);
|
||||
}
|
||||
@ -86,7 +85,7 @@ export const ViewReport = () => {
|
||||
<Navigation />
|
||||
<div className="container">
|
||||
<div className="viewReport__info">
|
||||
{localStorage.getItem("role_status") !== "18" &&
|
||||
{localStorage.getItem("role_status") !== "18" && (
|
||||
<>
|
||||
<ProfileBreadcrumbs
|
||||
links={[
|
||||
@ -96,12 +95,18 @@ export const ViewReport = () => {
|
||||
]}
|
||||
/>
|
||||
<h2 className="viewReport__title">
|
||||
Ваши отчеты - <span>просмотр отчета за день</span>
|
||||
Ваши отчеты - <span>просмотр отчета за день</span>
|
||||
</h2>
|
||||
</>
|
||||
}
|
||||
<Link className="viewReport__back"
|
||||
to={localStorage.getItem("role_status") === "18" ? `/profile/employees/report/${params.id}` :`/profile/calendar`}>
|
||||
)}
|
||||
<Link
|
||||
className="viewReport__back"
|
||||
to={
|
||||
localStorage.getItem("role_status") === "18"
|
||||
? `/profile/employees/report/${params.id}`
|
||||
: `/profile/calendar`
|
||||
}
|
||||
>
|
||||
<img src={arrow} alt="#" />
|
||||
<p>Вернуться</p>
|
||||
</Link>
|
||||
@ -119,7 +124,9 @@ export const ViewReport = () => {
|
||||
</div>
|
||||
<div className="viewReport__switch-date">
|
||||
<div onClick={() => previousDay()}>
|
||||
<Link to={`../view/${getCreatedDate(previousReportDay)}/${params.id}`}>
|
||||
<Link
|
||||
to={`../view/${getCreatedDate(previousReportDay)}/${params.id}`}
|
||||
>
|
||||
<div className="viewReport__switch-date__prev switch-date">
|
||||
<img src={arrowSwitchDate} alt="arrow" />
|
||||
</div>
|
||||
@ -208,12 +215,13 @@ export const ViewReport = () => {
|
||||
)}
|
||||
{!Boolean(taskText.length) && !loader && (
|
||||
<div className="viewReport__noTask">
|
||||
{localStorage.getItem("role_status") === "4" ?
|
||||
{localStorage.getItem("role_status") === "4" ? (
|
||||
<p>
|
||||
В этот день вы <span>не заполняли</span> отчет
|
||||
</p> :
|
||||
</p>
|
||||
) : (
|
||||
<p>Отчет за день не заполнен</p>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<Footer />
|
||||
|
Loading…
Reference in New Issue
Block a user