@@ -3,10 +3,9 @@ import {
33 getSession ,
44 getUserDetails ,
55 getSubscription
6- } from '@/app/supabase-server' ;
6+ } from '@/app/supabase-server-calls ' ;
77import Button from '@/components/ui/Button' ;
8- import { Database } from '@/types_db' ;
9- import { createServerActionClient } from '@supabase/auth-helpers-nextjs' ;
8+ import { createClient } from '@/utils/supabase/server' ;
109import { revalidatePath } from 'next/cache' ;
1110import { cookies } from 'next/headers' ;
1211import Link from 'next/link' ;
@@ -38,13 +37,15 @@ export default async function Account() {
3837 'use server' ;
3938
4039 const newName = formData . get ( 'name' ) as string ;
41- const supabase = createServerActionClient < Database > ( { cookies } ) ;
40+ const cookieStore = cookies ( ) ;
41+ const supabase = createClient ( cookieStore ) ;
4242 const session = await getSession ( ) ;
43- const user = session ?. user ;
43+ if ( ! session ) return redirect ( '/signin' ) ;
44+ const user = session . user ;
4445 const { error } = await supabase
4546 . from ( 'users' )
4647 . update ( { full_name : newName } )
47- . eq ( 'id' , user ? .id ) ;
48+ . eq ( 'id' , user . id ) ;
4849 if ( error ) {
4950 console . log ( error ) ;
5051 }
@@ -55,7 +56,8 @@ export default async function Account() {
5556 'use server' ;
5657
5758 const newEmail = formData . get ( 'email' ) as string ;
58- const supabase = createServerActionClient < Database > ( { cookies } ) ;
59+ const cookieStore = cookies ( ) ;
60+ const supabase = createClient ( cookieStore ) ;
5961 const { error } = await supabase . auth . updateUser ( { email : newEmail } ) ;
6062 if ( error ) {
6163 console . log ( error ) ;
0 commit comments