diff --git a/src/frontend/src/components/nameInputComponent/index.tsx b/src/frontend/src/components/nameInputComponent/index.tsx new file mode 100644 index 000000000..126a99645 --- /dev/null +++ b/src/frontend/src/components/nameInputComponent/index.tsx @@ -0,0 +1,91 @@ +import React, { useState, ChangeEvent } from "react"; +import { Textarea } from "../ui/textarea"; +import { Label } from "../ui/label"; +import { Input } from "../ui/input"; + +type InputProps = { + name: string | null; + description: string | null; + maxLength?: number; + flows: Array<{ id: string; name: string }>; + tabId: string; + setName: (name: string) => void; + setDescription: (description: string) => void; + updateFlow: (flow: { id: string; name: string }) => void; +}; + +export const EditFlowSettings: React.FC = ({ + name, + description, + maxLength = 50, + flows, + tabId, + setName, + setDescription, + updateFlow, +}) => { + const [isMaxLength, setIsMaxLength] = useState(false); + + const handleNameChange = (event: ChangeEvent) => { + const { value } = event.target; + if (value.length >= maxLength) { + setIsMaxLength(true); + } else { + setIsMaxLength(false); + } + + if (value !== "") { + let newFlow = flows.find((f) => f.id === tabId); + if (newFlow) { + newFlow.name = value; + setName(value); + updateFlow(newFlow); + } + } else { + setName(value); + } + }; + + const handleDescriptionChange = (event: ChangeEvent) => { + setDescription(event.target.value); + }; + + return ( +
+ +