Skip to content

Commit 1d47473

Browse files
authored
Merge pull request #215 from Real-Dev-Squad/develop
Dev to Main Sync
2 parents d64d37b + 3635a1d commit 1d47473

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

src/api/teams/teams.api.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
TeamCreationCodeVerificationResponse,
1010
TeamDto,
1111
TTeamDto,
12+
UpdateTeamParams,
1213
UserRolesDetails,
1314
} from './teams.type'
1415

@@ -101,4 +102,15 @@ export const TeamsApi = {
101102
return data
102103
},
103104
},
105+
106+
updateTeam: {
107+
key: ({ teamId }: UpdateTeamParams) => ['TeamsApi.updateTeam', teamId],
108+
fn: async ({ teamId, pocId, ...data }: UpdateTeamParams): Promise<TeamDto> => {
109+
const { data: updatedData } = await apiClient.patch<TeamDto>(`/v1/teams/${teamId}`, {
110+
...data,
111+
...(pocId && { poc_id: pocId }),
112+
})
113+
return updatedData
114+
},
115+
},
104116
}

src/api/teams/teams.type.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,10 @@ export type GetUserRolesParams = {
157157
teamId: string
158158
userId: string
159159
}
160+
161+
export type UpdateTeamParams = {
162+
teamId: string
163+
pocId?: string
164+
name?: string
165+
description?: string
166+
}

src/components/teams/team-members.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,29 @@ export const TeamMembers = ({ teamId }: TeamMembersProps) => {
106106
},
107107
})
108108

109+
const updatePocMutation = useMutation({
110+
mutationFn: TeamsApi.updateTeam.fn,
111+
onSuccess: () => {
112+
queryClient.invalidateQueries({
113+
queryKey: TeamsApi.getTeamById.key({ teamId, member: true }),
114+
})
115+
queryClient.invalidateQueries({
116+
queryKey: TasksApi.getTasks.key(),
117+
})
118+
toast.success('POC updated successfully')
119+
},
120+
onError: () => {
121+
toast.error('Failed to update POC')
122+
},
123+
})
124+
125+
const handleAppointAsPoc = (memberId: string) => {
126+
updatePocMutation.mutate({
127+
teamId,
128+
pocId: memberId,
129+
})
130+
}
131+
109132
return (
110133
<div>
111134
<div className="flex items-center justify-between pb-4">
@@ -173,6 +196,14 @@ export const TeamMembers = ({ teamId }: TeamMembersProps) => {
173196
</DropdownMenuTrigger>
174197
<DropdownMenuContent>
175198
<DropdownMenuItem>Change Role</DropdownMenuItem>
199+
{member.id !== data?.poc_id && (
200+
<DropdownMenuItem
201+
onSelect={() => handleAppointAsPoc(member.id)}
202+
disabled={updatePocMutation.isPending}
203+
>
204+
Appoint as POC
205+
</DropdownMenuItem>
206+
)}
176207
{member.id !== user?.id &&
177208
member.id !== data?.created_by &&
178209
member.id !== data?.poc_id ? (

0 commit comments

Comments
 (0)