From b4b0b25d07e2d846df0c5fc9c211f9ea81c6b7c8 Mon Sep 17 00:00:00 2001 From: Andre-Diamond <32074058+Andre-Diamond@users.noreply.github.com> Date: Tue, 19 Mar 2024 07:51:39 +0200 Subject: [PATCH] Fix initial options bug and remove console.log statement --- components/SelectNames.tsx | 5 +++++ components/SummaryTemplate.tsx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/components/SelectNames.tsx b/components/SelectNames.tsx index 13380cd..16dc0c6 100644 --- a/components/SelectNames.tsx +++ b/components/SelectNames.tsx @@ -19,6 +19,11 @@ const SelectNames: React.FC = ({ onSelect, initialValue }) => { value: 'vanilla', label: 'Vanilla' } ]; + React.useEffect(() => { + let initialOptions = initialValue ? initialValue.split(", ").map(val => ({ label: val, value: val })) : []; + setSelectedLabels(initialOptions); + }, [initialValue]); + async function handleInputChange(selected: any) { setSelectedLabels(selected); // Update local state let labs: string[] = selected.map((item: any) => item.label); diff --git a/components/SummaryTemplate.tsx b/components/SummaryTemplate.tsx index bfecbb9..053dba0 100644 --- a/components/SummaryTemplate.tsx +++ b/components/SummaryTemplate.tsx @@ -251,6 +251,7 @@ const SummaryTemplate = ({ updateMeetings }: SummaryTemplateProps) => { setLoading(true); try { + //console.log("test", cleanedFormData) const data = await saveCustomAgenda(cleanedFormData); if (data !== false) { //console.log("Calling updateMeetings with:", summary, data[0].date); @@ -281,7 +282,7 @@ const SummaryTemplate = ({ updateMeetings }: SummaryTemplateProps) => { setMyVariable(updatedMyVariable); } else { console.log("Error in saving custom agenda"); - } + } } catch (error) { console.error("Error submitting the form:", error); alert("There was an error submitting the meeting summary.");