Compare commits
No commits in common. "ab90e59880d75745f82a79c6178612aa212ccde7" and "2f61f7f130a0ebced39ab1b097624ae30c1dfaf3" have entirely different histories.
ab90e59880
...
2f61f7f130
@ -10,13 +10,11 @@ import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
||||
import anyMoment from "assets/icons/anyMoment.svg";
|
||||
import doc from "assets/icons/doc.svg";
|
||||
import telegramLogo from "assets/icons/tgLogo.svg";
|
||||
import accept from "assets/images/accept.png";
|
||||
|
||||
import "./modalRegistration.scss";
|
||||
|
||||
export const ModalRegistration = ({ active, setActive }) => {
|
||||
const [loader, setLoader] = useState(false);
|
||||
const [isPartner, setIsPartner] = useState(false);
|
||||
|
||||
const fields = {
|
||||
username: "",
|
||||
@ -58,7 +56,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
fields,
|
||||
showNotificationError,
|
||||
showNotificationTrue,
|
||||
isPartner
|
||||
closeModal
|
||||
);
|
||||
|
||||
return (
|
||||
@ -125,15 +123,6 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="input_checkbox"
|
||||
onClick={() => setIsPartner(!isPartner)}
|
||||
>
|
||||
<p>Партнер:</p>
|
||||
<span className={isPartner ? "checkbox--active" : ""}>
|
||||
{isPartner ? <img src={accept} alt="accept" /> : ""}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="button-box">
|
||||
{loader ? (
|
||||
|
@ -128,38 +128,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.input_checkbox {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
|
||||
p {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
span {
|
||||
border: 1px solid gray;
|
||||
border-radius: 4px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-left: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox--active {
|
||||
background: #f2f2f2;
|
||||
}
|
||||
}
|
||||
|
||||
.button-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
@ -7,7 +7,6 @@ import { Link, Navigate } from "react-router-dom";
|
||||
import { getProfileInfo } from "@redux/outstaffingSlice";
|
||||
import {
|
||||
getRequestDates,
|
||||
setEditReport,
|
||||
setReportDate,
|
||||
setRequestDate
|
||||
} from "@redux/reportSlice";
|
||||
@ -102,10 +101,7 @@ export const ProfileCalendar = () => {
|
||||
<Link to="/profile/calendar/report">
|
||||
<button
|
||||
className="calendar__btn"
|
||||
onClick={() => {
|
||||
dispatch(setReportDate(""));
|
||||
dispatch(setEditReport(""));
|
||||
}}
|
||||
onClick={() => dispatch(setReportDate(""))}
|
||||
>
|
||||
Заполнить отчет
|
||||
</button>
|
||||
|
@ -5,7 +5,6 @@ import { useDispatch } from "react-redux";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
import {
|
||||
setEditReport,
|
||||
setReportDate,
|
||||
setRequestDate,
|
||||
setSendRequest
|
||||
@ -236,7 +235,6 @@ export const ProfileCalendarComponent = React.memo(
|
||||
else {
|
||||
dispatch(setReportDate(day));
|
||||
dispatch(setSendRequest(true));
|
||||
dispatch(setEditReport(""));
|
||||
}
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
@ -286,15 +284,15 @@ export const ProfileCalendarComponent = React.memo(
|
||||
? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}`
|
||||
: `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}`
|
||||
: activePeriod
|
||||
? "Выберите диапазон на календаре"
|
||||
: "Выбрать диапазон"}
|
||||
? "Выберите диапазон на календаре"
|
||||
: "Выбрать диапазон"}
|
||||
</span>
|
||||
<span>
|
||||
{totalRangeHours
|
||||
? `${totalRangeHours} ${hourOfNum(totalRangeHours)}`
|
||||
: endDate
|
||||
? "0 часов"
|
||||
: ""}
|
||||
? "0 часов"
|
||||
: ""}
|
||||
</span>
|
||||
{endDate && (
|
||||
<BaseButton
|
||||
|
@ -3,11 +3,9 @@ import React, { useEffect, useState } from "react";
|
||||
import DatePicker, { registerLocale } from "react-datepicker";
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Link, Navigate, useNavigate } from "react-router-dom";
|
||||
|
||||
import { getEditReport, getReportDate } from "@redux/reportSlice";
|
||||
import { setEditReport } from "@redux/reportSlice";
|
||||
import { getReportDate } from "@redux/reportSlice";
|
||||
|
||||
import { apiRequest } from "@api/request";
|
||||
|
||||
@ -37,8 +35,6 @@ const ReportForm = () => {
|
||||
}
|
||||
const navigate = useNavigate();
|
||||
const reportDate = useSelector(getReportDate);
|
||||
const editReport = useSelector(getEditReport);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
initListeners();
|
||||
@ -47,23 +43,15 @@ const ReportForm = () => {
|
||||
const [isFetching, setIsFetching] = useState(false);
|
||||
const [reportSuccess, setReportSuccess] = useState("");
|
||||
const [startDate, setStartDate] = useState(
|
||||
reportDate || editReport
|
||||
? new Date(reportDate ? reportDate._d : editReport.created_at)
|
||||
: new Date()
|
||||
reportDate ? new Date(reportDate._d) : new Date()
|
||||
);
|
||||
const [datePickerOpen, setDatePickerOpen] = useState(false);
|
||||
|
||||
const [inputs, setInputs] = useState(
|
||||
editReport
|
||||
? editReport.task
|
||||
: [{ task: "", hours_spent: "", minutes_spent: 0 }]
|
||||
);
|
||||
const [troublesInputValue, setTroublesInputValue] = useState(
|
||||
editReport ? editReport.difficulties : ""
|
||||
);
|
||||
const [scheduledInputValue, setScheduledInputValue] = useState(
|
||||
editReport ? editReport.tomorrow : ""
|
||||
);
|
||||
const [inputs, setInputs] = useState([
|
||||
{ task: "", hours_spent: "", minutes_spent: 0 }
|
||||
]);
|
||||
const [troublesInputValue, setTroublesInputValue] = useState("");
|
||||
const [scheduledInputValue, setScheduledInputValue] = useState("");
|
||||
|
||||
const addInput = () => {
|
||||
setInputs((prev) => [
|
||||
@ -124,49 +112,14 @@ const ReportForm = () => {
|
||||
setReportSuccess("");
|
||||
navigate("/profile/calendar");
|
||||
}, 1000);
|
||||
setInputs(() => []);
|
||||
setTroublesInputValue("");
|
||||
setScheduledInputValue("");
|
||||
setIsFetching(false);
|
||||
clearParams();
|
||||
setInputs(() => [{ task: "", hours_spent: "", minutes_spent: 0 }]);
|
||||
});
|
||||
};
|
||||
|
||||
const handleEditReport = () => {
|
||||
setIsFetching(true);
|
||||
for (let input of inputs) {
|
||||
if (!input.task || !input.hours_spent) {
|
||||
setReportSuccess("Заполните задачи");
|
||||
setTimeout(() => setReportSuccess(""), 2000);
|
||||
setIsFetching(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
apiRequest(`/reports/update?id=${editReport.id}`, {
|
||||
method: "PUT",
|
||||
data: {
|
||||
tasks: inputs,
|
||||
difficulties: troublesInputValue,
|
||||
tomorrow: scheduledInputValue,
|
||||
created_at: getCreatedDate(startDate),
|
||||
status: 1
|
||||
}
|
||||
}).then(() => {
|
||||
setReportSuccess("Отчет изменён");
|
||||
setTimeout(() => {
|
||||
setReportSuccess("");
|
||||
navigate("/profile/calendar");
|
||||
}, 1000);
|
||||
setIsFetching(false);
|
||||
clearParams();
|
||||
dispatch(setEditReport(""));
|
||||
});
|
||||
};
|
||||
|
||||
const clearParams = () => {
|
||||
setInputs(() => []);
|
||||
setTroublesInputValue("");
|
||||
setScheduledInputValue("");
|
||||
setInputs(() => [{ task: "", hours_spent: "", minutes_spent: 0 }]);
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="report-form">
|
||||
<ProfileHeader />
|
||||
@ -180,8 +133,7 @@ const ReportForm = () => {
|
||||
]}
|
||||
/>
|
||||
<h2 className="summary__title">
|
||||
Ваши отчеты -{" "}
|
||||
<span>{editReport ? "редактировать отчет" : "добавить отчет"}</span>
|
||||
Ваши отчеты - <span>добавить отчет</span>
|
||||
</h2>
|
||||
<div>
|
||||
<div className="report__head">
|
||||
@ -195,14 +147,13 @@ const ReportForm = () => {
|
||||
<div className="report-form__content">
|
||||
<div className="report-form__block">
|
||||
<div className="report-form__block-title">
|
||||
<h2>
|
||||
{editReport
|
||||
? "Редактирование отчета за день"
|
||||
: "Добавление отчета за день"}
|
||||
</h2>
|
||||
<h2>Добавление отчета за день</h2>
|
||||
<h3>Дата заполнения отчета:</h3>
|
||||
</div>
|
||||
<div className="report-form__block-img">
|
||||
<div
|
||||
className="report-form__block-img"
|
||||
onClick={() => setDatePickerOpen(true)}
|
||||
>
|
||||
<img
|
||||
className="report-form__calendar-icon"
|
||||
src={calendarIcon}
|
||||
@ -348,15 +299,9 @@ const ReportForm = () => {
|
||||
) : (
|
||||
<button
|
||||
className="report-form__footer-btn"
|
||||
onClick={() => {
|
||||
if (editReport) {
|
||||
handleEditReport();
|
||||
} else {
|
||||
handler();
|
||||
}
|
||||
}}
|
||||
onClick={() => handler()}
|
||||
>
|
||||
{editReport ? "Редактировать" : "Отправить"}
|
||||
Отправить
|
||||
</button>
|
||||
)}
|
||||
<p className="report-form__footer-text">
|
||||
|
@ -6,8 +6,7 @@ export const useFormValidation = (
|
||||
apiEndpoint,
|
||||
fields,
|
||||
showNotificationError,
|
||||
showNotificationTrue,
|
||||
isPartner
|
||||
showNotificationTrue
|
||||
) => {
|
||||
// Состояние формы, содержащее значения полей
|
||||
const [formData, setFormData] = useState(fields);
|
||||
@ -85,7 +84,7 @@ export const useFormValidation = (
|
||||
e.preventDefault();
|
||||
// Проверка валидации формы
|
||||
if (validateForm()) {
|
||||
let newformData = { ...formData, is_partner: isPartner ? 1 : 0 };
|
||||
let newformData = { ...formData };
|
||||
delete newformData.secondPassword;
|
||||
|
||||
try {
|
||||
|
@ -39,7 +39,7 @@ export const PartnerCategories = () => {
|
||||
setLoader(true);
|
||||
apiRequest("/project/my-employee").then((el) => {
|
||||
setLoader(false);
|
||||
setStaff(el?.managerEmployees);
|
||||
setStaff(el.managerEmployees);
|
||||
});
|
||||
}, []);
|
||||
|
||||
@ -161,22 +161,16 @@ export const PartnerCategories = () => {
|
||||
<Loader style={"green"} height={80} width={80} />
|
||||
) : (
|
||||
<div className="partnerCategories__items">
|
||||
{Boolean(staff) ? (
|
||||
staff.map((card) => {
|
||||
return (
|
||||
<PartnerPersonCard
|
||||
key={card.id}
|
||||
name={card.employee.fio}
|
||||
img={card.employee.avatar}
|
||||
userId={card.user_id}
|
||||
/>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<span className="partnerCategories__empty">
|
||||
У вас нет нанятого персонала
|
||||
</span>
|
||||
)}
|
||||
{staff.map((card) => {
|
||||
return (
|
||||
<PartnerPersonCard
|
||||
key={card.id}
|
||||
name={card.employee.fio}
|
||||
img={card.employee.avatar}
|
||||
userId={card.user_id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{/*{personalInfoItems.map((item, index) => {*/}
|
||||
{/* return (*/}
|
||||
{/* <Link*/}
|
||||
|
@ -21,12 +21,6 @@
|
||||
//column-gap: 21px;
|
||||
}
|
||||
|
||||
&__empty {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
|
@ -43,7 +43,6 @@ import TrackerSelectColumn from "@components/TrackerSelectColumn/TrackerSelectCo
|
||||
|
||||
import arrow from "assets/icons/arrows/arrowCalendar.png";
|
||||
import arrowDown from "assets/icons/arrows/selectArrow.png";
|
||||
import calendarIcon from "assets/icons/calendar.svg";
|
||||
import close from "assets/icons/close.png";
|
||||
import commentsBoard from "assets/icons/commentsBoard.svg";
|
||||
import del from "assets/icons/delete.svg";
|
||||
@ -55,6 +54,7 @@ import tasks from "assets/icons/trackerTasks.svg";
|
||||
import accept from "assets/images/accept.png";
|
||||
import archive from "assets/images/archiveIcon.png";
|
||||
import avatarMok from "assets/images/avatarMok.png";
|
||||
import calendarIcon from "assets/icons/calendar.svg";
|
||||
|
||||
import { getCorrectDate } from "../../components/Calendar/calendarHelper";
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
|
||||
import { setEditReport } from "@redux/reportSlice";
|
||||
|
||||
import { apiRequest } from "@api/request";
|
||||
|
||||
import {
|
||||
@ -23,7 +20,6 @@ import arrow from "assets/icons/arrows/left-arrow.png";
|
||||
import "./viewReport.scss";
|
||||
|
||||
export const ViewReport = () => {
|
||||
const dispatch = useDispatch();
|
||||
const params = useParams();
|
||||
const [previousReportDay] = useState(new Date(params.date));
|
||||
const [nextReportDay] = useState(new Date(params.date));
|
||||
@ -36,7 +32,6 @@ export const ViewReport = () => {
|
||||
const [currentDay] = useState(new Date());
|
||||
const [loader, setLoader] = useState(false);
|
||||
const [deleteLoader, setDeleteLoader] = useState(false);
|
||||
const [reportInfo, setReportInfo] = useState({});
|
||||
|
||||
function getReportFromDate(day) {
|
||||
setLoader(true);
|
||||
@ -46,7 +41,6 @@ export const ViewReport = () => {
|
||||
apiRequest(`reports/find-by-date?user_id=${params.id}&date=${day}`).then(
|
||||
(res) => {
|
||||
let spendTime = 0;
|
||||
setReportInfo(res[0]);
|
||||
setTaskId(res[0]?.id);
|
||||
for (const item of res) {
|
||||
if (item.difficulties) {
|
||||
@ -133,17 +127,7 @@ export const ViewReport = () => {
|
||||
</Link>
|
||||
{localStorage.getItem("role_status") !== "18" && (
|
||||
<div className="viewReport__bar">
|
||||
<Link
|
||||
to="/profile/calendar/report"
|
||||
onClick={() => dispatch(setEditReport(reportInfo))}
|
||||
className={
|
||||
taskText.length
|
||||
? "viewReport__bar__edit"
|
||||
: "viewReport__bar__edit disable"
|
||||
}
|
||||
>
|
||||
Редактировать
|
||||
</Link>
|
||||
<button className="viewReport__bar__edit">Редактировать</button>
|
||||
{deleteLoader ? (
|
||||
<Loader style={"green"} />
|
||||
) : (
|
||||
|
@ -73,18 +73,9 @@
|
||||
}
|
||||
|
||||
&__edit {
|
||||
color: #000000;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
line-height: 32px;
|
||||
padding: 8px 24px;
|
||||
background: #E1FCCF;
|
||||
border-radius: 44px;
|
||||
border: none;
|
||||
|
||||
&:hover {
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
|
||||
&__delete {
|
||||
|
@ -4,8 +4,7 @@ const initialState = {
|
||||
dateSelected: "",
|
||||
reportDate: "",
|
||||
requestDates: "",
|
||||
sendRequest: "",
|
||||
editReport: ""
|
||||
sendRequest: ""
|
||||
};
|
||||
|
||||
export const reportSlice = createSlice({
|
||||
@ -23,20 +22,12 @@ export const reportSlice = createSlice({
|
||||
},
|
||||
setSendRequest: (state, action) => {
|
||||
state.sendRequest = action.payload;
|
||||
},
|
||||
setEditReport: (state, action) => {
|
||||
state.editReport = action.payload;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const {
|
||||
dateSelected,
|
||||
setReportDate,
|
||||
setRequestDate,
|
||||
setSendRequest,
|
||||
setEditReport
|
||||
} = reportSlice.actions;
|
||||
export const { dateSelected, setReportDate, setRequestDate, setSendRequest } =
|
||||
reportSlice.actions;
|
||||
|
||||
export const selectDate = (state) => state.report.dateSelected;
|
||||
|
||||
@ -46,6 +37,4 @@ export const getRequestDates = (state) => state.report.requestDates;
|
||||
|
||||
export const getSendRequest = (state) => state.report.sendRequest;
|
||||
|
||||
export const getEditReport = (state) => state.report.editReport;
|
||||
|
||||
export default reportSlice.reducer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user