Skip to content

Commit

Permalink
fix(put): request node
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Jan 7, 2025
1 parent 13d9b81 commit 849efdc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/components/ModalsContainer/EditNodeNameModal/Body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getTopicsData, putNodeData } from '~/network/fetchSourcesData'
import { useDataStore } from '~/stores/useDataStore'
import { useSelectedNode } from '~/stores/useGraphStore'
import { useModal } from '~/stores/useModalStore'
import { NodeExtended, NodeRequest, Topic } from '~/types'
import { NodeExtended, Topic } from '~/types'
import { colors } from '~/utils/colors'
import { TitleEditor } from '../Title'

Expand Down Expand Up @@ -90,23 +90,19 @@ export const Body = () => {

const nodeData = {
node_type: node?.node_type,
properties: {
node_data: {
name: updatedData.name,
...(updatedData.image_url && { image_url: updatedData.image_url }),
properties: updatedData.properties,
ref_id: updatedData.ref_id,
},
ref_id: node?.ref_id,
}

try {
await putNodeData(node?.ref_id || '', nodeData as unknown as NodeRequest)
await putNodeData(node?.ref_id || '', nodeData)

const { updateNode } = useDataStore.getState()

updateNode({
...node,
name: updatedData.name,
...(updatedData.image_url && { image_url: updatedData.image_url }),
} as NodeExtended)
updateNode({ ...node, ...nodeData.node_data } as NodeExtended)

closeHandler()
} catch (error) {
Expand Down

0 comments on commit 849efdc

Please sign in to comment.