import React, { useState } from 'react' import { useSelector, useDispatch } from 'react-redux' import { fetchPost } from '../../server/server' import {useHistory, useParams, Redirect, Link} from 'react-router-dom' import { Loader } from '../Loader/Loader' import {auth} from '../../redux/outstaffingSlice' import { getReportDate } from '../../redux/reportSlice' import { getRole } from '../../redux/roleSlice' import calendarIcon from '../../images/calendar_icon.png' import ellipse from '../../images/ellipse.png' import remove from '../../images/remove.png' import addIcon from '../../images/addIcon.png' import { currentMonthAndDay, getReports } from '../Calendar/calendarHelper' import './reportForm.scss' import arrow from "../../images/right-arrow.png"; const getCreatedDate = (day) => { if (day) { return `${new Date(day).getFullYear()}-${new Date(day).getMonth() + 1}-${new Date(day).getDate()}` } else { const date = new Date(); const dd = String(date.getDate()).padStart(2, '0') const mm = String(date.getMonth() + 1).padStart(2, '0') const yyyy = date.getFullYear() return `${yyyy}-${mm}-${dd}` } } const ReportForm = () => { const dispatch = useDispatch() const history = useHistory() const reportDate = useSelector(getReportDate) const role = useSelector(getRole) const [isFetching, setIsFetching] = useState(false) const [reportSuccess, setReportSuccess] = useState(false) const [inputs, setInputs] = useState([ { task: '', hours_spent: '', minutes_spent: 0 } ]); const [troublesInputValue, setTroublesInputValue] = useState(''); const [scheduledInputValue, setScheduledInputValue] = useState(''); const addInput = () => { setInputs((prev) => [...prev, { task: '', hours_spent: '', minutes_spent: 0 }]) } const totalHours = inputs.reduce((a,b) => a + b.hours_spent, 0) const deleteInput = (indexRemove) => { if (indexRemove !== 0) { setInputs((prev) => prev.filter((el, index) => index !== indexRemove)) } } return (
Вернуться назад

Добавить отчет

Дата заполнения отчета:

{/*{currentMonthAndDayReportPage()}*/} {reportDate ? currentMonthAndDay(reportDate) : getCreatedDate()}
Какие задачи были выполнены?

Краткое описание задачи

Количество часов

{inputs.map((input, index) => { return (
{index+1}.
setInputs(inputs.map( (input, inputIndex) => { return index === inputIndex ? { ...input, task: e.target.value } : input }))} />
setInputs(inputs.map( (input, inputIndex) => { return index === inputIndex ? { ...input, hours_spent: Number(e.target.value) } : input }))} />
deleteInput(index)} src={remove} alt='' />
) })}
Добавить еще
Какие сложности возникли?
setTroublesInputValue(e.target.value)} />
Что планируется сделать завтра?
setScheduledInputValue(e.target.value)} />

Всего за день : {totalHours} часов

{reportSuccess &&

Отчет отправлен

}
) } export default ReportForm