diff --git a/src/components/inputs/mission_tasks_editor.tsx b/src/components/inputs/mission_tasks_editor.tsx new file mode 100644 index 0000000..cc15945 --- /dev/null +++ b/src/components/inputs/mission_tasks_editor.tsx @@ -0,0 +1,115 @@ +import { Mission } from "@/types/mission"; +import { Task } from "@/types/task"; +import React, { useState } from "react"; +import { TESelect } from "tw-elements-react"; + +interface MissionTaskEditorProps { + mission: Mission; + onMissionChange: (updatedMission: Mission) => void; +} + +const MissionTaskEditor: React.FC = ({ + mission, + onMissionChange, +}) => { + const [newTaskName, setNewTaskName] = useState(""); + const [newTaskAgent, setNewTaskAgent] = useState(""); + const [newTaskDescription, setNewTaskDescription] = useState(""); + + const handleAddTask = () => { + const newTask: Task = { + name: newTaskName, + description: newTaskDescription, + agent: "", + }; + const updatedTasks = [...mission.tasks, newTask]; + const updatedMission: Mission = { ...mission, tasks: updatedTasks }; + onMissionChange(updatedMission); + setNewTaskName(""); + setNewTaskDescription(""); + }; + + const handleRemoveTask = (index: number) => { + const updatedTasks = [...mission.tasks]; + updatedTasks.splice(index, 1); + const updatedMission: Mission = { ...mission, tasks: updatedTasks }; + onMissionChange(updatedMission); + }; + + return ( +
+

Mission Tasks

+ {mission.tasks.map((task, index) => ( +
+
+

{task.name}

+ +
+
{task.description}
+
+ Agent: + + {task.agent} + +
+
+ ))} +
+
+ Add New Task: +
+
+
+ + setNewTaskName(e.target.value)} + className="border border-gray-300 text-black rounded px-3 py-1" + /> +
+
+ +
+