File tree Expand file tree Collapse file tree
apps/website/app/utils/supabase Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,3 +124,26 @@ export const createGroup = async (
124124 ) ;
125125 return result . data ?. group_id || null ;
126126} ;
127+
128+ export const removeFromGroup = async ( {
129+ client,
130+ groupId,
131+ memberId,
132+ } : {
133+ client : DGSupabaseClient ;
134+ groupId : string ;
135+ memberId ?: string ;
136+ } ) : Promise < string | null > => {
137+ if ( memberId === undefined ) {
138+ const userData = await getSessionBaseUserData ( client ) ;
139+ memberId = userData ?. id ?? undefined ;
140+ if ( memberId === undefined ) return "Not logged in" ;
141+ }
142+ const response = await client
143+ . from ( "group_membership" )
144+ . delete ( )
145+ . eq ( "member_id" , memberId )
146+ . eq ( "group_id" , groupId ) ;
147+ if ( response . error ) return response . error . message ;
148+ return null ; // success
149+ } ;
You can’t perform that action at this time.
0 commit comments