fix: use API response data for grid local state updates
- use addResult/response directly instead of manually constructing objects - fixes grid not displaying items until refresh - API response has proper GridWeapon/Character/Summon structure
This commit is contained in:
parent
a34e0f939b
commit
782aaf1479
1 changed files with 6 additions and 60 deletions
|
|
@ -168,16 +168,7 @@
|
||||||
itemAdded = true
|
itemAdded = true
|
||||||
|
|
||||||
// Update local state with the added weapon
|
// Update local state with the added weapon
|
||||||
weapons = [...weapons, {
|
weapons = [...weapons, addResult]
|
||||||
id: addResult.id || `temp-${Date.now()}`,
|
|
||||||
position,
|
|
||||||
object: {
|
|
||||||
granblueId: firstItem.granblueId,
|
|
||||||
name: firstItem.name,
|
|
||||||
element: firstItem.element
|
|
||||||
},
|
|
||||||
mainhand: position === -1
|
|
||||||
}]
|
|
||||||
} else if (activeTab === GridType.Summon) {
|
} else if (activeTab === GridType.Summon) {
|
||||||
// Use selectedSlot if available, otherwise default to main summon
|
// Use selectedSlot if available, otherwise default to main summon
|
||||||
if (selectedSlot === null) position = -1
|
if (selectedSlot === null) position = -1
|
||||||
|
|
@ -192,17 +183,7 @@
|
||||||
itemAdded = true
|
itemAdded = true
|
||||||
|
|
||||||
// Update local state with the added summon
|
// Update local state with the added summon
|
||||||
summons = [...summons, {
|
summons = [...summons, addResult]
|
||||||
id: addResult.id || `temp-${Date.now()}`,
|
|
||||||
position,
|
|
||||||
object: {
|
|
||||||
granblueId: firstItem.granblueId,
|
|
||||||
name: firstItem.name,
|
|
||||||
element: firstItem.element
|
|
||||||
},
|
|
||||||
main: position === -1,
|
|
||||||
friend: position === 6
|
|
||||||
}]
|
|
||||||
} else if (activeTab === GridType.Character) {
|
} else if (activeTab === GridType.Character) {
|
||||||
// Use selectedSlot if available, otherwise default to first slot
|
// Use selectedSlot if available, otherwise default to first slot
|
||||||
if (selectedSlot === null) position = 0
|
if (selectedSlot === null) position = 0
|
||||||
|
|
@ -215,15 +196,7 @@
|
||||||
itemAdded = true
|
itemAdded = true
|
||||||
|
|
||||||
// Update local state with the added character
|
// Update local state with the added character
|
||||||
characters = [...characters, {
|
characters = [...characters, addResult]
|
||||||
id: addResult.id || `temp-${Date.now()}`,
|
|
||||||
position,
|
|
||||||
object: {
|
|
||||||
granblueId: firstItem.granblueId,
|
|
||||||
name: firstItem.name,
|
|
||||||
element: firstItem.element
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
selectedSlot = null // Reset after using
|
selectedSlot = null // Reset after using
|
||||||
|
|
||||||
|
|
@ -311,16 +284,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add to local state
|
// Add to local state
|
||||||
weapons = [...weapons, {
|
weapons = [...weapons, response]
|
||||||
id: response.id || `temp-${Date.now()}`,
|
|
||||||
position,
|
|
||||||
object: {
|
|
||||||
granblueId: item.granblueId,
|
|
||||||
name: item.name,
|
|
||||||
element: item.element
|
|
||||||
},
|
|
||||||
mainhand: position === -1
|
|
||||||
}]
|
|
||||||
} else if (activeTab === GridType.Summon) {
|
} else if (activeTab === GridType.Summon) {
|
||||||
// Use selectedSlot for first item if available
|
// Use selectedSlot for first item if available
|
||||||
if (i === 0 && selectedSlot !== null && !summons.find(s => s.position === selectedSlot)) {
|
if (i === 0 && selectedSlot !== null && !summons.find(s => s.position === selectedSlot)) {
|
||||||
|
|
@ -344,17 +308,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add to local state
|
// Add to local state
|
||||||
summons = [...summons, {
|
summons = [...summons, response]
|
||||||
id: response.id || `temp-${Date.now()}`,
|
|
||||||
position,
|
|
||||||
object: {
|
|
||||||
granblueId: item.granblueId,
|
|
||||||
name: item.name,
|
|
||||||
element: item.element
|
|
||||||
},
|
|
||||||
main: position === -1,
|
|
||||||
friend: position === 6
|
|
||||||
}]
|
|
||||||
} else if (activeTab === GridType.Character) {
|
} else if (activeTab === GridType.Character) {
|
||||||
// Use selectedSlot for first item if available
|
// Use selectedSlot for first item if available
|
||||||
if (i === 0 && selectedSlot !== null && !characters.find(c => c.position === selectedSlot)) {
|
if (i === 0 && selectedSlot !== null && !characters.find(c => c.position === selectedSlot)) {
|
||||||
|
|
@ -376,15 +330,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add to local state
|
// Add to local state
|
||||||
characters = [...characters, {
|
characters = [...characters, response]
|
||||||
id: response.id || `temp-${Date.now()}`,
|
|
||||||
position,
|
|
||||||
object: {
|
|
||||||
granblueId: item.granblueId,
|
|
||||||
name: item.name,
|
|
||||||
element: item.element
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue