Files
moybeach-main/app/actions.ts
T

31 lines
794 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use server';
import { prisma } from '@/lib/db';
export async function submitContactMessage(formData: FormData) {
const name = formData.get('name') as string;
const email = formData.get('email') as string;
const subject = formData.get('subject') as string | null;
const message = formData.get('message') as string;
if (!name || !email || !message) {
return { error: 'Gerekli alanları doldurunuz.' };
}
try {
await prisma.contactMessage.create({
data: {
name,
email,
subject,
message,
isRead: false,
}
});
return { success: true };
} catch (error) {
console.error('Mesaj gönderilirken hata:', error);
return { error: 'Mesajınız gönderilirken bir hata oluştu. Lütfen tekrar deneyin.' };
}
}