Skip to content

Commit

Permalink
fix(refactor): update node request structure and types
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Jan 10, 2025
1 parent 9c45bb3 commit 606e924
Show file tree
Hide file tree
Showing 2 changed files with 358 additions and 350 deletions.
18 changes: 12 additions & 6 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, Topic } from '~/types'
import { NodeExtended, NodeRequest, Topic } from '~/types'
import { colors } from '~/utils/colors'
import { TitleEditor } from '../Title'

Expand Down Expand Up @@ -88,21 +88,27 @@ export const Body = () => {

const updatedData = getValues()

const nodeData = {
const nodeData: NodeRequest = {
node_type: node?.node_type,
node_data: {
properties: {
name: updatedData.name,
properties: updatedData.properties,
ref_id: updatedData.ref_id,
...(updatedData.properties as Record<string, unknown>),
},
ref_id: node?.ref_id,
}

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

const { updateNode } = useDataStore.getState()

updateNode({ ...node, ...nodeData.node_data } as NodeExtended)
const updatedNode: NodeExtended = {
...node,
name: nodeData.properties.name || '',
properties: nodeData.properties,
} as NodeExtended

updateNode(updatedNode)

closeHandler()
} catch (error) {
Expand Down
Loading

0 comments on commit 606e924

Please sign in to comment.