textures1245 / csmju-comcamp-22nd-promote

ComCamp 22nd for Computer Science Maejo University promote project.
https://comcamp.csmju.com/
0 stars 1 forks source link

Uncaught (in promise) FirebaseError: Function setDoc() called with invalid data. Unsupported field value: undefined #6

Closed moking55 closed 9 months ago

moking55 commented 9 months ago

When a user leaves the "Reason for Joining" text area blank on the information form page and clicks the "Save" button, an error occurs:

Uncaught (in promise) FirebaseError: Function setDoc() called with invalid data. Unsupported field value: undefined (found in field info.reasonForJoining in document users/[user id])

Steps to Reproduce:

  1. Navigate to the authentication page.
  2. On the information form page, scroll down to the "Survey" section.
  3. Leave the "Reason for Joining" text area blank.
  4. Click the "Save" button.

Expected Behavior:

The user should be able to leave the "Reason for Joining" text area blank and save the form without encountering an error.

Actual Behavior:

An error occurs when the user leaves the "Reason for Joining" text area blank and saves the form.

Impact:

This bug prevents users from submitting the information form without providing a reason for joining.

Priority:

High

Resolution:

The code should be modified to handle the case where the user leaves the "Reason for Joining" text area blank. The field should either be set to null or be omitted from the data that is saved to Firestore.

Additional Notes:

This bug is specific to the reason for joining field. Other fields on the form do not appear to be affected by this issue.

textures1245 commented 9 months ago

Thank you for reporting this bug and providing detailed steps to reproduce it. I appreciate you taking the time to identify and report this issue, which is preventing users from submitting the information form without providing a reason for joining.

I have investigated the issue and identified the root cause. As you mentioned, the issue arises due to the dynamic creation of the "Reason for Joining" text area based on the checkbox input state. When the user leaves the checkbox unchecked, the text area is not created, resulting in an undefined value being submitted.

To fix this bug, I modified the code to ensure that the "Reason for Joining" text area is always created by using "hidden class directive" instead of "if directive", regardless of the checkbox input state. This will ensure that a valid value is always submitted, even if the user leaves the text area empty.

I had also add a validation check to prevent the form from being submitted if the "Reason for Joining" text area is empty. This will ensure that users are prompted to provide a reason for joining before they can submit the form.

I tested these changes thoroughly to ensure that they resolved the issue and did not introduce any new bugs. And already committed this to the 0e85953 commit version.

Thank you again for your valuable contribution to our project. Your attention to detail is helping us to improve the user experience and ensure that our application is working as intended.