From 8e80519cf08b98b1137fcaed004ce8a61ae92086 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Mon, 7 Oct 2024 20:47:09 +0500 Subject: [PATCH] fix(blueprint-modal): pass ?string for toggled attributes --- .../BlueprintModal/Body/Editor/index.tsx | 30 +++++++++++-------- src/network/fetchSourcesData/index.ts | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx index b77a7499f..50e4020b8 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx @@ -88,11 +88,8 @@ const handleSubmitForm = async ( const requestData: { attributes: { [key: string]: string } index?: string - media_url?: string color?: string icon?: string - image_url?: string - source_link?: string } = { ...withoutAttributes, attributes: updatedAttributes, @@ -108,21 +105,15 @@ const handleSubmitForm = async ( } if (mediaOptions.videoAudio) { - requestData.media_url = '' - } else if (initialMediaOptions.videoAudio) { - requestData.media_url = 'delete' + requestData.attributes.media_url = '?string' } if (mediaOptions.image) { - requestData.image_url = '' - } else if (initialMediaOptions.image) { - requestData.image_url = 'delete' + requestData.attributes.image_url = '?string' } if (mediaOptions.sourceLink) { - requestData.source_link = '' - } else if (initialMediaOptions.sourceLink) { - requestData.source_link = 'delete' + requestData.attributes.source_link = '?string' } let res: { status: string; ref_id: string } @@ -365,12 +356,27 @@ export const Editor = ({ setGraphLoading(true) + const toggleMedia: { image_url?: string; source_link?: string; media_url?: string } = {} + + if (mediaOptions.image) { + toggleMedia.image_url = '?string' + } + + if (mediaOptions.sourceLink) { + toggleMedia.source_link = '?string' + } + + if (mediaOptions.videoAudio) { + toggleMedia.media_url = '?string' + } + await editNodeSchemaUpdate(selectedSchema?.ref_id as string, { type: data.type, parent: newParent as string, color: selectedColor, icon: selectedIcon, attributes: { + ...toggleMedia, index: selectedIndex as string, }, }) diff --git a/src/network/fetchSourcesData/index.ts b/src/network/fetchSourcesData/index.ts index 7b0793de6..e18a39ad1 100644 --- a/src/network/fetchSourcesData/index.ts +++ b/src/network/fetchSourcesData/index.ts @@ -184,7 +184,7 @@ export interface UpdateSchemaParams { color?: string icon?: string attributes: { - index: string + [key: string | number]: string } }