22 lines
587 B
TypeScript
22 lines
587 B
TypeScript
'use server'
|
|
|
|
import { createClient } from "@/lib/supabase/server"
|
|
import { revalidatePath } from "next/cache"
|
|
|
|
export async function createPackage(data: { name: string; price: number; description?: string; is_active: boolean }) {
|
|
const supabase = await createClient()
|
|
|
|
const { error } = await supabase.from('packages').insert({
|
|
name: data.name,
|
|
price: data.price,
|
|
description: data.description,
|
|
is_active: data.is_active,
|
|
})
|
|
|
|
if (error) {
|
|
throw new Error(error.message)
|
|
}
|
|
|
|
revalidatePath('/dashboard/settings/packages')
|
|
}
|