'use server' import { db } from '@/lib/db' import { revalidatePath } from 'next/cache' import { RoomType } from '@prisma/client' export type RoomInput = { slug: string type: RoomType nameTr: string nameEn: string nameDe: string descriptionTr: string descriptionEn: string descriptionDe: string capacity: number price: number | null imageUrl: string | null images: string[] amenities: string[] available: boolean featured: boolean } export async function createRoom(data: RoomInput) { try { const room = await db.room.create({ data, }) revalidatePath('/[locale]/admin/rooms', 'page') revalidatePath('/[locale]/dairelerimiz', 'page') revalidatePath('/[locale]', 'page') return { success: true, room } } catch (error) { console.error('Failed to create room:', error) return { success: false, error: 'Oda oluşturulurken bir hata oluştu.' } } } export async function updateRoom(id: string, data: RoomInput) { try { const room = await db.room.update({ where: { id }, data, }) revalidatePath('/[locale]/admin/rooms', 'page') revalidatePath('/[locale]/dairelerimiz', 'page') revalidatePath('/[locale]', 'page') return { success: true, room } } catch (error) { console.error('Failed to update room:', error) return { success: false, error: 'Oda güncellenirken bir hata oluştu.' } } } export async function deleteRoom(id: string) { try { await db.room.delete({ where: { id }, }) revalidatePath('/[locale]/admin/rooms', 'page') revalidatePath('/[locale]/dairelerimiz', 'page') revalidatePath('/[locale]', 'page') return { success: true } } catch (error) { console.error('Failed to delete room:', error) return { success: false, error: 'Oda silinirken bir hata oluştu.' } } }