diff --git a/frontend/src/app/tasks/components/EditTask.tsx b/frontend/src/app/tasks/components/EditTask.tsx new file mode 100644 index 000000000..09cc2c3b6 --- /dev/null +++ b/frontend/src/app/tasks/components/EditTask.tsx @@ -0,0 +1,116 @@ +import Box from '@mui/joy/Box' +import Stack from '@mui/joy/Stack' + +import { Task } from '@/domain/Task' +import { TaskType } from '@/domain/TaskType' +import { Project } from '@/domain/Project' +import Button from '@mui/joy/Button' + +import { Select } from '@/ui/Select/Select' +import { TextArea } from '@/ui/TextArea/TextArea' +import { Input } from '@/ui/Input/Input' + +import { TimePicker } from './TimePicker' +import { useEditTaskForm } from '../hooks/useEditTaskForm' + +type EditTaskProps = { + task: Task + tasks: Array + projects: Array + taskTypes: Array + closeForm: () => void +} + +export const EditTask = ({ task, tasks, projects, taskTypes, closeForm }: EditTaskProps) => { + const { handleChange, formState, handleSubmit, resetForm } = useEditTaskForm({ + task, + tasks, + closeForm + }) + + const handleProject = (value: string) => { + const project = projects.find((project) => project.description === value) + if (project) { + handleChange('projectId', project.id) + handleChange('projectName', value) + } + } + + return ( + { + e.preventDefault() + handleSubmit() + }} + component="form" + gap="8px" + width="400px" + > + handleChange('taskType', value)} + options={taskTypes.map((taskType) => taskType.slug)} + placeholder="Select task type" + /> + + handleChange('startTime', value)} + required + /> + + handleChange('endTime', value)} + required + /> + +