Fix stall update API to use PUT with full object
- Changed updateStall from PATCH to PUT (LNbits API requirement) - Updated to send full stall object instead of partial update - Merges form values with existing stall data before sending 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2ee4aafd05
commit
4a89652ad8
2 changed files with 11 additions and 13 deletions
|
|
@ -389,14 +389,18 @@ const onSubmit = form.handleSubmit(async (values) => {
|
||||||
throw new Error('No wallet admin key available')
|
throw new Error('No wallet admin key available')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the stall with new values
|
// Build full stall object with updated values (API requires PUT with full object)
|
||||||
const updatedStall = await nostrmarketAPI.updateStall(adminKey, currentStall.value.id, {
|
const stallToUpdate = {
|
||||||
|
...currentStall.value,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
config: {
|
config: {
|
||||||
|
...currentStall.value.config,
|
||||||
description: values.description || '',
|
description: values.description || '',
|
||||||
image_url: values.imageUrl || undefined
|
image_url: values.imageUrl || undefined
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
const updatedStall = await nostrmarketAPI.updateStall(adminKey, stallToUpdate)
|
||||||
|
|
||||||
currentStall.value = updatedStall
|
currentStall.value = updatedStall
|
||||||
toast.success('Store settings saved successfully!')
|
toast.success('Store settings saved successfully!')
|
||||||
|
|
|
||||||
|
|
@ -331,23 +331,17 @@ export class NostrmarketAPI extends BaseService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing stall
|
* Update an existing stall
|
||||||
|
* Note: The LNbits API uses PUT and expects the full stall object
|
||||||
*/
|
*/
|
||||||
async updateStall(
|
async updateStall(
|
||||||
walletAdminkey: string,
|
walletAdminkey: string,
|
||||||
stallId: string,
|
stallData: Stall
|
||||||
stallData: Partial<{
|
|
||||||
name: string
|
|
||||||
config: {
|
|
||||||
description?: string
|
|
||||||
image_url?: string
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
): Promise<Stall> {
|
): Promise<Stall> {
|
||||||
const stall = await this.request<Stall>(
|
const stall = await this.request<Stall>(
|
||||||
`/api/v1/stall/${stallId}`,
|
`/api/v1/stall/${stallData.id}`,
|
||||||
walletAdminkey,
|
walletAdminkey,
|
||||||
{
|
{
|
||||||
method: 'PATCH',
|
method: 'PUT',
|
||||||
body: JSON.stringify(stallData),
|
body: JSON.stringify(stallData),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue