Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/api/teams/teams.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TeamCreationCodeVerificationResponse,
TeamDto,
TTeamDto,
UpdateTeamParams,
UserRolesDetails,
} from './teams.type'

Expand Down Expand Up @@ -101,4 +102,15 @@ export const TeamsApi = {
return data
},
},

updateTeam: {
key: ({ teamId }: UpdateTeamParams) => ['TeamsApi.updateTeam', teamId],
fn: async ({ teamId, pocId, ...data }: UpdateTeamParams): Promise<TeamDto> => {
const { data: updatedData } = await apiClient.patch<TeamDto>(`/v1/teams/${teamId}`, {
...data,
...(pocId && { poc_id: pocId }),
})
return updatedData
},
},
}
7 changes: 7 additions & 0 deletions src/api/teams/teams.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,10 @@ export type GetUserRolesParams = {
teamId: string
userId: string
}

export type UpdateTeamParams = {
teamId: string
pocId?: string
name?: string
description?: string
}
31 changes: 31 additions & 0 deletions src/components/teams/team-members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ export const TeamMembers = ({ teamId }: TeamMembersProps) => {
},
})

const updatePocMutation = useMutation({
mutationFn: TeamsApi.updateTeam.fn,
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: TeamsApi.getTeamById.key({ teamId, member: true }),
})
queryClient.invalidateQueries({
queryKey: TasksApi.getTasks.key(),
})
toast.success('POC updated successfully')
},
onError: () => {
toast.error('Failed to update POC')
},
})

const handleAppointAsPoc = (memberId: string) => {
updatePocMutation.mutate({
teamId,
pocId: memberId,
})
}

return (
<div>
<div className="flex items-center justify-between pb-4">
Expand Down Expand Up @@ -173,6 +196,14 @@ export const TeamMembers = ({ teamId }: TeamMembersProps) => {
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>Change Role</DropdownMenuItem>
{member.id !== data?.poc_id && (
<DropdownMenuItem
onSelect={() => handleAppointAsPoc(member.id)}
disabled={updatePocMutation.isPending}
>
Appoint as POC
</DropdownMenuItem>
)}
{member.id !== user?.id &&
member.id !== data?.created_by &&
member.id !== data?.poc_id ? (
Expand Down