feat: integrate Cloudinary image upload, Instagram Feed, and fix Next.js warnings
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function getAboutSettings() {
|
||||
try {
|
||||
let settings = await prisma.aboutSettings.findUnique({
|
||||
where: { id: "default" }
|
||||
});
|
||||
|
||||
if (!settings) {
|
||||
settings = await prisma.aboutSettings.create({
|
||||
data: {
|
||||
id: "default",
|
||||
title: "Sonsuz Mavilikte Bir Kaçış",
|
||||
description: "Kozmos Beach & More, denizin esintisiyle doğanın ritmini bir araya getiren eşsiz bir deneyim sunuyor. Gündüz güneşin ve berrak denizin tadını çıkarırken, gün batımıyla birlikte DJ performansları ve özel kokteyller eşliğinde unutulmaz anılar biriktirin.",
|
||||
card1Title: "Kusursuz Sahil",
|
||||
card1Desc: "İncecik altın kumu ve turkuaz sularıyla kendinizi tamamen yenileyin.",
|
||||
card2Title: "Gastronomi",
|
||||
card2Desc: "Dünya mutfağından özenle seçilmiş lezzetler ve imza kokteyller.",
|
||||
card3Title: "Canlı Eğlence",
|
||||
card3Desc: "Her akşam gün batımında başlayan benzersiz DJ performansları.",
|
||||
image: "https://images.unsplash.com/photo-1544148103-0773bf10d330?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80",
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { success: true, data: settings };
|
||||
} catch (error) {
|
||||
console.error("Error fetching about settings:", error);
|
||||
return { success: false, error: "Hakkımızda ayarları alınırken bir hata oluştu." };
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateAboutSettings(formData: FormData) {
|
||||
try {
|
||||
const title = formData.get("title") as string;
|
||||
const description = formData.get("description") as string;
|
||||
const card1Title = formData.get("card1Title") as string;
|
||||
const card1Desc = formData.get("card1Desc") as string;
|
||||
const card2Title = formData.get("card2Title") as string;
|
||||
const card2Desc = formData.get("card2Desc") as string;
|
||||
const card3Title = formData.get("card3Title") as string;
|
||||
const card3Desc = formData.get("card3Desc") as string;
|
||||
const image = formData.get("image") as string;
|
||||
|
||||
if (!title || !description || !card1Title || !card1Desc || !card2Title || !card2Desc || !card3Title || !card3Desc || !image) {
|
||||
return { success: false, error: "Tüm alanların doldurulması zorunludur." };
|
||||
}
|
||||
|
||||
await prisma.aboutSettings.upsert({
|
||||
where: { id: "default" },
|
||||
update: { title, description, card1Title, card1Desc, card2Title, card2Desc, card3Title, card3Desc, image },
|
||||
create: { id: "default", title, description, card1Title, card1Desc, card2Title, card2Desc, card3Title, card3Desc, image }
|
||||
});
|
||||
|
||||
revalidatePath("/admin/about");
|
||||
revalidatePath("/");
|
||||
revalidatePath("/tr");
|
||||
revalidatePath("/en");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Error updating about settings:", error);
|
||||
return { success: false, error: "Hakkımızda ayarları güncellenirken bir hata oluştu." };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user