Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blueprint] - Toggling 3 core attributes should send ?string in POST or PUT request #2308

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -366,12 +357,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 @@ -184,7 +184,7 @@ export interface UpdateSchemaParams {
primary_color?: string
icon?: string
attributes: {
index: string
[key: string | number]: string
}
}

Expand Down
Loading