ipungg-junior / yummypiv

The Restaurant Management Web App is a software solution designed to help restaurant owners and managers efficiently manage daily operations. This application aims to enhance productivity, facilitate monitoring, and improve customer experience.
https://yummypiv.com
0 stars 0 forks source link

[FIX] rev cancel image input on form upload product #33

Closed ipungg-junior closed 4 weeks ago

ipungg-junior commented 4 weeks ago

When img canceledd, loading must be stopped, and field input img must be clear

Here is new code modal/upload_product.html

     imageInputProduct.addEventListener('change', function (event) {
            const file = event.target.files[0];
            const maxSize = 8 * 1024 * 1024; // 8MB.

            if (file) {
                if (file.size > maxSize) {
                    alert('Ukuran file tidak boleh lebih dari 8MB.');
                    file.value = '';
                    imageInputProduct.value = '';
                    loadingProduct.hidden = true;
                } else {
                    loadingProduct.hidden = false;
                    const reader = new FileReader();
                    reader.onload = function (e) {
                        imagePreviewProduct.src = e.target.result;
                        imagePreviewProduct.hidden = false;
                    };
                    reader.readAsDataURL(file);
                    imageInputProduct.hidden = true;
                    loadingProduct.hidden = true;
                }
            }
        });