🐛 fix(EditFlowSettingsComponent): update flows array type to include description property to fix type error

🔧 chore(EditFlowSettingsComponent): refactor handleDescriptionChange to update description in flows array and setDesc state variable
🔧 chore(EditFlowSettingsComponent): update value prop of description textarea to use desc state variable instead of description prop
This commit is contained in:
Cristhian Zanforlin Lousa 2023-07-21 11:09:35 -03:00
commit f67c0ff509

View file

@ -7,7 +7,7 @@ type InputProps = {
name: string | null;
description: string | null;
maxLength?: number;
flows: Array<{ id: string; name: string }>;
flows: Array<{ id: string; name: string; description: string }>;
tabId: string;
setName: (name: string) => void;
setDescription: (description: string) => void;
@ -37,7 +37,13 @@ export const EditFlowSettings: React.FC<InputProps> = ({
setName(value);
};
const [desc, setDesc] = useState(
flows.find((f) => f.id === tabId).description
);
const handleDescriptionChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
flows.find((f) => f.id === tabId).description = event.target.value;
setDesc(flows.find((f) => f.id === tabId).description)
setDescription(event.target.value);
};
@ -70,7 +76,7 @@ export const EditFlowSettings: React.FC<InputProps> = ({
name="description"
id="description"
onChange={handleDescriptionChange}
value={description ?? ""}
value={desc}
placeholder="Flow description"
className="mt-2 max-h-[100px] font-normal"
rows={3}