fix: resolve prisma v6 warning and next 15 form action typings
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import { deleteBlogPostAction } from '@/app/actions'
|
||||
import { Link } from '@/i18n/routing'
|
||||
import DeleteButton from '@/components/DeleteButton'
|
||||
import { Edit, Trash, Plus, FileText, CheckCircle, XCircle } from 'lucide-react'
|
||||
|
||||
export default async function AdminBlogPage() {
|
||||
@@ -97,17 +98,11 @@ export default async function AdminBlogPage() {
|
||||
<Edit className="w-4 h-4" />
|
||||
</Link>
|
||||
|
||||
<form action={async () => {
|
||||
<form action={async () => {
|
||||
'use server'
|
||||
await deleteBlogPostAction(post.id)
|
||||
}}>
|
||||
<button
|
||||
type="submit"
|
||||
className="p-1.5 bg-paper text-shutter hover:text-bougainvillea hover:bg-bougainvillea/5 rounded-lg border border-pine/10 hover:border-bougainvillea/25 transition shadow-sm"
|
||||
title="Sil"
|
||||
>
|
||||
<Trash className="w-4 h-4" />
|
||||
</button>
|
||||
<DeleteButton />
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
@@ -118,6 +113,14 @@ export default async function AdminBlogPage() {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href="/admin/blog/new"
|
||||
className="inline-flex items-center gap-1.5 bg-turquoise hover:bg-turquoise/90 text-paper text-xs font-bold py-3 px-5 rounded-xl shadow-sm transition active:scale-95 duration-150"
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
Yeni Yazı Ekle
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ export default async function CategoryFormPage({ params }: { params: Promise<{ i
|
||||
</div>
|
||||
|
||||
<div className="bg-paper p-6 rounded-2xl shadow-sm border border-pine/8">
|
||||
<form action={createOrUpdateCategoryAction} className="space-y-5">
|
||||
<form action={createOrUpdateCategoryAction as any} className="space-y-5">
|
||||
<input type="hidden" name="id" value={resolvedParams.id} />
|
||||
|
||||
<div>
|
||||
|
||||
@@ -53,7 +53,7 @@ export default async function AdminCategoriesPage() {
|
||||
>
|
||||
<Edit2 className="w-4 h-4" />
|
||||
</Link>
|
||||
<form action={deleteCategoryAction} className="inline-block">
|
||||
<form action={deleteCategoryAction as any} className="inline-block">
|
||||
<input type="hidden" name="id" value={cat.id} />
|
||||
<DeleteButton />
|
||||
</form>
|
||||
|
||||
@@ -30,7 +30,7 @@ export default async function NeighborhoodFormPage({ params }: { params: Promise
|
||||
</div>
|
||||
|
||||
<div className="bg-paper p-6 rounded-2xl shadow-sm border border-pine/8">
|
||||
<form action={createOrUpdateNeighborhoodAction} className="space-y-5">
|
||||
<form action={createOrUpdateNeighborhoodAction as any} className="space-y-5">
|
||||
<input type="hidden" name="id" value={resolvedParams.id} />
|
||||
|
||||
<div>
|
||||
|
||||
+74
-17
@@ -46,7 +46,7 @@ export async function submitBusinessAction(formData: FormData) {
|
||||
})
|
||||
|
||||
revalidatePath('/admin/submissions')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function submitContactMessageAction(formData: FormData) {
|
||||
@@ -67,7 +67,7 @@ export async function submitContactMessageAction(formData: FormData) {
|
||||
})
|
||||
|
||||
revalidatePath('/admin/messages')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function approveSubmissionAction(id: string) {
|
||||
@@ -105,13 +105,13 @@ export async function approveSubmissionAction(id: string) {
|
||||
revalidatePath('/restaurants')
|
||||
revalidatePath('/aparts')
|
||||
revalidatePath('/businesses')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function rejectSubmissionAction(id: string) {
|
||||
await mockDb.updateSubmissionStatus(id, 'REJECTED')
|
||||
revalidatePath('/admin/submissions')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function deleteListingAction(id: string) {
|
||||
@@ -120,21 +120,21 @@ export async function deleteListingAction(id: string) {
|
||||
revalidatePath('/restaurants')
|
||||
revalidatePath('/aparts')
|
||||
revalidatePath('/businesses')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function restoreListingAction(id: string) {
|
||||
await mockDb.restoreListing(id)
|
||||
revalidatePath('/admin/trash')
|
||||
revalidatePath('/admin/listings')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function hardDeleteListingAction(id: string) {
|
||||
try {
|
||||
await mockDb.hardDeleteListing(id)
|
||||
revalidatePath('/admin/trash')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
if (err.message?.includes('RESTRICT') || err.message?.includes('Foreign key constraint')) {
|
||||
return { success: false, error: 'Silme başarısız: Bu mekana bağlı etkinlik (Event) veya kayıtlar var.' }
|
||||
@@ -146,7 +146,7 @@ export async function hardDeleteListingAction(id: string) {
|
||||
export async function markMessageReadAction(id: string) {
|
||||
await mockDb.markMessageAsRead(id)
|
||||
revalidatePath('/admin/messages')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function createOrUpdateListingAction(formData: FormData) {
|
||||
@@ -250,7 +250,7 @@ export async function createOrUpdateListingAction(formData: FormData) {
|
||||
revalidatePath('/restaurants')
|
||||
revalidatePath('/aparts')
|
||||
revalidatePath('/businesses')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
return { success: false, error: err.message || 'Mekan kaydedilemedi.' }
|
||||
}
|
||||
@@ -261,7 +261,7 @@ export async function deleteBlogPostAction(id: string) {
|
||||
await mockDb.deleteBlogPost(id)
|
||||
revalidatePath('/admin/blog')
|
||||
revalidatePath('/blog')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function createOrUpdateBlogPostAction(formData: FormData) {
|
||||
@@ -319,7 +319,7 @@ export async function createOrUpdateBlogPostAction(formData: FormData) {
|
||||
revalidatePath('/admin/blog')
|
||||
revalidatePath('/blog')
|
||||
revalidatePath(`/blog/${slug}`)
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
return { success: false, error: err.message || 'Yazı kaydedilemedi.' }
|
||||
}
|
||||
@@ -330,7 +330,7 @@ export async function deleteCollectionAction(id: string) {
|
||||
await mockDb.deleteCollection(id)
|
||||
revalidatePath('/admin/collections')
|
||||
revalidatePath('/collections')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function createOrUpdateCollectionAction(formData: FormData) {
|
||||
@@ -380,7 +380,7 @@ export async function createOrUpdateCollectionAction(formData: FormData) {
|
||||
revalidatePath('/admin/collections')
|
||||
revalidatePath('/collections')
|
||||
revalidatePath(`/collection/${slug}`)
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
return { success: false, error: err.message || 'Koleksiyon kaydedilemedi.' }
|
||||
}
|
||||
@@ -391,7 +391,7 @@ export async function deleteEventAction(id: string) {
|
||||
await mockDb.deleteEvent(id)
|
||||
revalidatePath('/admin/events')
|
||||
revalidatePath('/events')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function createOrUpdateEventAction(formData: FormData) {
|
||||
@@ -449,7 +449,7 @@ export async function createOrUpdateEventAction(formData: FormData) {
|
||||
revalidatePath('/admin/events')
|
||||
revalidatePath('/events')
|
||||
revalidatePath(`/event/${slug}`)
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
return { success: false, error: err.message || 'Etkinlik kaydedilemedi.' }
|
||||
}
|
||||
@@ -464,7 +464,7 @@ export async function deleteNeighborhoodAction(id: string) {
|
||||
|
||||
await mockDb.deleteNeighborhood(id)
|
||||
revalidatePath('/admin/neighborhoods')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
if (err.message?.includes('RESTRICT') || err.message?.includes('Foreign key constraint')) {
|
||||
return { success: false, error: 'Silme başarısız: Bu mahalleye bağlı gizli (silinmiş veya arşivlenmiş) mekanlar veya etkinlikler var.' }
|
||||
@@ -498,7 +498,7 @@ export async function createOrUpdateNeighborhoodAction(formData: FormData) {
|
||||
await mockDb.createNeighborhood(data)
|
||||
}
|
||||
revalidatePath('/admin/neighborhoods')
|
||||
return { success: true }
|
||||
return { success: true, error: undefined }
|
||||
} catch (err: any) {
|
||||
return { success: false, error: err.message || 'Mahalle kaydedilemedi.' }
|
||||
}
|
||||
@@ -606,3 +606,60 @@ export async function deleteCategoryAction(formData: FormData) {
|
||||
await mockDb.deleteCategory(id)
|
||||
revalidatePath('/admin/categories')
|
||||
}
|
||||
|
||||
export async function deleteSubmissionAction(id: string) {
|
||||
await mockDb.deleteSubmission(id)
|
||||
revalidatePath('/admin/submissions')
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function deleteMessageAction(id: string) {
|
||||
await mockDb.deleteMessage(id)
|
||||
revalidatePath('/admin/messages')
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
export async function searchListingsAction(query: string) {
|
||||
if (!query || query.length < 2) return []
|
||||
|
||||
const allListings = await mockDb.getListings()
|
||||
const q = query.toLowerCase()
|
||||
|
||||
const results = allListings.filter(l =>
|
||||
!l.deletedAt && (
|
||||
l.nameTr.toLowerCase().includes(q) ||
|
||||
l.nameEn?.toLowerCase().includes(q) ||
|
||||
l.nameRu?.toLowerCase().includes(q)
|
||||
)
|
||||
).slice(0, 5) // Return max 5 suggestions
|
||||
|
||||
return results.map(l => ({
|
||||
id: l.id,
|
||||
nameTr: l.nameTr,
|
||||
nameEn: l.nameEn,
|
||||
nameRu: l.nameRu,
|
||||
slug: l.slug,
|
||||
categorySlug: l.category?.slug || 'restoran'
|
||||
}))
|
||||
}
|
||||
|
||||
export async function saveWidgetPartnerAction(formData: FormData) {
|
||||
const id = formData.get('id') as string | null
|
||||
const name = formData.get('name') as string
|
||||
const logoUrl = formData.get('logoUrl') as string
|
||||
const websiteUrl = formData.get('websiteUrl') as string
|
||||
const widgetType = formData.get('widgetType') as string
|
||||
|
||||
if (!name || !logoUrl || !websiteUrl) {
|
||||
return { error: 'Lütfen zorunlu alanları doldurun.' }
|
||||
}
|
||||
|
||||
if (id) {
|
||||
await mockDb.updateWidgetPartner(id, { name, logoUrl, websiteUrl, widgetType })
|
||||
} else {
|
||||
await mockDb.createWidgetPartner({ name, logoUrl, websiteUrl, widgetType })
|
||||
}
|
||||
|
||||
revalidatePath('/admin/widget-partners')
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
@@ -37,8 +37,5 @@
|
||||
"tailwindcss": "^4",
|
||||
"tsx": "^4.23.0",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "tsx prisma/seed.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { defineConfig } from '@prisma/config'
|
||||
|
||||
export default defineConfig({
|
||||
seed: 'tsx prisma/seed.ts'
|
||||
})
|
||||
Reference in New Issue
Block a user