Skip to content

Commit

Permalink
fix(blue-print): untoggling a media atribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoaibdev7 committed Sep 25, 2024
1 parent 2f2e7b9 commit 1087c5a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | undefined> => {
try {
// eslint-disable-next-line camelcase
Expand All @@ -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 }
Expand Down Expand Up @@ -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' })
Expand Down

0 comments on commit 1087c5a

Please sign in to comment.