Skip to content

Commit 6ed2d22

Browse files
committed
fix: remove signature from store when delete returns 404
When attempting to delete a signature that no longer exists on the server (404 response), the signature was not being removed from the Pinia store, leaving stale data in the UI. This fix checks for 404 status in the error handler and clears the signature from the store, ensuring the UI state matches the server state even when the signature was already deleted. Also improved error handling to safely access nested response properties and provide a fallback error message. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 2abe0fe commit 6ed2d22

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/store/signatureElements.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,11 @@ export const useSignatureElementsStore = function(...args) {
136136
this.signs[type] = emptyElement
137137
this.success = data.ocs.data.message
138138
})
139-
.catch(({ data }) => {
140-
this.error = { message: data.ocs.data.message }
139+
.catch(({ response }) => {
140+
if (response?.status === 404) {
141+
this.signs[type] = emptyElement
142+
}
143+
this.error = { message: response?.data?.ocs?.data?.message || 'Error deleting signature' }
141144
})
142145
},
143146
},

0 commit comments

Comments
 (0)