Skip to content

Commit 13b5cb8

Browse files
shleeableYour Name
andauthored
Bugfix: Update Settings.vue - finally window.location.reload() was reloading on validation errors instead of showing error. (#458)
* Update Settings.vue * prettier --------- Co-authored-by: Your Name <you@example.com>
1 parent 008a3e3 commit 13b5cb8

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

resources/js/pages/admin/Settings.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,12 +2087,22 @@ const saveSettings = async () => {
20872087
20882088
try {
20892089
const response = await settingsApi.updateSettings(settings)
2090-
} catch (error) {
2091-
alertModal('Error', error?.response?.data?.message)
2092-
} finally {
2093-
saving.value = false
20942090
await nextTick()
20952091
window.location.reload()
2092+
} catch (error) {
2093+
saving.value = false
2094+
const errorMessage =
2095+
error?.response?.data?.message || 'An error occurred while saving settings'
2096+
const validationErrors = error?.response?.data?.errors
2097+
2098+
if (validationErrors) {
2099+
const errorList = Object.entries(validationErrors)
2100+
.map(([field, messages]) => `${field}: ${messages.join(', ')}`)
2101+
.join('\n')
2102+
alertModal('Validation Error', `${errorMessage}\n\n${errorList}`)
2103+
} else {
2104+
alertModal('Error', errorMessage)
2105+
}
20962106
}
20972107
}
20982108

0 commit comments

Comments
 (0)