import React, { useState } from 'react' import { useSelector, useDispatch } from 'react-redux' import { fetchPost } from '../../server/server' import { useHistory, useParams, Redirect } from 'react-router-dom' import { Loader } from '../Loader/Loader' import { auth } from '../../redux/outstaffingSlice' 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 { currentMonthAndDayReportPage } from '../Calendar/calendarHelper' import './reportForm.scss' const getCreatedDate = () => { 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 role = useSelector(getRole) const [isFetching, setIsFetching] = 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 deleteInput = (indexRemove) => { if (indexRemove !== 1) { setInputs((prev) => prev.filter((el, index) => index !== indexRemove)) } } return (

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

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

{currentMonthAndDayReportPage()}
Какие задачи были выполнены?

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

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

{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)} />

Всего за день : 60 часов

) } export default ReportForm