@@ -63,16 +63,22 @@ export function MemberCard({
6363 ( state : OrganizationStateStore ) => state . currentOrganizationId
6464 ) ;
6565 const { isACoach, userSession } = useAuthStore ( ( state : AuthStore ) => state ) ;
66- const { error : deleteError , deleteNested : deleteUser } = useUserMutation ( currentOrganizationId ) ;
67- const { error : createError , createNested : createRelationship } = useCoachingRelationshipMutation ( currentOrganizationId ) ;
66+ const { error : deleteError , deleteNested : deleteUser } = useUserMutation (
67+ currentOrganizationId
68+ ) ;
69+ const { error : createError , createNested : createRelationship } =
70+ useCoachingRelationshipMutation ( currentOrganizationId ) ;
6871
6972 console . log ( "is a coach" , isACoach ) ;
7073
7174 // Check if current user is a coach in any of this user's relationships
7275 // and make sure we can't delete ourselves. Admins can delete any user.
73- const canDeleteUser = ( userRelationships ?. some (
74- ( rel ) => rel . coach_id === userSession . id && userId !== userSession . id
75- ) || ( userSession . role === Role . Admin ) ) && userSession . id !== userId ;
76+ const canDeleteUser =
77+ ( userRelationships ?. some (
78+ ( rel ) => rel . coach_id === userSession . id && userId !== userSession . id
79+ ) ||
80+ userSession . role === Role . Admin ) &&
81+ userSession . id !== userId ;
7682
7783 const handleDelete = async ( ) => {
7884 if ( ! confirm ( "Are you sure you want to delete this member?" ) ) {
@@ -129,8 +135,10 @@ export function MemberCard({
129135 toast . error ( `Error assigning ${ assignMode } ` ) ;
130136 return ;
131137 }
132-
133- toast . success ( `Successfully assigned ${ assignedMember . first_name } ${ assignedMember . last_name } as ${ assignMode } for ${ selectedMember . first_name } ${ selectedMember . last_name } ` ) ;
138+
139+ toast . success (
140+ `Successfully assigned ${ assignedMember . first_name } ${ assignedMember . last_name } as ${ assignMode } for ${ selectedMember . first_name } ${ selectedMember . last_name } `
141+ ) ;
134142 onRefresh ( ) ;
135143 setAssignDialogOpen ( false ) ;
136144 setSelectedMember ( null ) ;
@@ -146,49 +154,61 @@ export function MemberCard({
146154 { email && < p className = "text-sm text-muted-foreground" > { email } </ p > }
147155 </ div >
148156 { ( isACoach || userSession . role === Role . Admin ) && (
149- < DropdownMenu >
150- < DropdownMenuTrigger asChild >
151- < Button variant = "ghost" size = "icon" className = "text-muted-foreground" >
152- < MoreHorizontal className = "h-4 w-4" />
153- </ Button >
154- </ DropdownMenuTrigger >
155- < DropdownMenuContent align = "end" >
156- { userSession . role === Role . Admin && (
157- < >
158- < DropdownMenuItem
159- onClick = { ( ) => {
160- setAssignMode ( "coach" ) ;
161- setAssignDialogOpen ( true ) ;
162- setSelectedMember ( { id : userId , first_name : firstName , last_name : lastName } ) ;
163- } }
164- >
165- Assign Coach
166- </ DropdownMenuItem >
167- < DropdownMenuItem
168- onClick = { ( ) => {
169- setAssignMode ( "coachee" ) ;
170- setAssignDialogOpen ( true ) ;
171- setSelectedMember ( { id : userId , first_name : firstName , last_name : lastName } ) ;
172- } }
173- >
174- Assign Coachee
175- </ DropdownMenuItem >
176- </ >
177- ) }
178- { canDeleteUser && (
179- < >
180- < DropdownMenuSeparator />
181- < DropdownMenuItem
182- onClick = { handleDelete }
183- className = "text-destructive focus:text-destructive"
184- >
185- < Trash2 className = "mr-2 h-4 w-4" /> Delete
186- </ DropdownMenuItem >
187- </ >
188- ) }
189- </ DropdownMenuContent >
190- </ DropdownMenu >
191- ) }
157+ < DropdownMenu >
158+ < DropdownMenuTrigger asChild >
159+ < Button
160+ variant = "ghost"
161+ size = "icon"
162+ className = "text-muted-foreground"
163+ >
164+ < MoreHorizontal className = "h-4 w-4" />
165+ </ Button >
166+ </ DropdownMenuTrigger >
167+ < DropdownMenuContent align = "end" >
168+ { userSession . role === Role . Admin && (
169+ < >
170+ < DropdownMenuItem
171+ onClick = { ( ) => {
172+ setAssignMode ( "coach" ) ;
173+ setAssignDialogOpen ( true ) ;
174+ setSelectedMember ( {
175+ id : userId ,
176+ first_name : firstName ,
177+ last_name : lastName ,
178+ } ) ;
179+ } }
180+ >
181+ Assign Coach
182+ </ DropdownMenuItem >
183+ < DropdownMenuItem
184+ onClick = { ( ) => {
185+ setAssignMode ( "coachee" ) ;
186+ setAssignDialogOpen ( true ) ;
187+ setSelectedMember ( {
188+ id : userId ,
189+ first_name : firstName ,
190+ last_name : lastName ,
191+ } ) ;
192+ } }
193+ >
194+ Assign Coachee
195+ </ DropdownMenuItem >
196+ </ >
197+ ) }
198+ { canDeleteUser && (
199+ < >
200+ < DropdownMenuSeparator />
201+ < DropdownMenuItem
202+ onClick = { handleDelete }
203+ className = "text-destructive focus:text-destructive"
204+ >
205+ < Trash2 className = "mr-2 h-4 w-4" /> Delete
206+ </ DropdownMenuItem >
207+ </ >
208+ ) }
209+ </ DropdownMenuContent >
210+ </ DropdownMenu >
211+ ) }
192212
193213 { /* Assign Coach/Coachee Modal */ }
194214 < Dialog open = { assignDialogOpen } onOpenChange = { setAssignDialogOpen } >
@@ -198,7 +218,8 @@ export function MemberCard({
198218 { assignMode === "coach" ? "Assign Coach" : "Assign Coachee" }
199219 </ DialogTitle >
200220 < DialogDescription >
201- Select a member to be their { assignMode === "coach" ? "coach" : "coachee" }
221+ Select a member to be their{ " " }
222+ { assignMode === "coach" ? "coach" : "coachee" }
202223 </ DialogDescription >
203224 </ DialogHeader >
204225 < Select
@@ -212,12 +233,17 @@ export function MemberCard({
212233 { users
213234 . filter ( ( m ) => m . id !== userId )
214235 . map ( ( m ) => (
215- < SelectItem key = { m . id } value = { m . id . toString ( ) } > { `${ m . first_name } ${ m . last_name } ` } </ SelectItem >
236+ < SelectItem
237+ key = { m . id }
238+ value = { m . id . toString ( ) }
239+ > { `${ m . first_name } ${ m . last_name } ` } </ SelectItem >
216240 ) ) }
217241 </ SelectContent >
218242 </ Select >
219243 < DialogFooter >
220- < Button onClick = { handleCreateCoachingRelationship } > { assignMode === "coach" ? "Assign as Coach" : "Assign as Coachee" } </ Button >
244+ < Button onClick = { handleCreateCoachingRelationship } >
245+ { assignMode === "coach" ? "Assign as Coach" : "Assign as Coachee" }
246+ </ Button >
221247 </ DialogFooter >
222248 </ DialogContent >
223249 </ Dialog >
0 commit comments