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

fix: error handling for file upload #1936

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Conversation

pandeymangg
Copy link
Contributor

What does this PR do?

Fixes # (issue)

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • 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
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

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

Copy link

vercel bot commented Jan 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Jan 22, 2024 0:39am
formbricks-com ⬜️ Ignored (Inspect) Jan 22, 2024 0:39am

Copy link
Contributor

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

Copy link
Contributor

packages/surveys/src/components/general/FileInput.tsx

Consider using a more user-friendly approach to display error messages. Instead of using the alert function, which can be intrusive and disrupt the user's workflow, consider displaying the error message in a non-blocking UI element, such as a notification or a message box within the application's interface. This would make the error messages less disruptive and more integrated with the rest of the application.
Create Issue
See the diff
Checkout the fix

    // Instead of:
    alert(err.message);

    // Consider:
    displayNotification(err.message);
git fetch origin && git checkout -b ReviewBot/The-c-1tpxe7z origin/ReviewBot/The-c-1tpxe7z

Consider refactoring the file upload process to handle multiple files concurrently rather than sequentially. This could potentially improve the performance of the file upload process, especially when the user is uploading multiple files at once. You can achieve this by using Promise.all to wait for all file upload promises to resolve.
Create Issue
See the diff
Checkout the fix

    // Instead of:
    for (const file of validFiles) {
      const response = await onFileUpload(file, { allowedFileExtensions, surveyId });
      // ...
    }

    // Consider:
    const uploadPromises = validFiles.map(file => onFileUpload(file, { allowedFileExtensions, surveyId }));
    const responses = await Promise.all(uploadPromises);
    // ...
git fetch origin && git checkout -b ReviewBot/The-c-5vfrezb origin/ReviewBot/The-c-5vfrezb

Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pandeymangg thanks for fixing this so fast; looks great! 😊🚀

@mattinannt mattinannt added this pull request to the merge queue Jan 22, 2024
Merged via the queue into main with commit 64ff49a Jan 22, 2024
14 checks passed
@mattinannt mattinannt deleted the hotfix/file-upload-errors branch January 22, 2024 12:58
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

Successfully merging this pull request may close these issues.

None yet

2 participants