From c7638a783e2265c9323fd0fe808d3b175d3ade40 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Mon, 7 Oct 2024 21:54:11 -0700 Subject: [PATCH] Dynamically update added files when upload in agent creation --- src/interface/web/app/agents/page.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interface/web/app/agents/page.tsx b/src/interface/web/app/agents/page.tsx index fef3e932..6b38ccbd 100644 --- a/src/interface/web/app/agents/page.tsx +++ b/src/interface/web/app/agents/page.tsx @@ -246,7 +246,6 @@ function AgentCard(props: AgentCardProps) { body: JSON.stringify(values), }) .then((response) => { - console.log(response); if (response.status === 200) { form.reset(); setShowModal(false); @@ -660,6 +659,8 @@ function AgentModificationForm(props: AgentModificationFormProps) { const [uploading, setUploading] = useState(false); const [progressValue, setProgressValue] = useState(0); const [uploadedFiles, setUploadedFiles] = useState([]); + const [allFileOptions, setAllFileOptions] = useState(props.filesOptions); + const fileInputRef = useRef(null); useEffect(() => { @@ -682,6 +683,7 @@ function AgentModificationForm(props: AgentModificationFormProps) { useEffect(() => { if (uploadedFiles.length > 0) { handleAgentFileChange(uploadedFiles); + setAllFileOptions((prev) => [...prev, ...uploadedFiles]); } }, [uploadedFiles]); @@ -1028,7 +1030,7 @@ function AgentModificationForm(props: AgentModificationFormProps) { No files found. - {props.filesOptions.map((file) => ( + {allFileOptions.map((file) => ( ) => { - console.log(JSON.stringify(values)); - let agentsApiUrl = `/api/agents`; fetch(agentsApiUrl, {