From b75b8463350b7e194566ff0f63ee56fb2e6fe001 Mon Sep 17 00:00:00 2001 From: Mikola Date: Wed, 7 Feb 2024 18:54:21 +0300 Subject: [PATCH 1/2] active links in nav, delete report, loaders in report, changes routes --- src/App.js | 16 ++-- src/components/Calendar/Calendar.jsx | 2 +- src/components/Navigation/Navigation.jsx | 9 ++- .../ProfileCalendar/ProfileCalendar.jsx | 2 +- .../ProfileCalendarComponent.jsx | 6 +- src/components/ReportForm/ReportForm.jsx | 17 +++-- src/components/ShortReport/ShortReport.jsx | 2 +- .../features/quiz/CardAviableTest.jsx | 4 +- src/pages/Quiz/PassingTests.js | 12 +-- src/pages/Quiz/QuizPage.js | 8 +- src/pages/Quiz/QuizReportPage.js | 4 +- src/pages/ViewReport/ViewReport.jsx | 44 +++++++---- src/pages/ViewReport/viewReport.scss | 73 +++++-------------- 13 files changed, 91 insertions(+), 108 deletions(-) diff --git a/src/App.js b/src/App.js index 09f15c57..ebacc0f0 100644 --- a/src/App.js +++ b/src/App.js @@ -106,22 +106,15 @@ const App = () => { } /> } /> - } /> } /> - - } /> - } /> - } /> - - } /> } /> } /> - } /> + } /> + } /> } /> - } /> } /> }/> } /> @@ -133,6 +126,11 @@ const App = () => { } /> } /> } /> + + } /> + } /> + } /> + { img
- +
diff --git a/src/components/Navigation/Navigation.jsx b/src/components/Navigation/Navigation.jsx index 3d5758f7..4270c886 100644 --- a/src/components/Navigation/Navigation.jsx +++ b/src/components/Navigation/Navigation.jsx @@ -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,9 @@ 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 +35,7 @@ export const Navigation = () => { name: "Выплаты" }, { - path: "/Quiz", + path: "/quiz", name: "Тесты" }, { @@ -81,6 +81,7 @@ export const Navigation = () => { key={index} end to={link.path === "/Quiz" ? link.path : `/profile${link.path}`} + className={currentPath. includes(link.path) ? 'active' : ''} > {link.name} diff --git a/src/components/ProfileCalendar/ProfileCalendar.jsx b/src/components/ProfileCalendar/ProfileCalendar.jsx index e4077d09..6875cce9 100644 --- a/src/components/ProfileCalendar/ProfileCalendar.jsx +++ b/src/components/ProfileCalendar/ProfileCalendar.jsx @@ -98,7 +98,7 @@ export const ProfileCalendar = () => { {profileInfo.specification} разработчик

- + + {isFetching ? + : + + }

Всего за день:{" "} diff --git a/src/components/ShortReport/ShortReport.jsx b/src/components/ShortReport/ShortReport.jsx index 8e76afb4..355bdd1e 100644 --- a/src/components/ShortReport/ShortReport.jsx +++ b/src/components/ShortReport/ShortReport.jsx @@ -80,7 +80,7 @@ export const ShortReport = () => {

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

- Посмотреть подробный отчет + Посмотреть подробный отчет
diff --git a/src/components/features/quiz/CardAviableTest.jsx b/src/components/features/quiz/CardAviableTest.jsx index 9a807ec3..fc96db86 100644 --- a/src/components/features/quiz/CardAviableTest.jsx +++ b/src/components/features/quiz/CardAviableTest.jsx @@ -9,7 +9,7 @@ export const CardAvailableTest = ({ title, description, path, status }) => { return (
{ {status === 2 && (

Получить отчет по тестированию

- Отчет по тесту + Отчет по тесту
)}
diff --git a/src/pages/Quiz/PassingTests.js b/src/pages/Quiz/PassingTests.js index 7eeb83bb..bbf8ea2b 100644 --- a/src/pages/Quiz/PassingTests.js +++ b/src/pages/Quiz/PassingTests.js @@ -120,12 +120,12 @@ export const PassingTests = () => { ))}
)} - {!startTest && ( -
- ИЛИ выполните тестовое задание, без - прохождения тестов -
- )} + {/*{!startTest && (*/} + {/*
*/} + {/* ИЛИ выполните тестовое задание, без*/} + {/* прохождения тестов*/} + {/*
*/} + {/*)}*/} )} {completedTest && ( diff --git a/src/pages/Quiz/QuizPage.js b/src/pages/Quiz/QuizPage.js index 56778627..3778f4f8 100644 --- a/src/pages/Quiz/QuizPage.js +++ b/src/pages/Quiz/QuizPage.js @@ -144,10 +144,10 @@ export const QuizPage = () => {

Анкет нет

)} -
- ИЛИ выполните тестовое задание, без - прохождения тестов -
+ {/*
*/} + {/* ИЛИ выполните тестовое задание, без*/} + {/* прохождения тестов*/} + {/*
*/} )} {selectedCategory && ( diff --git a/src/pages/Quiz/QuizReportPage.js b/src/pages/Quiz/QuizReportPage.js index accf14be..7a30b1e8 100644 --- a/src/pages/Quiz/QuizReportPage.js +++ b/src/pages/Quiz/QuizReportPage.js @@ -42,8 +42,8 @@ export const QuizReportPage = () => {
diff --git a/src/pages/ViewReport/ViewReport.jsx b/src/pages/ViewReport/ViewReport.jsx index d9e5ffe6..74ee0f3d 100644 --- a/src/pages/ViewReport/ViewReport.jsx +++ b/src/pages/ViewReport/ViewReport.jsx @@ -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 = () => { #

Вернуться

- {/*
-

- {getCorrectDate(dateReport.id)} -

-

- Вами потрачено на работу:{" "} - - {totalHours} {hourOfNum(totalHours)} - -

-
*/} + {localStorage.getItem("role_status") !== "18" && +
+ + {deleteLoader ? : + + } +
+ }
previousDay()}>
arrow @@ -141,7 +157,7 @@ export const ViewReport = () => { getCreatedDate(currentDay) === params.date ? "disable" : "" }`} > - +
arrow
diff --git a/src/pages/ViewReport/viewReport.scss b/src/pages/ViewReport/viewReport.scss index 87cb5070..8cfdae69 100644 --- a/src/pages/ViewReport/viewReport.scss +++ b/src/pages/ViewReport/viewReport.scss @@ -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 { -- 2.34.1 From 1fd6a736521086001bf1e7a2dc216021b83e0a46 Mon Sep 17 00:00:00 2001 From: Mikola Date: Wed, 7 Feb 2024 18:54:55 +0300 Subject: [PATCH 2/2] active links in nav, delete report, loaders in report, changes routes --- src/components/Navigation/Navigation.jsx | 3 +- .../ProfileCalendarComponent.jsx | 12 ++--- src/components/ReportForm/ReportForm.jsx | 11 ++--- src/components/ShortReport/ShortReport.jsx | 4 +- .../features/quiz/CardAviableTest.jsx | 6 ++- src/pages/ViewReport/ViewReport.jsx | 45 ++++++++++++------- 6 files changed, 51 insertions(+), 30 deletions(-) diff --git a/src/components/Navigation/Navigation.jsx b/src/components/Navigation/Navigation.jsx index 4270c886..dc48a5dc 100644 --- a/src/components/Navigation/Navigation.jsx +++ b/src/components/Navigation/Navigation.jsx @@ -9,7 +9,6 @@ import { urlForLocal } from "@utils/helper"; import avatarMok from "assets/images/avatarMok.png"; export const Navigation = () => { - const profileInfo = useSelector(getProfileInfo); const currentPath = window.location.pathname; const [user] = useState( @@ -81,7 +80,7 @@ export const Navigation = () => { key={index} end to={link.path === "/Quiz" ? link.path : `/profile${link.path}`} - className={currentPath. includes(link.path) ? 'active' : ''} + className={currentPath.includes(link.path) ? "active" : ""} > {link.name} diff --git a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx index 84d4f66f..8cab6dd5 100644 --- a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx +++ b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx @@ -98,7 +98,9 @@ export const ProfileCalendarComponent = React.memo( if (userId) { return `/profile/calendar/view/${date.created_at}/${userId}`; } - return `/profile/calendar/view/${date.created_at}/${localStorage.getItem("id")}`; + return `/profile/calendar/view/${ + date.created_at + }/${localStorage.getItem("id")}`; } } @@ -282,15 +284,15 @@ export const ProfileCalendarComponent = React.memo( ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}` : activePeriod - ? "Выберите диапазон на календаре" - : "Выбрать диапазон"} + ? "Выберите диапазон на календаре" + : "Выбрать диапазон"} {totalRangeHours ? `${totalRangeHours} ${hourOfNum(totalRangeHours)}` : endDate - ? "0 часов" - : ""} + ? "0 часов" + : ""} {endDate && ( { }; const handler = () => { - setIsFetching(true) + setIsFetching(true); for (let input of inputs) { if (!input.task || !input.hours_spent) { setReportSuccess("Заполните задачи"); setTimeout(() => setReportSuccess(""), 2000); - setIsFetching(false) + setIsFetching(false); return; } } @@ -294,15 +294,16 @@ const ReportForm = () => {
- {isFetching ? - : + {isFetching ? ( + + ) : ( - } + )}

Всего за день:{" "} diff --git a/src/components/ShortReport/ShortReport.jsx b/src/components/ShortReport/ShortReport.jsx index 355bdd1e..c4b7238e 100644 --- a/src/components/ShortReport/ShortReport.jsx +++ b/src/components/ShortReport/ShortReport.jsx @@ -80,7 +80,9 @@ export const ShortReport = () => {

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

- Посмотреть подробный отчет + + Посмотреть подробный отчет +
diff --git a/src/components/features/quiz/CardAviableTest.jsx b/src/components/features/quiz/CardAviableTest.jsx index fc96db86..a1c6d289 100644 --- a/src/components/features/quiz/CardAviableTest.jsx +++ b/src/components/features/quiz/CardAviableTest.jsx @@ -9,7 +9,11 @@ export const CardAvailableTest = ({ title, description, path, status }) => { return (
{ const [taskText, setTaskText] = useState([]); const [difficulties, setDifficulties] = useState([]); const [tomorrowTask, setTomorrowTask] = useState([]); - const [taskId, setTaskId] = 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) + const [deleteLoader, setDeleteLoader] = useState(false); function getReportFromDate(day) { setLoader(true); @@ -41,7 +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) + setTaskId(res[0]?.id); for (const item of res) { if (item.difficulties) { setDifficulties((prevArray) => [...prevArray, item.difficulties]); @@ -69,13 +69,13 @@ export const ViewReport = () => { } function deleteReport() { - setDeleteLoader(true) + setDeleteLoader(true); apiRequest(`reports/delete?id=${taskId}`, { method: "DELETE" }).then((res) => { - setDeleteLoader(false) + setDeleteLoader(false); if (res) { - window.location.replace("/profile/calendar") + window.location.replace("/profile/calendar"); } }); } @@ -125,23 +125,32 @@ export const ViewReport = () => { #

Вернуться

- {localStorage.getItem("role_status") !== "18" && + {localStorage.getItem("role_status") !== "18" && (
- - {deleteLoader ? : - + {deleteLoader ? ( + + ) : ( + - } + )}
- } + )}
previousDay()}>
arrow @@ -157,7 +166,11 @@ export const ViewReport = () => { getCreatedDate(currentDay) === params.date ? "disable" : "" }`} > - +
arrow
-- 2.34.1