feat: change language
Deploy On Server / Prepare Repository Remotely (push) Successful in 9s
Deploy On Server / Docker Compose Up (push) Successful in 17s
Deploy On Server / Prune Images (push) Successful in 3s
Deploy On Server / Remove .env File (push) Successful in 3s

This commit is contained in:
Raul Lugo
2026-08-11 23:42:47 +02:00
parent d1a352a473
commit 3c359285ad
5 changed files with 208 additions and 2 deletions
+52 -2
View File
@@ -4,14 +4,25 @@ import { revalidatePath } from "next/cache"
import { auth } from "@/auth"
import { isAdminEmail } from "@/lib/admin-auth"
import { updateSaveTheDateSent } from "@/lib/db/queries/invitations"
import { updateSaveTheDateSentSchema } from "@/lib/validation/invitation"
import {
updateInvitationLanguage,
updateSaveTheDateSent,
} from "@/lib/db/queries/invitations"
import {
updateInvitationLanguageSchema,
updateSaveTheDateSentSchema,
} from "@/lib/validation/invitation"
export interface UpdateSaveTheDateSentResult {
ok: boolean
error: string | null
}
export interface UpdateInvitationLanguageResult {
ok: boolean
error: string | null
}
export async function updateSaveTheDateSentAction(input: {
invitationId: string
sent: boolean
@@ -49,3 +60,42 @@ export async function updateSaveTheDateSentAction(input: {
return { ok: true, error: null }
}
export async function updateInvitationLanguageAction(input: {
invitationId: string
language: string
}): Promise<UpdateInvitationLanguageResult> {
const session = await auth()
const adminEmail = session?.user?.email
if (!isAdminEmail(adminEmail)) {
return { ok: false, error: "You are not allowed to update invitations." }
}
const parsed = updateInvitationLanguageSchema.safeParse(input)
if (!parsed.success) {
return { ok: false, error: "Select a supported language." }
}
try {
const updated = await updateInvitationLanguage({
invitationId: parsed.data.invitationId,
language: parsed.data.language,
adminEmail: adminEmail ?? "",
})
if (!updated) {
return { ok: false, error: "This guest group no longer exists." }
}
} catch (error) {
console.error("Failed to update invitation language", error)
return { ok: false, error: "Could not update the invitation language." }
}
revalidatePath(`/admin/guests/${parsed.data.invitationId}`)
revalidatePath("/admin/guests")
revalidatePath("/admin")
return { ok: true, error: null }
}