hata ayıklama ve kod temizliği

This commit is contained in:
2026-01-11 23:58:09 +03:00
parent b2a915240f
commit 32009b4886
22 changed files with 117 additions and 92 deletions

View File

@@ -3,7 +3,15 @@
import { createClient } from "@/lib/supabase-server"
import { revalidatePath } from "next/cache"
export async function createProduct(data: any) {
interface ProductData {
name: string
category: string
description?: string
price: number
image_url?: string
}
export async function createProduct(data: ProductData) {
const supabase = createClient()
// Validate data manually or use Zod schema here again securely
@@ -23,12 +31,12 @@ export async function createProduct(data: any) {
revalidatePath("/dashboard/products")
return { success: true }
} catch (error: any) {
return { success: false, error: error.message }
} catch (error) {
return { success: false, error: (error as Error).message }
}
}
export async function updateProduct(id: number, data: any) {
export async function updateProduct(id: number, data: ProductData) {
const supabase = createClient()
try {
@@ -45,7 +53,7 @@ export async function updateProduct(id: number, data: any) {
revalidatePath("/dashboard/products")
revalidatePath(`/dashboard/products/${id}`)
return { success: true }
} catch (error: any) {
return { success: false, error: error.message }
} catch (error) {
return { success: false, error: (error as Error).message }
}
}