import { useEffect, useRef, useState } from 'react'; import { Field, Text, TextArea, Select, Slider, DatePicker, } from '@svar-ui/react-core'; import { useWritableProp } from '@svar-ui/lib-react'; import './Form.css'; export default function Form(props) { const [task, setTask] = useWritableProp(props.task); const { taskTypes, onAction } = props; const nodeRef = useRef(null); const [left, setLeft] = useState(); const [top, setTop] = useState(); useEffect(() => { if (nodeRef.current) { setLeft((window.innerWidth - nodeRef.current.offsetWidth) / 2); setTop((window.innerHeight - nodeRef.current.offsetHeight) / 2); } }, []); function deleteTask() { onAction && onAction({ action: 'delete-task', data: { id: task.id } }); onAction && onAction({ action: 'close-form' }); } function onClose() { onAction && onAction({ action: 'close-form' }); } function handleChange({ value }, key) { let t = task; if (key === 'type' && value === 'milestone') { delete t.end; t.duration = 0; } else if (t.start > t.end) { t.start = t.end; t.duration = 1; t.end = 0; } t = { ...t, [key]: value, }; setTask(t); onAction && onAction({ action: 'update-task', data: { id: t.id, task: t }, }); } return (

Edit task

handleChange(ev, 'text')} />