b
This commit is contained in:
@@ -645,3 +645,40 @@ export async function searchListingsAction(query: string) {
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
export async function saveWidgetPartnerAction(formData: FormData) {
|
||||
const id = formData.get('id') as string | null
|
||||
const name = formData.get('name') as string
|
||||
const url = formData.get('url') as string
|
||||
const neighborhoodSlug = formData.get('neighborhoodSlug') as string | null
|
||||
const isActive = formData.get('isActive') === 'true'
|
||||
|
||||
if (!name || !url) {
|
||||
return { error: 'Lütfen zorunlu alanları doldurun.' }
|
||||
}
|
||||
|
||||
const data = {
|
||||
name,
|
||||
url,
|
||||
neighborhoodSlug: neighborhoodSlug || null,
|
||||
isActive
|
||||
}
|
||||
|
||||
try {
|
||||
if (id && id !== 'new') {
|
||||
await mockDb.updateWidgetPartner(id, data)
|
||||
} else {
|
||||
await mockDb.createWidgetPartner(data)
|
||||
}
|
||||
revalidatePath('/admin/widget-partners')
|
||||
return { success: true, error: undefined }
|
||||
} catch (error: any) {
|
||||
return { error: error.message || 'Bir hata oluştu.' }
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteWidgetPartnerAction(id: string) {
|
||||
await mockDb.deleteWidgetPartner(id)
|
||||
revalidatePath('/admin/widget-partners')
|
||||
return { success: true, error: undefined }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user