Skip to content

Commit

Permalink
Merge pull request #2308 from MahtabBukhari/pass_toggled_attributes_i…
Browse files Browse the repository at this point in the history
…n_attributes_object_value_is_string

[Blueprint] - Toggling 3 core attributes should send ?string in POST or PUT request
  • Loading branch information
Rassl authored Oct 27, 2024
2 parents 4060195 + c1a853e commit 719e5b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
30 changes: 18 additions & 12 deletions src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ const handleSubmitForm = async (
const requestData: {
attributes: { [key: string]: string }
index?: string
media_url?: string
primary_color?: string
icon?: string
image_url?: string
source_link?: string
} = {
...withoutAttributes,
attributes: updatedAttributes,
Expand All @@ -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 }
Expand Down Expand Up @@ -368,12 +359,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,
primary_color: selectedPrimaryColor,
icon: selectedIcon,
attributes: {
...toggleMedia,
index: selectedIndex as string,
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/network/fetchSourcesData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export interface UpdateSchemaParams {
primary_color?: string
icon?: string
attributes: {
index: string
[key: string | number]: string
}
}

Expand Down

0 comments on commit 719e5b3

Please sign in to comment.