From 4683981913cd2a8d012e13b32250601b6da46c6d Mon Sep 17 00:00:00 2001 From: ramnique <30795890+ramnique@users.noreply.github.com> Date: Thu, 23 Jan 2025 12:11:09 +0530 Subject: [PATCH] editor: add scenario form updates --- .../[projectId]/playground/scenario-list.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx b/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx index 6d991a83..cce50e6d 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx @@ -6,13 +6,12 @@ import { getScenarios, createScenario, updateScenario, deleteScenario } from "@/ import { Scenario, WithStringId } from "@/app/lib/types"; import { z } from "zod"; import { EditableField } from "@/app/lib/components/editable-field"; -import { HamburgerIcon } from "@/app/lib/components/icons"; -import { EllipsisVerticalIcon, PlayIcon } from "lucide-react"; +import { EllipsisVerticalIcon, PlayIcon, PlusIcon } from "lucide-react"; export function AddScenarioForm({ onAdd, }: { - onAdd: (name: string, description: string) => void; + onAdd: (name: string, description: string) => Promise; }) { const [name, setName] = useState(""); const [description, setDescription] = useState(""); @@ -20,9 +19,14 @@ export function AddScenarioForm({ const [saving, setSaving] = useState(false); const handleAdd = async () => { + if (!name.trim() || !description.trim()) { + setError("Name and description are required"); + return; + } + try { setSaving(true); - await onAdd(name, description); + await onAdd(name.trim(), description.trim()); setName(""); setDescription(""); setError(null); @@ -34,7 +38,7 @@ export function AddScenarioForm({ }; return
-
Add Scenario
+
Add scenario
- - + } > - Add Scenario + Add scenario
} @@ -158,7 +160,7 @@ export function ScenarioList({ size="sm" variant="bordered" > - Add Scenario + Add scenario } {loading &&