Update application features and add scripts (core changes)

This commit is contained in:
AyrisAI
2026-07-19 11:38:56 +03:00
parent a36b833e00
commit da84cdc231
44 changed files with 2953 additions and 449 deletions
+75
View File
@@ -0,0 +1,75 @@
'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.' }
}
}