Add interactive feedback form with API submission - #700
Draft
hdprajwal wants to merge 4 commits into
Draft
Conversation
Contributor
Cloudflare Pages preview
|
| </select> | ||
| <div | ||
| role="dialog" | ||
| aria-label="Send feedback" |
Collaborator
There was a problem hiding this comment.
Can you rebase to use the PopupCard component?
If we need to add or modify any styles with the PopupCard we can.
| Close | ||
| </HoverableButton> | ||
| </div> | ||
| ); |
Collaborator
There was a problem hiding this comment.
As a rule of thumb, files should be less than 100 lines long. Please refactor components into other files -- especially large inner components.
|
|
||
| const SCRIPT_SRC = 'https://challenges.cloudflare.com/turnstile/v0/api.js'; | ||
|
|
||
| interface TurnstileApi { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: This swaps the old
mailto:feedback link for a real form inside the app. When someone submits, it sends the feedback to a Cloudflare Worker, which saves it in a D1 database. It can also show a Cloudflare Turnstile check to keep bots out, but only if a site key is set.Changes
submitFeedback.tsposts the feedback to the worker and throws if the response is not OK. It turns rate-limit and verification errors into plain messages people can understand.TurnstileWidget.tsxloads the Turnstile script once and shows the bot check, but only when a site key is set. It hands the solved token back to the form.FeedbackForm.tsxwas rewritten. It is now its own dialog with simple states: idle, submitting, success, and error. You can only send when the message is not empty, and when the Turnstile check is solved if one is shown.VITE_FEEDBACK_API_URLfor the worker URL, and an optionalVITE_TURNSTILE_SITE_KEY. Both are written down in.env.exampleandsrc/vite-env.d.ts.getFeedbackEmailBody.ts. We no longer build an email body.PageNavBar.tsxnow holds the open and close state and shows the button.FeedbackFormtakes anonCloseprop.ZIndex.FeedbackForm.Out of scope/Future work: clicking outside the form does not close it yet. The Cloudflare Worker and D1 backend are in a separate change.
Test Plan and Screenshots
How to test the changes in this PR:
VITE_FEEDBACK_API_URLand run the feedback worker locally, or point it at the deployed worker. If you want to test the bot check, also setVITE_TURNSTILE_SITE_KEY.npm run devand click "Feedback" in the navbar.Checklist
Summary
Testing
npm run lintnpm run buildnpm run testnpm run dev, tried out the form by hand using the steps aboveDocs