"use server" import { createClient } from "@/lib/supabase-server" import { revalidatePath } from "next/cache" export async function createProduct(data: any) { const supabase = createClient() // Validate data manually or use Zod schema here again securely // For simplicity, we assume data is coming from the strongly typed Client Form // In production, ALWAYS validate server-side strictly. try { const { error } = await supabase.from("products").insert({ name: data.name, category: data.category, description: data.description, price: data.price, image_url: data.image_url, }) if (error) throw error revalidatePath("/dashboard/products") return { success: true } } catch (error: any) { return { success: false, error: error.message } } } export async function updateProduct(id: number, data: any) { const supabase = createClient() try { const { error } = await supabase.from("products").update({ name: data.name, category: data.category, description: data.description, price: data.price, image_url: data.image_url, }).eq("id", id) if (error) throw error revalidatePath("/dashboard/products") revalidatePath(`/dashboard/products/${id}`) return { success: true } } catch (error: any) { return { success: false, error: error.message } } }