Skip to content

Conversation

@KapadiaNaitik
Copy link
Contributor

What does this PR do?

Add File Upload Question

Fixes #1257 (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change adds a new database migration
  • This change requires a documentation update

How should this be tested?

  • Create new question from the survey editor

Checklist

Required

Will Update During Final Review

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

@vercel
Copy link

vercel bot commented Oct 17, 2023

@KapadiaNaitik is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

@KapadiaNaitik KapadiaNaitik marked this pull request as draft October 17, 2023 20:19
@github-actions github-actions bot added enhancement New feature or request formtribe-2023 hacktoberfest complete these issues to gather points for Hacktoberfest labels Oct 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2023

Thank you for following the naming conventions for pull request titles! 🙏

@review-agent-prime
Copy link
Contributor

Your code looks pretty solid overall, and you did a good job at integrating the File Upload feature. There are a few areas, though, where we could make some potential improvements:

  1. Duplicate ID: In FileUploadQuestionForm.tsx you're using the same id 'm' for multiple Switch components. Please assign unique identifiers to each Switch.

  2. Inline Comments: In FileUploadQuestion.tsx, lines 23-27, you have commented-out code. If this was intended to be removed, then I would suggest deleting it to improve readability and maintain clean codebase.

     ```tsx
          <form onSubmit={(e) => {
         e.preventDefault();
         //  if ( validateInput(value as string, question.inputType, question.required)) {
         onSubmit({ [question.id]: "submitted" });
         // }
     ```
    
  3. Unused Param: In the SubmitButton component in FileUploadQuestion.tsx, the onClick prop for the SubmitButton seems to do nothing.

     ```tsx
         <SubmitButton
           ...
           onClick={() => {}}
         />
     ```
    

    Consider removing it if it's not needed or implement the onClick action if it was overlooked.

  4. Handle File Upload: Currently, I see no functionality to handle file upload in your form. Do remember to implement an input field of type "File" and a function to handle these file uploads.

  5. Data Validation: There does not appear to be any form of file upload size or type validation in the back-end. It's important to always validate form inputs both on the client-side and the server-side for security and data integrity reasons. I suggest adding checks for these in the back-end and client side as well.

That's pretty much about it. Great job on the PR!

@KapadiaNaitik KapadiaNaitik marked this pull request as ready for review October 29, 2023 14:10
@jobenjada
Copy link
Member

@mattinannt these things I couldn't solve:

  1. Better error message when someone tries to upload a too large image. It just says "Upload failed!" - in case we can detect that it happened bc the file size is above the free level, we should display the File Too Large error message.

If not, we should at least add "Try again with a smaller file."


  1. When a file is deleted out of the uploader, the selection window is always opened again. I don't like the UX, bc when you delete something you dont necessarily want to upload a new file.

I've tried stopPropagation and moving the input a level up to not be a child but a sibling of the label (as GPT suggested). Can you fix this?


Rest works well :)

@danielehrhardt
Copy link

@mattinannt these things I couldn't solve:

  1. Better error message when someone tries to upload a too large image. It just says "Upload failed!" - in case we can detect that it happened bc the file size is above the free level, we should display the File Too Large error message.

If not, we should at least add "Try again with a smaller file."

  1. When a file is deleted out of the uploader, the selection window is always opened again. I don't like the UX, bc when you delete something you dont necessarily want to upload a new file.

I've tried stopPropagation and moving the input a level up to not be a child but a sibling of the label (as GPT suggested). Can you fix this?

Rest works well :)

Works great. Would like to see it in the next release <3

@pandeymangg
Copy link
Contributor

The upload functionality is not working for in-app surveys right now, this is due to an overlook in the FileUpload component, will fix this today so that this can get closed 💪

@jobenjada jobenjada enabled auto-merge November 23, 2023 14:32
@jobenjada jobenjada added this pull request to the merge queue Nov 23, 2023
Merged via the queue into formbricks:main with commit 3391957 Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request hacktoberfest complete these issues to gather points for Hacktoberfest hacktoberfest-accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE][FormTribe 🔥][1000 Points] Question Type: File Upload

5 participants