Implement i18n with German and English support (default DE)
This commit is contained in:
@@ -4,8 +4,15 @@ import prisma from "@/lib/prisma"
|
||||
import { revalidatePath } from "next/cache"
|
||||
import { headers } from "next/headers"
|
||||
import { sendNotification } from "@/lib/notifications"
|
||||
import { getDictionary } from "@/get-dictionary"
|
||||
|
||||
export async function updatePlan(
|
||||
planId: string,
|
||||
data: { instructions?: string; webhookUrl?: string; notifyAll?: boolean },
|
||||
lang: string = "en"
|
||||
) {
|
||||
const dict = await getDictionary(lang as any)
|
||||
|
||||
export async function updatePlan(planId: string, data: { instructions?: string; webhookUrl?: string; notifyAll?: boolean }) {
|
||||
const plan = await prisma.plan.update({
|
||||
where: { id: planId },
|
||||
data: {
|
||||
@@ -18,9 +25,13 @@ export async function updatePlan(planId: string, data: { instructions?: string;
|
||||
if (data.instructions && plan.webhookUrl && plan.notifyAll) {
|
||||
const host = (await headers()).get("host")
|
||||
const protocol = host?.includes("localhost") ? "http" : "https"
|
||||
const planUrl = `${protocol}://${host}/dashboard/${planId}`
|
||||
await sendNotification(plan.webhookUrl, `📝 UPDATED: Cat instructions have been modified.\nPlan: ${planUrl}`)
|
||||
const planUrl = `${protocol}://${host}/${lang}/dashboard/${planId}`
|
||||
|
||||
await sendNotification(
|
||||
plan.webhookUrl,
|
||||
dict.notifications.instructionsUpdated.replace("{url}", planUrl)
|
||||
)
|
||||
}
|
||||
|
||||
revalidatePath(`/dashboard/${planId}`)
|
||||
revalidatePath(`/${lang}/dashboard/${planId}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user