aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/feedback-button/feedback-button-actions.tsx
diff options
context:
space:
mode:
authorSebastien Castiel <sebastien@castiel.me>2024-01-18 15:46:50 -0500
committerSebastien Castiel <sebastien@castiel.me>2024-01-18 15:48:45 -0500
commitf9040f8beda10b3969572cf8764e49f9b24b222a (patch)
treea48e28bb1d92db3ca29985f2ea450df4e1acc76e /src/components/feedback-button/feedback-button-actions.tsx
parent395c86666cbca10fe5e2f26476437e1e840b3a65 (diff)
Merge feedback and support dialogs
Diffstat (limited to 'src/components/feedback-button/feedback-button-actions.tsx')
-rw-r--r--src/components/feedback-button/feedback-button-actions.tsx23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/components/feedback-button/feedback-button-actions.tsx b/src/components/feedback-button/feedback-button-actions.tsx
new file mode 100644
index 0000000..00c8748
--- /dev/null
+++ b/src/components/feedback-button/feedback-button-actions.tsx
@@ -0,0 +1,23 @@
+'use server'
+import { formSchema } from '@/components/feedback-button/feedback-button-common'
+import { FeedbackButtonEmail } from '@/components/feedback-button/feedback-button-email'
+import { getResend } from '@/lib/resend'
+import { env } from 'process'
+
+export 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} />,
+ })
+}