employeeReport

This commit is contained in:
Mikola 2024-02-02 18:44:11 +03:00
parent 5825015706
commit 8a2876e30b
5 changed files with 100 additions and 89 deletions

View File

@ -15,7 +15,10 @@ export const PartnerPersonCard = ({ name, img, userId }) => {
</div> </div>
<div className="partnerPersonCard__info"> <div className="partnerPersonCard__info">
<h2 className="partnerPersonCard__name">{name}</h2> <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"> <div className="partnerPersonCard__more">
<img src={rightArrow} alt="arrow" /> <img src={rightArrow} alt="arrow" />

View File

@ -96,14 +96,14 @@ export const ProfileCalendarComponent = React.memo(
)}-${correctDay(new Date(day).getDate())}` === date.created_at )}-${correctDay(new Date(day).getDate())}` === date.created_at
) { ) {
if (userId) { if (userId) {
return `../view/${date.created_at}/${userId}` return `../view/${date.created_at}/${userId}`;
} }
return `../view/${date.created_at}/${localStorage.getItem("id")}`; return `../view/${date.created_at}/${localStorage.getItem("id")}`;
} }
} }
if (userId) { if (userId) {
return "#" return "#";
} }
return "../../report"; return "../../report";
@ -123,7 +123,9 @@ export const ProfileCalendarComponent = React.memo(
startDate._d startDate._d
)}`; )}`;
apiRequest( apiRequest(
`/reports/index?${requestDates}&user_id=${userId ? userId : localStorage.getItem("id")}` `/reports/index?${requestDates}&user_id=${
userId ? userId : localStorage.getItem("id")
}`
).then((reports) => { ).then((reports) => {
let spendTime = 0; let spendTime = 0;
reports.map((report) => { reports.map((report) => {
@ -172,9 +174,7 @@ export const ProfileCalendarComponent = React.memo(
<div className="calendar-component"> <div className="calendar-component">
<div className="calendar-component__header"> <div className="calendar-component__header">
<div className="calendar-component__header-info"> <div className="calendar-component__header-info">
{!userId && {!userId && <h3>Мои отчеты за </h3>}
<h3>Мои отчеты за </h3>
}
<p className="calendar__hours"> <p className="calendar__hours">
{month}&nbsp; {month}&nbsp;
<span> <span>

View File

@ -1,20 +1,21 @@
import moment from "moment/moment";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Navigate, useParams } from "react-router-dom"; import { Navigate, useParams } from "react-router-dom";
import { Footer } from "@components/Common/Footer/Footer"; import { getRequestDates, setRequestDate } from "@redux/reportSlice";
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 { apiRequest } from "@api/request"; 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 { getReports } from "@components/Calendar/calendarHelper";
import { Footer } from "@components/Common/Footer/Footer";
import { Loader } from "@components/Common/Loader/Loader"; 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 = () => { export const PartnerEmployeeReport = () => {
// if ( // if (
@ -25,7 +26,7 @@ export const PartnerEmployeeReport = () => {
const params = useParams(); const params = useParams();
const dispatch = useDispatch(); const dispatch = useDispatch();
const [userInfo, setUserInfo] = useState({}) const [userInfo, setUserInfo] = useState({});
const [value, setValue] = useState(moment()); const [value, setValue] = useState(moment());
const [reports, setReports] = useState([]); const [reports, setReports] = useState([]);
const [totalHours, setTotalHours] = useState(0); const [totalHours, setTotalHours] = useState(0);
@ -39,21 +40,18 @@ export const PartnerEmployeeReport = () => {
}, []); }, []);
useEffect(() => { useEffect(() => {
apiRequest( apiRequest(`/resume?userId=${params.uuid}`).then((res) => {
`/resume?userId=${params.uuid}` setUserInfo(res);
).then((res) => {
setUserInfo(res)
}); });
}, []) }, []);
useEffect(() => { useEffect(() => {
setLoader(true); setLoader(true);
if (!requestDates) { if (!requestDates) {
return; return;
} }
apiRequest( apiRequest(`/reports/index?${requestDates}&user_id=${params.uuid}`).then(
`/reports/index?${requestDates}&user_id=${params.uuid}` (reports) => {
).then((reports) => {
let spendTime = 0; let spendTime = 0;
reports reports
@ -70,7 +68,8 @@ export const PartnerEmployeeReport = () => {
setTotalHours(Math.floor(spendTime)); setTotalHours(Math.floor(spendTime));
setReports(reports); setReports(reports);
setLoader(false); setLoader(false);
}); }
);
}, [requestDates]); }, [requestDates]);
return ( return (
@ -84,11 +83,11 @@ export const PartnerEmployeeReport = () => {
{ name: "Данные моего персонала", link: "/profile/employees" } { name: "Данные моего персонала", link: "/profile/employees" }
]} ]}
/> />
{!Object.keys(userInfo).length ? {!Object.keys(userInfo).length ? (
<div className="employeeReport__loader"> <div className="employeeReport__loader">
<Loader style={'green'} height={80} width={80} /> <Loader style={"green"} height={80} width={80} />
</div> </div>
: ) : (
<> <>
<div className="employeeReport__info"> <div className="employeeReport__info">
<div className="employeeReport__name"> <div className="employeeReport__name">
@ -96,15 +95,16 @@ export const PartnerEmployeeReport = () => {
<p>{userInfo.position}</p> <p>{userInfo.position}</p>
</div> </div>
<div className="employeeReport__skills"> <div className="employeeReport__skills">
{userInfo?.stack && userInfo.stack.map((skill, index) => { {userInfo?.stack &&
return <span key={index}>{skill}</span> userInfo.stack.map((skill, index) => {
return <span key={index}>{skill}</span>;
})} })}
</div> </div>
</div> </div>
<div className="employeeReport__wrapper"> <div className="employeeReport__wrapper">
{loader ? ( {loader ? (
<div className="employeeReport__loader"> <div className="employeeReport__loader">
<Loader style={'green'} height={80} width={80} /> <Loader style={"green"} height={80} width={80} />
</div> </div>
) : ( ) : (
<div className="employeeReport__calendar "> <div className="employeeReport__calendar ">
@ -123,7 +123,7 @@ export const PartnerEmployeeReport = () => {
)} )}
</div> </div>
</> </>
} )}
</div> </div>
<Footer /> <Footer />
</div> </div>

View File

@ -7,6 +7,7 @@ import { apiRequest } from "@api/request";
// import { setPartnerEmployees } from "@redux/outstaffingSlice"; // import { setPartnerEmployees } from "@redux/outstaffingSlice";
import { Footer } from "@components/Common/Footer/Footer"; import { Footer } from "@components/Common/Footer/Footer";
import { Loader } from "@components/Common/Loader/Loader";
import { Navigation } from "@components/Navigation/Navigation"; import { Navigation } from "@components/Navigation/Navigation";
import PartnerPersonCard from "@components/PartnerPersonCard/PartnerPersonCard"; import PartnerPersonCard from "@components/PartnerPersonCard/PartnerPersonCard";
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; 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 TestImg from "assets/images/partnerProfile/PersonalTesters.svg";
// import BackEndImg from "assets/images/partnerProfile/personalBackEnd.svg"; // import BackEndImg from "assets/images/partnerProfile/personalBackEnd.svg";
import "./partnerСategories.scss"; import "./partnerСategories.scss";
import { Loader } from "@components/Common/Loader/Loader";
export const PartnerCategories = () => { export const PartnerCategories = () => {
// const dispatch = useDispatch(); // const dispatch = useDispatch();
@ -33,12 +33,12 @@ export const PartnerCategories = () => {
} }
const [staff, setStaff] = useState([]); const [staff, setStaff] = useState([]);
const [loader, setLoader] = useState(false) const [loader, setLoader] = useState(false);
useEffect(() => { useEffect(() => {
setLoader(true) setLoader(true);
apiRequest("/project/my-employee").then((el) => { apiRequest("/project/my-employee").then((el) => {
setLoader(false) setLoader(false);
setStaff(el.managerEmployees); setStaff(el.managerEmployees);
}); });
}, []); }, []);
@ -157,9 +157,9 @@ export const PartnerCategories = () => {
]} ]}
/> />
<h2 className="partnerCategories__title">Данные персонала</h2> <h2 className="partnerCategories__title">Данные персонала</h2>
{loader ? {loader ? (
<Loader style={'green'} height={80} width={80} /> <Loader style={"green"} height={80} width={80} />
: ) : (
<div className="partnerCategories__items"> <div className="partnerCategories__items">
{staff.map((card) => { {staff.map((card) => {
return ( return (
@ -205,7 +205,7 @@ export const PartnerCategories = () => {
{/* );*/} {/* );*/}
{/*})}*/} {/*})}*/}
</div> </div>
} )}
</div> </div>
<Footer /> <Footer />
</div> </div>

View File

@ -20,7 +20,6 @@ import arrow from "assets/icons/arrows/left-arrow.png";
import "./viewReport.scss"; import "./viewReport.scss";
export const ViewReport = () => { export const ViewReport = () => {
const params = useParams(); const params = useParams();
const [previousReportDay] = useState(new Date(params.date)); const [previousReportDay] = useState(new Date(params.date));
const [nextReportDay] = useState(new Date(params.date)); const [nextReportDay] = useState(new Date(params.date));
@ -37,9 +36,8 @@ export const ViewReport = () => {
setTaskText([]); setTaskText([]);
setDifficulties([]); setDifficulties([]);
setTomorrowTask([]); setTomorrowTask([]);
apiRequest( apiRequest(`reports/find-by-date?user_id=${params.id}&date=${day}`).then(
`reports/find-by-date?user_id=${params.id}&date=${day}` (res) => {
).then((res) => {
let spendTime = 0; let spendTime = 0;
for (const item of res) { for (const item of res) {
if (item.difficulties) { if (item.difficulties) {
@ -61,7 +59,8 @@ export const ViewReport = () => {
} }
setTotalHours(Math.floor(spendTime)); setTotalHours(Math.floor(spendTime));
setLoader(false); setLoader(false);
}); }
);
previousReportDay.setDate(previousReportDay.getDate() - 1); previousReportDay.setDate(previousReportDay.getDate() - 1);
nextReportDay.setDate(nextReportDay.getDate() + 1); nextReportDay.setDate(nextReportDay.getDate() + 1);
} }
@ -86,7 +85,7 @@ export const ViewReport = () => {
<Navigation /> <Navigation />
<div className="container"> <div className="container">
<div className="viewReport__info"> <div className="viewReport__info">
{localStorage.getItem("role_status") !== "18" && {localStorage.getItem("role_status") !== "18" && (
<> <>
<ProfileBreadcrumbs <ProfileBreadcrumbs
links={[ links={[
@ -99,9 +98,15 @@ export const ViewReport = () => {
Ваши отчеты - <span>просмотр отчета за день</span> Ваши отчеты - <span>просмотр отчета за день</span>
</h2> </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="#" /> <img src={arrow} alt="#" />
<p>Вернуться</p> <p>Вернуться</p>
</Link> </Link>
@ -119,7 +124,9 @@ export const ViewReport = () => {
</div> </div>
<div className="viewReport__switch-date"> <div className="viewReport__switch-date">
<div onClick={() => previousDay()}> <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"> <div className="viewReport__switch-date__prev switch-date">
<img src={arrowSwitchDate} alt="arrow" /> <img src={arrowSwitchDate} alt="arrow" />
</div> </div>
@ -208,12 +215,13 @@ export const ViewReport = () => {
)} )}
{!Boolean(taskText.length) && !loader && ( {!Boolean(taskText.length) && !loader && (
<div className="viewReport__noTask"> <div className="viewReport__noTask">
{localStorage.getItem("role_status") === "4" ? {localStorage.getItem("role_status") === "4" ? (
<p> <p>
В этот день вы <span>не заполняли</span> отчет В этот день вы <span>не заполняли</span> отчет
</p> : </p>
) : (
<p>Отчет за день не заполнен</p> <p>Отчет за день не заполнен</p>
} )}
</div> </div>
)} )}
<Footer /> <Footer />