Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 'Product thumbnail image is required' alert when I try to update an existing product. #44

Open
vijeshkk opened this issue Oct 26, 2021 · 1 comment

Comments

@vijeshkk
Copy link

Hi Julius,
First of all, thanks alot for this wonderful e-commerce app and making it available to community for free.. :-)

Now to the issue.
error

From admin view, when I try to edit a product and submit the changes, I always get this message 'Product thumbnail image is required.'

I can see the thumbnail is loaded in the edit view, but somehow submit doesnt work without reuploading the thumbnail using 'choose image' button.

This is not as we may not be having the thumbnail copy of the product image all the time.

@vijeshkk
Copy link
Author

I think, product.imageUrl in src\views\admin\components\ProductForm.jsx should be product.image.

After changing onSubmitForm as below, it works fine for me.

  const onSubmitForm = (form) => {
    if (imageFile.image.file || product.imageUrl) {  // old
    if (imageFile.image.file || product.image) { // new
      onSubmit({
        ...form,
        quantity: 1,
        // due to firebase function billing policy, let's add lowercase version
        // of name here instead in firebase functions
        name_lower: form.name.toLowerCase(),
        dateAdded: new Date().getTime(),
        image: imageFile?.image?.file || product.imageUrl,  // old
        image: imageFile?.image?.file || product.image, // new
        imageCollection: imageFile.imageCollection
      });
    } else {
      // eslint-disable-next-line no-alert
      alert('Product thumbnail image is required.');
    }
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant