aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/feedback-button/feedback-button.tsx
diff options
context:
space:
mode:
authorSebastien Castiel <sebastien@castiel.me>2024-01-09 15:32:19 -0500
committerSebastien Castiel <sebastien@castiel.me>2024-01-09 15:32:19 -0500
commit323b0ea1282abc0945cef1ebf8185bdf9a156f5d (patch)
tree5526370fed1acbcb3cc2d43b9b1d0a6264783b47 /src/components/feedback-button/feedback-button.tsx
parent5ce96aef30b87a1aeecfac67e99621b06ab64b93 (diff)
Feedback button
Diffstat (limited to 'src/components/feedback-button/feedback-button.tsx')
-rw-r--r--src/components/feedback-button/feedback-button.tsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components/feedback-button/feedback-button.tsx b/src/components/feedback-button/feedback-button.tsx
new file mode 100644
index 0000000..d43f8a7
--- /dev/null
+++ b/src/components/feedback-button/feedback-button.tsx
@@ -0,0 +1,27 @@
+import { FeedbackButtonClient } from '@/components/feedback-button/feedback-button-client'
+import { formSchema } from '@/components/feedback-button/feedback-button-common'
+import { FeedbackButtonEmail } from '@/components/feedback-button/feedback-button-email'
+import { env } from '@/lib/env'
+import { getResend } from '@/lib/resend'
+
+export function FeedbackButton() {
+ async function sendFeedback(values: unknown) {
+ 'use server'
+ const { email, message } = formSchema.parse(values)
+ const resend = getResend()
+ if (!resend || !env.FEEDBACK_EMAIL_FROM || !env.FEEDBACK_EMAIL_TO) {
+ console.warn(
+ 'Resend is not properly configured. Feedback email won’t be sent.',
+ )
+ return
+ }
+ await resend.emails.send({
+ from: env.FEEDBACK_EMAIL_FROM,
+ to: env.FEEDBACK_EMAIL_TO,
+ subject: `Spliit: new feedback from ${email || 'anonymous user'}`,
+ react: <FeedbackButtonEmail email={email} message={message} />,
+ })
+ }
+
+ return <FeedbackButtonClient sendFeedback={sendFeedback} />
+}