trackerTask #16

Merged
nik.polishuk merged 2 commits from trackerTask into main 2024-02-07 18:56:16 +03:00
13 changed files with 91 additions and 108 deletions
Showing only changes of commit b75b846335 - Show all commits

View File

@ -106,22 +106,15 @@ const App = () => {
<Route exact path="/candidate/:id/form" element={<FormPage />} /> <Route exact path="/candidate/:id/form" element={<FormPage />} />
<Route path="/:userId/calendar" element={<Calendar />} /> <Route path="/:userId/calendar" element={<Calendar />} />
<Route exact path="/report" element={<ReportForm />} />
<Route path="/report/:id" element={<SingleReportPage />} /> <Route path="/report/:id" element={<SingleReportPage />} />
<Route exact path="quiz">
<Route index element={<QuizPage />} />
<Route exact path="test/:uuid" element={<PassingTests />} />
<Route exact path="report/:uuid" element={<QuizReportPage />} />
</Route>
<Route exact path="profile"> <Route exact path="profile">
<Route index element={<Profile />} /> <Route index element={<Profile />} />
<Route exact path="catalog" element={<Home />} /> <Route exact path="catalog" element={<Home />} />
<Route exact path="calendar" element={<ProfileCalendar />} /> <Route exact path="calendar" element={<ProfileCalendar />} />
<Route exact path="calendar/view/" element={<ProfileCalendar />} /> <Route exact path="calendar/report" element={<ReportForm />} />
<Route exact path="calendar/view/:date/:id" element={<ViewReport />} />
<Route exact path="summary" element={<Summary />} /> <Route exact path="summary" element={<Summary />} />
<Route exact path="view/:date/:id" element={<ViewReport />} />
<Route exact path="tracker" element={<Tracker />} /> <Route exact path="tracker" element={<Tracker />} />
<Route exact path="statistics/:id" element={<Statistics/>}/> <Route exact path="statistics/:id" element={<Statistics/>}/>
<Route exact path="payouts" element={<Payouts />} /> <Route exact path="payouts" element={<Payouts />} />
@ -133,6 +126,11 @@ const App = () => {
<Route exact path="employees" element={<PartnerCategories />} /> <Route exact path="employees" element={<PartnerCategories />} />
<Route exact path="employees/report/:uuid" element={<PartnerEmployeeReport />} /> <Route exact path="employees/report/:uuid" element={<PartnerEmployeeReport />} />
<Route exact path="treaties" element={<PartnerTreaties />} /> <Route exact path="treaties" element={<PartnerTreaties />} />
<Route exact path="quiz">
<Route index element={<QuizPage />} />
<Route exact path="test/:uuid" element={<PassingTests />} />
<Route exact path="report/:uuid" element={<QuizReportPage />} />
</Route>
<Route <Route
exact exact

View File

@ -60,7 +60,7 @@ const Calendar = () => {
<img className="calendar__title-img" src={rectangle} alt="img" /> <img className="calendar__title-img" src={rectangle} alt="img" />
</div> </div>
<div> <div>
<Link to="/report"> <Link to="/profile/calendar/report">
<button className="calendar__btn">Заполнить отчет</button> <button className="calendar__btn">Заполнить отчет</button>
</Link> </Link>
</div> </div>

View File

@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import { getProfileInfo } from "@redux/outstaffingSlice"; import { getProfileInfo } from "@redux/outstaffingSlice";
@ -9,9 +9,9 @@ import { urlForLocal } from "@utils/helper";
import avatarMok from "assets/images/avatarMok.png"; import avatarMok from "assets/images/avatarMok.png";
export const Navigation = () => { export const Navigation = () => {
const dispatch = useDispatch();
const profileInfo = useSelector(getProfileInfo); const profileInfo = useSelector(getProfileInfo);
const currentPath = window.location.pathname;
const [user] = useState( const [user] = useState(
localStorage.getItem("role_status") === "18" ? "partner" : "developer" localStorage.getItem("role_status") === "18" ? "partner" : "developer"
); );
@ -35,7 +35,7 @@ export const Navigation = () => {
name: "Выплаты" name: "Выплаты"
}, },
{ {
path: "/Quiz", path: "/quiz",
name: "Тесты" name: "Тесты"
}, },
{ {
@ -81,6 +81,7 @@ export const Navigation = () => {
key={index} key={index}
end end
to={link.path === "/Quiz" ? link.path : `/profile${link.path}`} to={link.path === "/Quiz" ? link.path : `/profile${link.path}`}
className={currentPath. includes(link.path) ? 'active' : ''}
> >
{link.name} {link.name}
</NavLink> </NavLink>

View File

@ -98,7 +98,7 @@ export const ProfileCalendar = () => {
{profileInfo.specification} разработчик {profileInfo.specification} разработчик
</p> </p>
</div> </div>
<Link to="/report"> <Link to="/profile/calendar/report">
<button <button
className="calendar__btn" className="calendar__btn"
onClick={() => dispatch(setReportDate(""))} onClick={() => dispatch(setReportDate(""))}

View File

@ -96,9 +96,9 @@ 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 `/profile/calendar/view/${date.created_at}/${userId}`;
} }
return `../view/${date.created_at}/${localStorage.getItem("id")}`; return `/profile/calendar/view/${date.created_at}/${localStorage.getItem("id")}`;
} }
} }
@ -106,7 +106,7 @@ export const ProfileCalendarComponent = React.memo(
return "#"; return "#";
} }
return "../../report"; return "/profile/calendar/report";
} }
const prevMonth = () => value.clone().subtract(1, "month"); const prevMonth = () => value.clone().subtract(1, "month");

View File

@ -87,10 +87,12 @@ const ReportForm = () => {
}; };
const handler = () => { const handler = () => {
setIsFetching(true)
for (let input of inputs) { for (let input of inputs) {
if (!input.task || !input.hours_spent) { if (!input.task || !input.hours_spent) {
setReportSuccess("Заполните задачи"); setReportSuccess("Заполните задачи");
setTimeout(() => setReportSuccess(""), 2000); setTimeout(() => setReportSuccess(""), 2000);
setIsFetching(false)
return; return;
} }
} }
@ -292,12 +294,15 @@ const ReportForm = () => {
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
<div className="report-form__footer"> <div className="report-form__footer">
<button {isFetching ?
className="report-form__footer-btn" <Loader style={'green'} /> :
onClick={() => handler()} <button
> className="report-form__footer-btn"
{isFetching ? <Loader /> : "Отправить"} onClick={() => handler()}
</button> >
Отпаравить
</button>
}
<p className="report-form__footer-text"> <p className="report-form__footer-text">
Всего за день:{" "} Всего за день:{" "}
<span> <span>

View File

@ -80,7 +80,7 @@ export const ShortReport = () => {
<h2 className="viewReport__title"> <h2 className="viewReport__title">
Ваши отчеты - <span>просмотр отчета за день</span> Ваши отчеты - <span>просмотр отчета за день</span>
</h2> </h2>
<Link to={`../view/${dateCreate}`}>Посмотреть подробный отчет</Link> <Link to={`/profile/calendar/view/${dateCreate}`}>Посмотреть подробный отчет</Link>
</div> </div>
<div className="viewReport__bar"> <div className="viewReport__bar">

View File

@ -9,7 +9,7 @@ export const CardAvailableTest = ({ title, description, path, status }) => {
return ( return (
<div className="card-available-test"> <div className="card-available-test">
<Link <Link
to={status === 2 ? `/quiz/report/${path}` : `/quiz/test/${path}`} to={status === 2 ? `/profile/quiz/report/${path}` : `/profile/quiz/test/${path}`}
aria-disabled={true} aria-disabled={true}
className="card-available-test__container" className="card-available-test__container"
style={ style={
@ -33,7 +33,7 @@ export const CardAvailableTest = ({ title, description, path, status }) => {
{status === 2 && ( {status === 2 && (
<div className="card-available-test__finished"> <div className="card-available-test__finished">
<p>Получить отчет по тестированию</p> <p>Получить отчет по тестированию</p>
<Link to={`/quiz/report/${path}`}>Отчет по тесту</Link> <Link to={`/profile/quiz/report/${path}`}>Отчет по тесту</Link>
</div> </div>
)} )}
</div> </div>

View File

@ -120,12 +120,12 @@ export const PassingTests = () => {
))} ))}
</div> </div>
)} )}
{!startTest && ( {/*{!startTest && (*/}
<div className="passing-tests-page__block-text block-text"> {/* <div className="passing-tests-page__block-text block-text">*/}
ИЛИ <Link to={""}>выполните тестовое задание</Link>, без {/* ИЛИ <Link to={""}>выполните тестовое задание</Link>, без*/}
прохождения тестов {/* прохождения тестов*/}
</div> {/* </div>*/}
)} {/*)}*/}
</> </>
)} )}
{completedTest && ( {completedTest && (

View File

@ -144,10 +144,10 @@ export const QuizPage = () => {
<h1>Анкет нет</h1> <h1>Анкет нет</h1>
)} )}
</div> </div>
<div className="block-text"> {/*<div className="block-text">*/}
ИЛИ <Link to={""}>выполните тестовое задание</Link>, без {/* ИЛИ <Link to={""}>выполните тестовое задание</Link>, без*/}
прохождения тестов {/* прохождения тестов*/}
</div> {/*</div>*/}
</> </>
)} )}
{selectedCategory && ( {selectedCategory && (

View File

@ -42,8 +42,8 @@ export const QuizReportPage = () => {
<ProfileBreadcrumbs <ProfileBreadcrumbs
links={[ links={[
{ name: "Главная", link: "/profile-candidate" }, { name: "Главная", link: "/profile-candidate" },
{ name: "Тестирование", link: "/Quiz" }, { name: "Тестирование", link: "/profile/quiz" },
{ name: "Отчет по тестированию", link: "/Quiz/report" } { name: "Отчет по тестированию", link: "/profile/quiz" }
]} ]}
/> />
<div className="quiz-report-page__title main-title"> <div className="quiz-report-page__title main-title">

View File

@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Link, Navigate, useParams } from "react-router-dom"; import { Link, useParams } from "react-router-dom";
import { apiRequest } from "@api/request"; import { apiRequest } from "@api/request";
@ -27,9 +27,11 @@ export const ViewReport = () => {
const [taskText, setTaskText] = useState([]); const [taskText, setTaskText] = useState([]);
const [difficulties, setDifficulties] = useState([]); const [difficulties, setDifficulties] = useState([]);
const [tomorrowTask, setTomorrowTask] = useState([]); const [tomorrowTask, setTomorrowTask] = useState([]);
const [taskId, setTaskId] = useState('')
const [totalHours, setTotalHours] = useState(0); const [totalHours, setTotalHours] = useState(0);
const [currentDay] = useState(new Date()); const [currentDay] = useState(new Date());
const [loader, setLoader] = useState(false); const [loader, setLoader] = useState(false);
const [deleteLoader, setDeleteLoader] = useState(false)
function getReportFromDate(day) { function getReportFromDate(day) {
setLoader(true); setLoader(true);
@ -39,6 +41,7 @@ export const ViewReport = () => {
apiRequest(`reports/find-by-date?user_id=${params.id}&date=${day}`).then( apiRequest(`reports/find-by-date?user_id=${params.id}&date=${day}`).then(
(res) => { (res) => {
let spendTime = 0; let spendTime = 0;
setTaskId(res[0]?.id)
for (const item of res) { for (const item of res) {
if (item.difficulties) { if (item.difficulties) {
setDifficulties((prevArray) => [...prevArray, item.difficulties]); setDifficulties((prevArray) => [...prevArray, item.difficulties]);
@ -65,6 +68,18 @@ export const ViewReport = () => {
nextReportDay.setDate(nextReportDay.getDate() + 1); nextReportDay.setDate(nextReportDay.getDate() + 1);
} }
function deleteReport() {
setDeleteLoader(true)
apiRequest(`reports/delete?id=${taskId}`, {
method: "DELETE"
}).then((res) => {
setDeleteLoader(false)
if (res) {
window.location.replace("/profile/calendar")
}
});
}
function nextDay() { function nextDay() {
getReportFromDate(getCreatedDate(nextReportDay)); getReportFromDate(getCreatedDate(nextReportDay));
previousReportDay.setDate(previousReportDay.getDate() + 2); previousReportDay.setDate(previousReportDay.getDate() + 2);
@ -110,22 +125,23 @@ export const ViewReport = () => {
<img src={arrow} alt="#" /> <img src={arrow} alt="#" />
<p>Вернуться</p> <p>Вернуться</p>
</Link> </Link>
{/* <div className="viewReport__bar"> {localStorage.getItem("role_status") !== "18" &&
<h3 className="viewReport__bar__date"> <div className="viewReport__bar">
{getCorrectDate(dateReport.id)} <button className="viewReport__bar__edit">
</h3> Редактировать
<p className="viewReport__bar__hours"> </button>
Вами потрачено на работу:{" "} {deleteLoader ? <Loader style={'green'} /> :
<span> <button onClick={deleteReport} className={taskText.length ? "viewReport__bar__delete" : "viewReport__bar__delete disable"}>
{totalHours} {hourOfNum(totalHours)} Удалить отчет
</span> </button>
</p> }
</div> */} </div>
}
</div> </div>
<div className="viewReport__switch-date"> <div className="viewReport__switch-date">
<div onClick={() => previousDay()}> <div onClick={() => previousDay()}>
<Link <Link
to={`../view/${getCreatedDate(previousReportDay)}/${params.id}`} to={`/profile/calendar/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" />
@ -141,7 +157,7 @@ export const ViewReport = () => {
getCreatedDate(currentDay) === params.date ? "disable" : "" getCreatedDate(currentDay) === params.date ? "disable" : ""
}`} }`}
> >
<Link to={`../view/${getCreatedDate(nextReportDay)}/${params.id}`}> <Link to={`/profile/calendar/view/${getCreatedDate(nextReportDay)}/${params.id}`}>
<div className={`viewReport__switch-date__next switch-date`}> <div className={`viewReport__switch-date__next switch-date`}>
<img src={arrowSwitchDate} alt="arrow" /> <img src={arrowSwitchDate} alt="arrow" />
</div> </div>

View File

@ -64,71 +64,34 @@
height: 72px; height: 72px;
justify-content: space-between; justify-content: space-between;
@media (max-width: 540px) { button {
padding: 10px 15px;
height: 60px;
}
@media (max-width: 500px) {
column-gap: 0;
justify-content: space-between;
}
&__date {
font-weight: 500;
font-size: 22px;
line-height: 32px;
color: #000000; color: #000000;
@media (max-width: 660px) {
font-size: 16px;
}
@media (max-width: 490px) {
font-size: 12px;
}
}
&__hours {
font-weight: 400;
font-size: 15px; font-size: 15px;
font-weight: 500;
line-height: 32px; line-height: 32px;
color: #000000; padding: 8px 24px;
@media (max-width: 660px) {
font-size: 11px;
}
span {
color: #52B709;
font-weight: 700;
}
} }
&__progressBar { &__edit {
max-width: 390px; background: #E1FCCF;
width: 100%; border-radius: 44px;
background: #F1F1F1; border: none;
}
&__delete {
background: white;
border-radius: 12px; border-radius: 12px;
height: 8px; border: 1px dashed #8BCC60;
position: relative;
span {
position: absolute;
height: 100%;
left: 0;
width: 60%;
background: #52B709;
border-radius: 12px;
}
} }
&__total { .disable {
font-weight: 400; pointer-events: none;
font-size: 12px; opacity: 0.5;
line-height: 32px;
} }
.loader {
max-width: 150px;
}
} }
h3 { h3 {