hata ayıklama ve kod temizliği
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user