first commit

This commit is contained in:
mstfyldz
2026-06-03 04:11:30 +03:00
parent d369c9e258
commit 7b4b3a85af
20 changed files with 3446 additions and 442 deletions
+22
View File
@@ -0,0 +1,22 @@
'use server'
import { saveCategories, type Category } from '@/data/menu'
import { revalidatePath } from 'next/cache'
import { cookies } from 'next/headers'
async function checkAuth() {
const cookieStore = await cookies()
const session = cookieStore.get('admin_session')?.value
if (!session || session !== (process.env.ADMIN_SECRET || 'secret')) {
throw new Error('Unauthorized')
}
}
export async function saveEntireMenu(categories: Category[]) {
await checkAuth()
await saveCategories(categories)
// Revalidate both language paths
revalidatePath('/tr')
revalidatePath('/en')
return { success: true }
}