diff --git a/packages/api/server/http.mts b/packages/api/server/http.mts index 9c81f27a..17547912 100644 --- a/packages/api/server/http.mts +++ b/packages/api/server/http.mts @@ -272,6 +272,23 @@ router.delete('/secrets/:name', cors(), async (req, res) => { return res.json({ result: updated }); }); +router.options('/feedback', cors()); +router.post('/feedback', cors(), async (req, res) => { + const { feedback, email } = req.body; + // Every time you modify the appscript here, you'll need to update the URL below + // @TODO: once we have an env variable setup, we can use that here. + const url = + 'https://script.google.com/macros/s/AKfycbxPrg8z47SkJnHyoZBYqNtkcH8hBe12f-f2UJJ3PcIHmKdbMMuJuPoOemEB1ib8a_IKCg/exec'; + + const result = await fetch(url, { + method: 'POST', + body: JSON.stringify({ feedback, email }), + headers: { 'Content-Type': 'text/plain;charset=utf-8' }, + }); + + return res.json({ success: result.ok }); +}); + type NpmSearchResult = { package: { name: string; diff --git a/packages/web/src/components/feedback-dialog.tsx b/packages/web/src/components/feedback-dialog.tsx new file mode 100644 index 00000000..c2d274d4 --- /dev/null +++ b/packages/web/src/components/feedback-dialog.tsx @@ -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 ( + + + + Share Feedback + +
+

+ We're always looking to improve Srcbook and your feedback is invaluable. +
+ You can open a public{' '} + + GitHub issue + {' '} + or use the form below. +

+