diff --git a/src/App.js b/src/App.js index d6aa71f0..09f15c57 100644 --- a/src/App.js +++ b/src/App.js @@ -42,6 +42,7 @@ import { PartnerEmployees } from "@pages/PartnerEmployees/PartnerEmployees"; import { AuthForCandidate } from "@pages/AuthForCandidate/AuthForCandidate"; import { RegistrationForCandidate } from "@pages/RegistrationForCandidate/RegistrationForCandidate"; import { ProfileCandidate } from "@pages/ProfileCandidate/ProfileCandidate"; +import { PartnerEmployeeReport } from "@pages/PartnerEmployeeReport/PartnerEmployeeReport"; import { PassingTests } from "@pages/Quiz/PassingTests"; import Blog from "./pages/Blog/Blog"; import Statistics from "@pages/Statistics/Statistics"; @@ -120,7 +121,7 @@ const App = () => { } /> } /> } /> - } /> + } /> } /> }/> } /> @@ -129,8 +130,10 @@ const App = () => { } /> } /> } /> - } /> + } /> + } /> } /> + { name: "Запросы" }, { - path: "/categories", + path: "/employees", name: "Персонал" }, { diff --git a/src/components/PartnerPersonCard/PartnerPersonCard.jsx b/src/components/PartnerPersonCard/PartnerPersonCard.jsx index 0679b42c..ac62ebb2 100644 --- a/src/components/PartnerPersonCard/PartnerPersonCard.jsx +++ b/src/components/PartnerPersonCard/PartnerPersonCard.jsx @@ -15,7 +15,10 @@ export const PartnerPersonCard = ({ name, img, userId }) => {

{name}

- + Подробный отчет
arrow diff --git a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx index 37335a3b..dc3b55c7 100644 --- a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx +++ b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx @@ -32,6 +32,7 @@ import rectangle from "assets/images/rectangle__calendar.png"; export const ProfileCalendarComponent = React.memo( ({ + userId, value, setValueHandler, reports, @@ -94,9 +95,17 @@ export const ProfileCalendarComponent = React.memo( new Date(day).getMonth() + 1 )}-${correctDay(new Date(day).getDate())}` === date.created_at ) { - return `../view/${date.created_at}`; + if (userId) { + return `../view/${date.created_at}/${userId}`; + } + return `../view/${date.created_at}/${localStorage.getItem("id")}`; } } + + if (userId) { + return "#"; + } + return "../../report"; } @@ -114,7 +123,9 @@ export const ProfileCalendarComponent = React.memo( startDate._d )}`; apiRequest( - `/reports/index?${requestDates}&user_id =${localStorage.getItem("id")}` + `/reports/index?${requestDates}&user_id=${ + userId ? userId : localStorage.getItem("id") + }` ).then((reports) => { let spendTime = 0; reports.map((report) => { @@ -163,7 +174,7 @@ export const ProfileCalendarComponent = React.memo(
-

Мои отчеты за

+ {!userId &&

Мои отчеты за

}

{month}  diff --git a/src/pages/PartnerEmployeeReport/PartnerEmployeeReport.jsx b/src/pages/PartnerEmployeeReport/PartnerEmployeeReport.jsx new file mode 100644 index 00000000..8906d88d --- /dev/null +++ b/src/pages/PartnerEmployeeReport/PartnerEmployeeReport.jsx @@ -0,0 +1,131 @@ +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 { getRequestDates, setRequestDate } from "@redux/reportSlice"; + +import { apiRequest } from "@api/request"; + +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 ( + // localStorage.getItem("role_status") !== "18" + // ) { + // return ; + // } + + const params = useParams(); + const dispatch = useDispatch(); + const [userInfo, setUserInfo] = useState({}); + const [value, setValue] = useState(moment()); + const [reports, setReports] = useState([]); + const [totalHours, setTotalHours] = useState(0); + const requestDates = useSelector(getRequestDates); + const [startRangeDays, setStartRangeDays] = useState(false); + const [startDate, setStartDate] = useState(null); + const [loader, setLoader] = useState(true); + + useEffect(() => { + dispatch(setRequestDate(getReports(moment()))); + }, []); + + useEffect(() => { + 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; + + 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); + } + ); + }, [requestDates]); + + return ( +

+ + +
+ + {!Object.keys(userInfo).length ? ( +
+ +
+ ) : ( + <> +
+
+

{userInfo.fio}

+

{userInfo.position}

+
+
+ {userInfo?.stack && + userInfo.stack.map((skill, index) => { + return {skill}; + })} +
+
+
+ {loader ? ( +
+ +
+ ) : ( +
+ setValue(value)} + value={value} + reports={reports} + totalHours={totalHours} + startRangeDays={startRangeDays} + toggleRangeDays={() => setStartRangeDays(!startRangeDays)} + startDate={startDate} + setStartDateRange={(date) => setStartDate(date)} + /> +
+ )} +
+ + )} +
+
+
+ ); +}; diff --git a/src/pages/PartnerEmployeeReport/partnerEmployeeReport.scss b/src/pages/PartnerEmployeeReport/partnerEmployeeReport.scss new file mode 100644 index 00000000..7e5953d8 --- /dev/null +++ b/src/pages/PartnerEmployeeReport/partnerEmployeeReport.scss @@ -0,0 +1,70 @@ +.employeeReport { + background: #F1F1F1; + height: 100%; + min-height: 100vh; + font-family: "LabGrotesque", sans-serif; + + .container { + margin-top: 23px; + } + + &__info { + padding: 10px 15px; + background: white; + display: flex; + border-radius: 15px; + column-gap: 15px; + align-items: center; + } + + &__name { + display: flex; + flex-direction: column; + row-gap: 10px; + width: 100%; + h2 { + font-size: 20px; + margin-bottom: 0; + } + + p { + font-size: 15px; + } + } + + &__skills { + display: flex; + flex-wrap: wrap; + gap: 7px; + width: 100%; + + span { + font-size: 12px; + line-height: 14px; + color: #263238; + background: #8DC63F; + border-radius: 12px; + padding: 5px; + max-width: 130px; + height: 24px; + display: flex; + align-items: center; + padding: 0 10px; + } + } + + &__calendar { + width: 100%; + } + + &__wrapper { + display: flex; + align-items: center; + justify-content: center; + min-height: 620px; + } + + &__loader { + margin: 20px; + } +} diff --git a/src/pages/PartnerСategories/PartnerСategories.jsx b/src/pages/PartnerСategories/PartnerСategories.jsx index e5982164..4ebf2784 100644 --- a/src/pages/PartnerСategories/PartnerСategories.jsx +++ b/src/pages/PartnerСategories/PartnerСategories.jsx @@ -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"; @@ -32,9 +33,12 @@ export const PartnerCategories = () => { } const [staff, setStaff] = useState([]); + const [loader, setLoader] = useState(false); useEffect(() => { + setLoader(true); apiRequest("/project/my-employee").then((el) => { + setLoader(false); setStaff(el.managerEmployees); }); }, []); @@ -149,55 +153,59 @@ export const PartnerCategories = () => {

Данные персонала

-
- {staff.map((card) => { - return ( - - ); - })} - {/*{personalInfoItems.map((item, index) => {*/} - {/* return (*/} - {/* {*/} - {/* dispatch(setPartnerEmployees(mokPersons));*/} - {/* }}*/} - {/* >*/} - {/*
*/} - {/* {item.title}*/} - {/*

{item.title}

*/} - {/*
*/} - {/*
*/} - {/*

{item.description}

*/} - {/*
*/} - {/* arrow*/} - {/*
*/} - {/*
*/} - {/* {!item.available && (*/} - {/*
*/} - {/*

У вас нет персонала из категории

*/} - {/* */} - {/*
*/} - {/* )}*/} - {/* */} - {/* );*/} - {/*})}*/} -
+ {loader ? ( + + ) : ( +
+ {staff.map((card) => { + return ( + + ); + })} + {/*{personalInfoItems.map((item, index) => {*/} + {/* return (*/} + {/* {*/} + {/* dispatch(setPartnerEmployees(mokPersons));*/} + {/* }}*/} + {/* >*/} + {/*
*/} + {/* {item.title}*/} + {/*

{item.title}

*/} + {/*
*/} + {/*
*/} + {/*

{item.description}

*/} + {/*
*/} + {/* arrow*/} + {/*
*/} + {/*
*/} + {/* {!item.available && (*/} + {/*
*/} + {/*

У вас нет персонала из категории

*/} + {/* */} + {/*
*/} + {/* )}*/} + {/* */} + {/* );*/} + {/*})}*/} +
+ )}
diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index ce43476e..976330fa 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -973,7 +973,7 @@ export const ProjectTracker = () => {
filesImg - {task.files ? task.files : 0}{" "} + {task.file_count ? task.file_count : 0}{" "} {/* {caseOfNum(0, "files")} */}
diff --git a/src/pages/ViewReport/ViewReport.jsx b/src/pages/ViewReport/ViewReport.jsx index 56d9f2e8..d9e5ffe6 100644 --- a/src/pages/ViewReport/ViewReport.jsx +++ b/src/pages/ViewReport/ViewReport.jsx @@ -20,13 +20,9 @@ import arrow from "assets/icons/arrows/left-arrow.png"; import "./viewReport.scss"; export const ViewReport = () => { - if (localStorage.getItem("role_status") === "18") { - return ; - } - - const dateReport = useParams(); - const [previousReportDay] = useState(new Date(dateReport.id)); - const [nextReportDay] = useState(new Date(dateReport.id)); + const params = useParams(); + const [previousReportDay] = useState(new Date(params.date)); + const [nextReportDay] = useState(new Date(params.date)); const [taskText, setTaskText] = useState([]); const [difficulties, setDifficulties] = useState([]); @@ -40,31 +36,31 @@ export const ViewReport = () => { setTaskText([]); setDifficulties([]); setTomorrowTask([]); - apiRequest( - `reports/find-by-date?user_id=${localStorage.getItem("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); } @@ -80,7 +76,7 @@ export const ViewReport = () => { } useEffect(() => { - getReportFromDate(dateReport.id); + getReportFromDate(params.date); }, []); return ( @@ -89,17 +85,28 @@ export const ViewReport = () => {
- -

- Ваши отчеты - просмотр отчета за день -

- + {localStorage.getItem("role_status") !== "18" && ( + <> + +

+ Ваши отчеты - просмотр отчета за день +

+ + )} + #

Вернуться

@@ -117,22 +124,24 @@ export const ViewReport = () => {
previousDay()}> - +
arrow
-

{getCorrectDate(dateReport.id)}

+

{getCorrectDate(params.date)}

nextDay()} className={`${ - getCreatedDate(currentDay) === dateReport.id ? "disable" : "" + getCreatedDate(currentDay) === params.date ? "disable" : "" }`} > - +
arrow
@@ -206,9 +215,13 @@ export const ViewReport = () => { )} {!Boolean(taskText.length) && !loader && (
-

- В этот день вы не заполняли отчет -

+ {localStorage.getItem("role_status") === "4" ? ( +

+ В этот день вы не заполняли отчет +

+ ) : ( +

Отчет за день не заполнен

+ )}
)}