feat(userarea): handle file upload success more

visibly

Improve user feedback during file uploads by explicitly handling HTTP
201 responses as successful uploads. Upon a successful upload, the
progress bar now turns green (`bg-success`) and displays a "Success!"
message, providing a clearer and more immediate visual cue to the user
that their file has been successfully uploaded. This change addresses
usability issues by making the upload progress and outcome more
discernible to users.
This commit is contained in:
Kumi 2024-03-16 21:35:45 +01:00
parent 7d78c5d4a0
commit 53d90cb070
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -117,10 +117,12 @@ function uploadFile(file, progressBar, thumbnail) {
xhr.open('POST', document.location.href, true);
xhr.onload = () => {
if (xhr.status === 200) {
if (xhr.status === 201) {
const response = JSON.parse(xhr.responseText);
const thumbnailUrl = response.thumbnailUrl;
thumbnail.src = thumbnailUrl;
progressBar.classList.add('bg-success');
progressBar.textContent = "Success!";
} else {
progressBar.classList.add('bg-danger');
progressBar.textContent = "Error!";