Initial commit: Cat Sitting Planner with PWA, SQLite, and Webhook Notifications
This commit is contained in:
22
app/actions/plan.ts
Normal file
22
app/actions/plan.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
"use server"
|
||||
|
||||
import prisma from "@/lib/prisma"
|
||||
import { revalidatePath } from "next/cache"
|
||||
import { sendNotification } from "@/lib/notifications"
|
||||
|
||||
export async function updatePlan(planId: string, data: { instructions?: string; webhookUrl?: string; notifyAll?: boolean }) {
|
||||
const plan = await prisma.plan.update({
|
||||
where: { id: planId },
|
||||
data: {
|
||||
instructions: data.instructions,
|
||||
webhookUrl: data.webhookUrl,
|
||||
notifyAll: data.notifyAll,
|
||||
}
|
||||
})
|
||||
|
||||
if (data.instructions && plan.webhookUrl && plan.notifyAll) {
|
||||
await sendNotification(plan.webhookUrl, `📝 UPDATED: Cat instructions have been modified.`)
|
||||
}
|
||||
|
||||
revalidatePath(`/dashboard/${planId}`)
|
||||
}
|
||||
Reference in New Issue
Block a user