Files
kitebeachakyaka/app/actions/hero.ts
T
2026-06-09 15:15:40 +03:00

49 lines
1.3 KiB
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 { revalidatePath } from "next/cache";
import prisma from "@/lib/prisma";
export type HeroActionState = {
success?: boolean;
message?: string;
} | null;
export async function updateHero(prevState: HeroActionState, formData: FormData): Promise<HeroActionState> {
const lang = formData.get("lang") as string;
const location = formData.get("location") as string;
const welcome = formData.get("welcome") as string;
const title = formData.get("title") as string;
const subtitle = formData.get("subtitle") as string;
const bookNow = formData.get("bookNow") as string;
const exploreActivities = formData.get("exploreActivities") as string;
const scroll = formData.get("scroll") as string;
if (!lang) {
return { success: false, message: "Dil seçimi eksik." };
}
await prisma.heroSection.upsert({
where: { lang },
update: { location, welcome, title, subtitle, bookNow, exploreActivities, scroll },
create: {
lang,
location,
welcome,
title,
subtitle,
bookNow,
exploreActivities,
scroll
}
});
revalidatePath('/admin/hero');
revalidatePath(`/${lang}`);
revalidatePath('/');
return {
success: true,
message: `${lang.toUpperCase()} Hero ayarları başarıyla kaydedildi!`
};
}