trackerTask #20
@ -18,10 +18,10 @@ import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadc
|
|||||||
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
||||||
|
|
||||||
import arrow from "assets/icons/arrows/left-arrow.png";
|
import arrow from "assets/icons/arrows/left-arrow.png";
|
||||||
|
import arrowDown from "assets/icons/arrows/selectArrow.png";
|
||||||
import calendarIcon from "assets/icons/calendar.svg";
|
import calendarIcon from "assets/icons/calendar.svg";
|
||||||
import ellipse from "assets/icons/ellipse.png";
|
import ellipse from "assets/icons/ellipse.png";
|
||||||
import remove from "assets/icons/remove.svg";
|
import remove from "assets/icons/remove.svg";
|
||||||
import arrowDown from "assets/icons/arrows/selectArrow.png";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getCorrectDate,
|
getCorrectDate,
|
||||||
@ -41,7 +41,6 @@ const ReportForm = () => {
|
|||||||
const editReport = useSelector(getEditReport);
|
const editReport = useSelector(getEditReport);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initListeners();
|
initListeners();
|
||||||
getProjectList();
|
getProjectList();
|
||||||
@ -54,10 +53,10 @@ const ReportForm = () => {
|
|||||||
? new Date(reportDate ? reportDate._d : editReport.created_at)
|
? new Date(reportDate ? reportDate._d : editReport.created_at)
|
||||||
: new Date()
|
: new Date()
|
||||||
);
|
);
|
||||||
const [projectList, setProjectList] = useState([])
|
const [projectList, setProjectList] = useState([]);
|
||||||
const [projectLoader, setProjectLoader] = useState(false)
|
const [projectLoader, setProjectLoader] = useState(false);
|
||||||
const [selectedProject, setSelectedProject] = useState('Выберите проект')
|
const [selectedProject, setSelectedProject] = useState("Выберите проект");
|
||||||
const [openSelectProject, setOpenSelectProject] = useState(false)
|
const [openSelectProject, setOpenSelectProject] = useState(false);
|
||||||
const [datePickerOpen, setDatePickerOpen] = useState(false);
|
const [datePickerOpen, setDatePickerOpen] = useState(false);
|
||||||
|
|
||||||
const [inputs, setInputs] = useState(
|
const [inputs, setInputs] = useState(
|
||||||
@ -93,13 +92,11 @@ const ReportForm = () => {
|
|||||||
div.classList &&
|
div.classList &&
|
||||||
(div.classList.contains("report-form__block-img") ||
|
(div.classList.contains("report-form__block-img") ||
|
||||||
div.classList.contains("react-datepicker-popper") ||
|
div.classList.contains("react-datepicker-popper") ||
|
||||||
div.classList.contains("report-form__project")
|
div.classList.contains("report-form__project"))
|
||||||
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
setDatePickerOpen(false);
|
setDatePickerOpen(false);
|
||||||
setOpenSelectProject(false)
|
setOpenSelectProject(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -110,16 +107,16 @@ const ReportForm = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getProjectList = () => {
|
const getProjectList = () => {
|
||||||
setProjectLoader(true)
|
setProjectLoader(true);
|
||||||
apiRequest(
|
apiRequest(
|
||||||
`/project/project-list?user_id=${localStorage.getItem(
|
`/project/project-list?user_id=${localStorage.getItem(
|
||||||
"id"
|
"id"
|
||||||
)}&expand=columns`
|
)}&expand=columns`
|
||||||
).then((el) => {
|
).then((el) => {
|
||||||
setProjectLoader(false)
|
setProjectLoader(false);
|
||||||
setProjectList(el?.projects)
|
setProjectList(el?.projects);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
const handler = () => {
|
const handler = () => {
|
||||||
setIsFetching(true);
|
setIsFetching(true);
|
||||||
for (let input of inputs) {
|
for (let input of inputs) {
|
||||||
@ -135,7 +132,7 @@ const ReportForm = () => {
|
|||||||
data: {
|
data: {
|
||||||
user_id: localStorage.getItem("id"),
|
user_id: localStorage.getItem("id"),
|
||||||
tasks: inputs,
|
tasks: inputs,
|
||||||
project_id: selectedProject.id ? selectedProject.id : '',
|
project_id: selectedProject.id ? selectedProject.id : "",
|
||||||
difficulties: troublesInputValue,
|
difficulties: troublesInputValue,
|
||||||
tomorrow: scheduledInputValue,
|
tomorrow: scheduledInputValue,
|
||||||
created_at: getCreatedDate(startDate),
|
created_at: getCreatedDate(startDate),
|
||||||
@ -167,7 +164,7 @@ const ReportForm = () => {
|
|||||||
data: {
|
data: {
|
||||||
tasks: inputs,
|
tasks: inputs,
|
||||||
difficulties: troublesInputValue,
|
difficulties: troublesInputValue,
|
||||||
project_id: selectedProject.id ? selectedProject.id : '',
|
project_id: selectedProject.id ? selectedProject.id : "",
|
||||||
tomorrow: scheduledInputValue,
|
tomorrow: scheduledInputValue,
|
||||||
created_at: getCreatedDate(startDate),
|
created_at: getCreatedDate(startDate),
|
||||||
status: 1
|
status: 1
|
||||||
@ -244,30 +241,58 @@ const ReportForm = () => {
|
|||||||
setStartDate(date);
|
setStartDate(date);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{projectLoader ? <div className="loader__wrapper"><Loader /></div> :
|
{projectLoader ? (
|
||||||
|
<div className="loader__wrapper">
|
||||||
|
<Loader />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="report-form__task-list">
|
<div className="report-form__task-list">
|
||||||
<img src={ellipse} alt="" />
|
<img src={ellipse} alt="" />
|
||||||
<span>Выберите проект</span>
|
<span>Выберите проект</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="report-form__project">
|
<div className="report-form__project">
|
||||||
<div className="project__selected" onClick={() => setOpenSelectProject(!openSelectProject)}>
|
<div
|
||||||
<p>{selectedProject.name ? selectedProject.name : selectedProject}</p>
|
className="project__selected"
|
||||||
<img className={openSelectProject ? "project__selected--open" : ""} src={arrowDown} alt='arrow' />
|
onClick={() => setOpenSelectProject(!openSelectProject)}
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
{selectedProject.name
|
||||||
|
? selectedProject.name
|
||||||
|
: selectedProject}
|
||||||
|
</p>
|
||||||
|
<img
|
||||||
|
className={
|
||||||
|
openSelectProject ? "project__selected--open" : ""
|
||||||
|
}
|
||||||
|
src={arrowDown}
|
||||||
|
alt="arrow"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{openSelectProject &&
|
{openSelectProject && (
|
||||||
<div className="project__dropDown">
|
<div className="project__dropDown">
|
||||||
{Boolean(projectList.length) ? projectList.map((project) => {
|
{Boolean(projectList.length) ? (
|
||||||
return <span onClick={() => {
|
projectList.map((project) => {
|
||||||
setSelectedProject(project)
|
return (
|
||||||
setOpenSelectProject(false)
|
<span
|
||||||
}} key={project.id}>{project.name}</span>
|
onClick={() => {
|
||||||
}) : <span>Проектов нет</span>}
|
setSelectedProject(project);
|
||||||
|
setOpenSelectProject(false);
|
||||||
|
}}
|
||||||
|
key={project.id}
|
||||||
|
>
|
||||||
|
{project.name}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<span>Проектов нет</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
<div className="report-form__task-list">
|
<div className="report-form__task-list">
|
||||||
<img src={ellipse} alt="" />
|
<img src={ellipse} alt="" />
|
||||||
<span>Какие задачи выполнены?</span>
|
<span>Какие задачи выполнены?</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user