mirror of
https://github.com/r-freeman/portfolio.git
synced 2025-04-24 19:14:36 +00:00
Add new subscriber notification
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m10s
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m10s
This commit is contained in:
parent
36532bc1f1
commit
af927a4331
@ -2,6 +2,16 @@
|
||||
|
||||
import {z} from 'zod'
|
||||
import {addSubscriber} from '@/lib/listmonk'
|
||||
import {sendNotification} from '@/lib/ntfy'
|
||||
|
||||
const notificationBody = (email: FormDataEntryValue | null) => {
|
||||
return {
|
||||
topic: 'portfolio',
|
||||
message: `${email} has subscribed to your newsletter.`,
|
||||
title: 'New subscriber',
|
||||
tags: ['rocket']
|
||||
}
|
||||
}
|
||||
|
||||
export async function subscribe(prevState: { message: string }, formData: FormData) {
|
||||
const schema = z.object({
|
||||
@ -28,5 +38,7 @@ export async function subscribe(prevState: { message: string }, formData: FormDa
|
||||
return {message: errorMessage}
|
||||
}
|
||||
|
||||
await sendNotification(notificationBody(email))
|
||||
|
||||
return {message: 'Subscribed'}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user