active links in nav, delete report, loaders in report, changes routes

This commit is contained in:
Mikola
2024-02-07 18:54:21 +03:00
parent 455be87e26
commit b75b846335
13 changed files with 91 additions and 108 deletions

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,23 @@ 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 +157,7 @@ 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;
}
span {
color: #52B709;
font-weight: 700;
}
padding: 8px 24px;
}
&__progressBar {
max-width: 390px;
width: 100%;
background: #F1F1F1;
&__edit {
background: #E1FCCF;
border-radius: 44px;
border: none;
}
&__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 {