employeeReport

This commit is contained in:
Mikola
2024-02-02 18:43:52 +03:00
parent dafb05619d
commit 5825015706
9 changed files with 308 additions and 80 deletions

View File

@ -20,13 +20,10 @@ import arrow from "assets/icons/arrows/left-arrow.png";
import "./viewReport.scss";
export const ViewReport = () => {
if (localStorage.getItem("role_status") === "18") {
return <Navigate to="/profile" replace />;
}
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([]);
@ -41,7 +38,7 @@ export const ViewReport = () => {
setDifficulties([]);
setTomorrowTask([]);
apiRequest(
`reports/find-by-date?user_id=${localStorage.getItem("id")}&date=${day}`
`reports/find-by-date?user_id=${params.id}&date=${day}`
).then((res) => {
let spendTime = 0;
for (const item of res) {
@ -80,7 +77,7 @@ export const ViewReport = () => {
}
useEffect(() => {
getReportFromDate(dateReport.id);
getReportFromDate(params.date);
}, []);
return (
@ -89,17 +86,22 @@ export const ViewReport = () => {
<Navigation />
<div className="container">
<div className="viewReport__info">
<ProfileBreadcrumbs
links={[
{ name: "Главная", link: "/profile" },
{ name: "Ваша отчетность", link: "/profile/calendar" },
{ name: "Просмотр отчета за день", link: "/profile/view" }
]}
/>
<h2 className="viewReport__title">
Ваши отчеты - <span>просмотр отчета за день</span>
</h2>
<Link className="viewReport__back" to={`/profile/calendar`}>
{localStorage.getItem("role_status") !== "18" &&
<>
<ProfileBreadcrumbs
links={[
{ name: "Главная", link: "/profile" },
{ name: "Ваша отчетность", link: "/profile/calendar" },
{ name: "Просмотр отчета за день", link: "/profile/view" }
]}
/>
<h2 className="viewReport__title">
Ваши отчеты - <span>просмотр отчета за день</span>
</h2>
</>
}
<Link className="viewReport__back"
to={localStorage.getItem("role_status") === "18" ? `/profile/employees/report/${params.id}` :`/profile/calendar`}>
<img src={arrow} alt="#" />
<p>Вернуться</p>
</Link>
@ -117,22 +119,22 @@ export const ViewReport = () => {
</div>
<div className="viewReport__switch-date">
<div onClick={() => previousDay()}>
<Link to={`../view/${getCreatedDate(previousReportDay)}`}>
<Link to={`../view/${getCreatedDate(previousReportDay)}/${params.id}`}>
<div className="viewReport__switch-date__prev switch-date">
<img src={arrowSwitchDate} alt="arrow" />
</div>
</Link>
</div>
<p>{getCorrectDate(dateReport.id)}</p>
<p>{getCorrectDate(params.date)}</p>
<div
onClick={() => nextDay()}
className={`${
getCreatedDate(currentDay) === dateReport.id ? "disable" : ""
getCreatedDate(currentDay) === params.date ? "disable" : ""
}`}
>
<Link to={`../view/${getCreatedDate(nextReportDay)}`}>
<Link to={`../view/${getCreatedDate(nextReportDay)}/${params.id}`}>
<div className={`viewReport__switch-date__next switch-date`}>
<img src={arrowSwitchDate} alt="arrow" />
</div>
@ -206,9 +208,12 @@ export const ViewReport = () => {
)}
{!Boolean(taskText.length) && !loader && (
<div className="viewReport__noTask">
<p>
В этот день вы <span>не заполняли</span> отчет
</p>
{localStorage.getItem("role_status") === "4" ?
<p>
В этот день вы <span>не заполняли</span> отчет
</p> :
<p>Отчет за день не заполнен</p>
}
</div>
)}
<Footer />