Merge pull request 'trackerTask' (#16) from trackerTask into main

Reviewed-on: #16
This commit is contained in:
Николай Полтщук 2024-02-07 18:56:16 +03:00
commit 81d2ee4098
13 changed files with 117 additions and 113 deletions

View File

@ -106,22 +106,15 @@ const App = () => {
<Route exact path="/candidate/:id/form" element={<FormPage />} />
<Route path="/:userId/calendar" element={<Calendar />} />
<Route exact path="/report" element={<ReportForm />} />
<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 index element={<Profile />} />
<Route exact path="catalog" element={<Home />} />
<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="view/:date/:id" element={<ViewReport />} />
<Route exact path="tracker" element={<Tracker />} />
<Route exact path="statistics/:id" element={<Statistics/>}/>
<Route exact path="payouts" element={<Payouts />} />
@ -133,6 +126,11 @@ const App = () => {
<Route exact path="employees" element={<PartnerCategories />} />
<Route exact path="employees/report/:uuid" element={<PartnerEmployeeReport />} />
<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
exact

View File

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

View File

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

View File

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

View File

@ -96,9 +96,11 @@ export const ProfileCalendarComponent = React.memo(
)}-${correctDay(new Date(day).getDate())}` === date.created_at
) {
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 +108,7 @@ export const ProfileCalendarComponent = React.memo(
return "#";
}
return "../../report";
return "/profile/calendar/report";
}
const prevMonth = () => value.clone().subtract(1, "month");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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