From 4d011ff08077d676c90304245d291a64d8131256 Mon Sep 17 00:00:00 2001 From: "Eng. Elias" Date: Mon, 19 Feb 2024 11:35:36 +0400 Subject: [PATCH] finishing the Basic UI of the project --- .../inputs/mission_tasks_editor.tsx | 115 ++++++++++++++++++ src/components/modals/mission_modal.tsx | 98 ++++++++------- src/data/data.ts | 3 +- 3 files changed, 171 insertions(+), 45 deletions(-) create mode 100644 src/components/inputs/mission_tasks_editor.tsx 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" + /> +
+
+ +
+