@@ -63,16 +63,22 @@ export function MemberCard({
63
63
( state : OrganizationStateStore ) => state . currentOrganizationId
64
64
) ;
65
65
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 ) ;
68
71
69
72
console . log ( "is a coach" , isACoach ) ;
70
73
71
74
// Check if current user is a coach in any of this user's relationships
72
75
// 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 ;
76
82
77
83
const handleDelete = async ( ) => {
78
84
if ( ! confirm ( "Are you sure you want to delete this member?" ) ) {
@@ -129,8 +135,10 @@ export function MemberCard({
129
135
toast . error ( `Error assigning ${ assignMode } ` ) ;
130
136
return ;
131
137
}
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
+ ) ;
134
142
onRefresh ( ) ;
135
143
setAssignDialogOpen ( false ) ;
136
144
setSelectedMember ( null ) ;
@@ -146,49 +154,61 @@ export function MemberCard({
146
154
{ email && < p className = "text-sm text-muted-foreground" > { email } </ p > }
147
155
</ div >
148
156
{ ( 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
+ ) }
192
212
193
213
{ /* Assign Coach/Coachee Modal */ }
194
214
< Dialog open = { assignDialogOpen } onOpenChange = { setAssignDialogOpen } >
@@ -198,7 +218,8 @@ export function MemberCard({
198
218
{ assignMode === "coach" ? "Assign Coach" : "Assign Coachee" }
199
219
</ DialogTitle >
200
220
< DialogDescription >
201
- Select a member to be their { assignMode === "coach" ? "coach" : "coachee" }
221
+ Select a member to be their{ " " }
222
+ { assignMode === "coach" ? "coach" : "coachee" }
202
223
</ DialogDescription >
203
224
</ DialogHeader >
204
225
< Select
@@ -212,12 +233,17 @@ export function MemberCard({
212
233
{ users
213
234
. filter ( ( m ) => m . id !== userId )
214
235
. 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 >
216
240
) ) }
217
241
</ SelectContent >
218
242
</ Select >
219
243
< 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 >
221
247
</ DialogFooter >
222
248
</ DialogContent >
223
249
</ Dialog >
0 commit comments