From 1087c5aa1f3bfd35d8051f2525434e7623748e2a Mon Sep 17 00:00:00 2001 From: Shoaibdev7 Date: Wed, 25 Sep 2024 12:02:10 +0500 Subject: [PATCH] fix(blue-print): untoggling a media atribute --- .../BlueprintModal/Body/Editor/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx index 4a73481e3..03df72858 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx @@ -69,6 +69,7 @@ const handleSubmitForm = async ( isUpdate = false, deletedAttributes: string[], mediaOptions: { videoAudio: boolean; image: boolean; sourceLink: boolean }, + initialMediaOptions: { videoAudio: boolean; image: boolean; sourceLink: boolean }, ): Promise => { try { // eslint-disable-next-line camelcase @@ -93,14 +94,20 @@ const handleSubmitForm = async ( if (mediaOptions.videoAudio) { requestData.media_url = '' + } else if (initialMediaOptions.videoAudio) { + requestData.media_url = 'delete' } if (mediaOptions.image) { requestData.image_url = '' + } else if (initialMediaOptions.image) { + requestData.image_url = 'delete' } if (mediaOptions.sourceLink) { requestData.source_link = '' + } else if (initialMediaOptions.sourceLink) { + requestData.source_link = 'delete' } let res: { status: string; ref_id: string } @@ -352,6 +359,11 @@ export const Editor = ({ !!selectedSchema, deletedAttributes, mediaOptions, + { + videoAudio: !!selectedSchema?.media_url, + image: !!selectedSchema?.image_url, + sourceLink: !!selectedSchema?.source_link, + }, ) onSchemaCreate({ type: data.type, parent: parent || '', ref_id: selectedSchema?.ref_id || res || 'new' })