1
1
'use server'
2
2
3
- import { Database , Update } from "@/lib/db"
3
+ import { Update } from "@/lib/db"
4
4
import { getAppBySlug } from "@/lib/db/apps"
5
5
import { createNewChat as createNewChatDb , deleteChat as deleteChatDb , updateChat as updateChatDb } from "@/lib/db/chats"
6
6
import { getCurrentSession } from "@/lib/session"
7
- import { createServerComponentClient } from "@supabase/auth-helpers-nextjs "
7
+ import { createClient } from "@/lib/ supabase/server "
8
8
import { revalidatePath } from "next/cache"
9
9
import { cookies } from "next/headers"
10
10
import { redirect } from "next/navigation"
11
11
12
12
export const createNewChat = async ( ) => {
13
- const supabase = createServerComponentClient < Database > ( { cookies } )
13
+ const cookieStore = cookies ( )
14
+ const supabase = createClient ( cookieStore )
14
15
const session = await getCurrentSession ( supabase )
15
16
const currentApp = await getAppBySlug ( supabase , '/apps/chat' )
16
17
@@ -32,7 +33,8 @@ export const createNewChat = async () => {
32
33
}
33
34
34
35
export const deleteChat = async ( id : string ) => {
35
- const supabase = createServerComponentClient < Database > ( { cookies } )
36
+ const cookieStore = cookies ( )
37
+ const supabase = createClient ( cookieStore )
36
38
37
39
try {
38
40
await deleteChatDb ( supabase , id )
@@ -43,7 +45,8 @@ export const deleteChat = async (id: string) => {
43
45
}
44
46
45
47
export const updateChat = async ( params : Update < 'chats' > ) => {
46
- const supabase = createServerComponentClient < Database > ( { cookies } )
48
+ const cookieStore = cookies ( )
49
+ const supabase = createClient ( cookieStore )
47
50
const { id, ...rest } = params
48
51
if ( ! id ) {
49
52
throw new Error ( 'Missing ID' )
0 commit comments