Skip to content

Commit

Permalink
Merge pull request #1748 from MuhammadUmer44/Pass-and-delete-inside-a…
Browse files Browse the repository at this point in the history
…ttributes-object

fix(blue-print): pass attribute and delete inside attributes object
  • Loading branch information
Rassl authored Jul 23, 2024
2 parents d0bed57 + 7d0792a commit c6c045a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,20 @@ const handleSubmitForm = async (
try {
const { attributes, ...withoutAttributes } = data

const updatedAttributes = {
...convertAttributes(attributes),
...deletedAttributes.reduce<{ [key: string]: string }>((acc, key) => ({ ...acc, [key]: 'delete' }), {}),
}

const requestData = {
...withoutAttributes,
attributes: convertAttributes(attributes),
...deletedAttributes.reduce<{ [key: string]: string }>((acc, key) => ({ ...acc, [key]: 'delete' }), {}),
attributes: updatedAttributes,
}

let res: { status: string; ref_id: string }

if (isUpdate) {
res = await api.put(`/schema`, JSON.stringify(requestData), {})
res = await api.put(`/schema/${data.ref_id}`, JSON.stringify(requestData), {})
} else {
res = await api.post(`/schema`, JSON.stringify({ ...requestData, node_key: 'name' }), {})
}
Expand Down

0 comments on commit c6c045a

Please sign in to comment.