fix(web): profile save gives visible feedback (HX-Refresh)
The admin/user profile modal PUT succeeded but the response was a bare JSON body swapped into a small div at the bottom of the still-open modal — no close, no toast, nothing moved. It read as 'the button did nothing' even though the save landed. HX-Request calls now answer with HX-Refresh (re-render shows the saved values everywhere and closes the modal) plus a visible confirmation. API callers keep the JSON body. Silent-failure display already exists site-wide (toast.ts listens for htmx:responseError), so failures were never the silent case.
This commit is contained in:
1 parent
0772f06d25
commit
57d83fd9af
1 file changed
+9
@@ -693,6 +693,15 @@ func (h *AuthHandler) UpdateProfile(c *echo.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Browser path (htmx modal + profile page): refresh so every rendered
|
||||||
|
// value (timezone select, table rows, header) reflects the save and the
|
||||||
|
// modal closes. A bare JSON body swapped into #profile-result read as
|
||||||
|
// "nothing happened" — the save DID land, invisibly.
|
||||||
|
if c.Request().Header.Get("HX-Request") == "true" {
|
||||||
|
c.Response().Header().Set("HX-Refresh", "true")
|
||||||
|
return c.HTML(http.StatusOK, `<div class="text-green-500">Profile updated.</div>`)
|
||||||
|
}
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, map[string]string{"message": "profile updated successfully"})
|
return c.JSON(http.StatusOK, map[string]string{"message": "profile updated successfully"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user