-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add feedback form * Add comment, remove debug log * Add optional email + send from API to avoid CORS
- Loading branch information
Showing
4 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useState } from 'react'; | ||
import { sendFeedback } from '@/lib/server'; | ||
import { toast } from 'sonner'; | ||
import { Button } from '@/components/ui/button'; | ||
import { Input } from '@/components/ui/input'; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
} from '@/components/ui/dialog'; | ||
import { Textarea } from '@/components/ui/textarea'; | ||
|
||
export default function FeedbackDialog({ | ||
open, | ||
onOpenChange, | ||
}: { | ||
open: boolean; | ||
onOpenChange: (open: boolean) => void; | ||
}) { | ||
const [feedback, setFeedback] = useState(''); | ||
const [email, setEmail] = useState(''); | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={onOpenChange}> | ||
<DialogContent className="max-w-xl"> | ||
<DialogHeader> | ||
<DialogTitle>Share Feedback</DialogTitle> | ||
<DialogDescription asChild> | ||
<div className="pt-4 flex flex-col gap-2"> | ||
<p> | ||
We're always looking to improve Srcbook and your feedback is invaluable. | ||
<br /> | ||
You can open a public{' '} | ||
<a | ||
href="https://github.com/srcbookdev/srcbook/issues/new" | ||
className="underline font-medium" | ||
> | ||
GitHub issue | ||
</a>{' '} | ||
or use the form below. | ||
</p> | ||
<Textarea | ||
placeholder="Share anonymous feedback" | ||
value={feedback} | ||
onChange={(e) => setFeedback(e.target.value)} | ||
/> | ||
<Input | ||
type="text" | ||
value={email} | ||
placeholder="Email (optional)" | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
<Button | ||
disabled={!feedback} | ||
onClick={() => { | ||
sendFeedback({ feedback, email }); | ||
setFeedback(''); | ||
setEmail(''); | ||
toast.info('Thanks for the feedback!'); | ||
onOpenChange(false); | ||
}} | ||
className="self-end" | ||
> | ||
Send | ||
</Button> | ||
</div> | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} |
This file contains 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
This file contains 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