refactor: extract cache info to separate files and add more mutations
This commit is contained in:
committed by
liyasthomas
parent
3809e9853e
commit
8d5bd051a1
@@ -18,6 +18,21 @@ type ExitTeamErrors =
|
||||
|
||||
type CreateTeamErrors = "team/name_invalid" | "ea/not_invite_or_admin"
|
||||
|
||||
type RenameTeamErrors =
|
||||
| "ea/not_invite_or_admin"
|
||||
| "team/invalid_id"
|
||||
| "team/not_required_role"
|
||||
|
||||
type UpdateTeamMemberRoleErrors =
|
||||
| "ea/not_invite_or_admin"
|
||||
| "team/invalid_id"
|
||||
| "team/not_required_role"
|
||||
|
||||
type RemoveTeamMemberErrors =
|
||||
| "ea/not_invite_or_admin"
|
||||
| "team/invalid_id"
|
||||
| "team/not_required_role"
|
||||
|
||||
export const createTeam = (name: TeamName) =>
|
||||
pipe(
|
||||
runMutation<
|
||||
@@ -85,3 +100,83 @@ export const leaveTeam = (teamID: string) =>
|
||||
additionalTypenames: ["Team"],
|
||||
}
|
||||
)
|
||||
|
||||
export const renameTeam = (teamID: string, newName: TeamName) =>
|
||||
pipe(
|
||||
runMutation<
|
||||
{
|
||||
renameTeam: {
|
||||
id: string
|
||||
name: TeamName
|
||||
}
|
||||
},
|
||||
RenameTeamErrors
|
||||
>(
|
||||
gql`
|
||||
mutation RenameTeam($newName: String!, $teamID: ID!) {
|
||||
renameTeam(newName: $newName, teamID: $teamID) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
{
|
||||
newName,
|
||||
teamID,
|
||||
}
|
||||
),
|
||||
TE.map(({ renameTeam }) => renameTeam)
|
||||
)
|
||||
|
||||
export const updateTeamMemberRole = (
|
||||
userUid: string,
|
||||
teamID: string,
|
||||
newRole: TeamMemberRole
|
||||
) =>
|
||||
pipe(
|
||||
runMutation<
|
||||
{
|
||||
updateTeamMemberRole: {
|
||||
membershipID: string
|
||||
role: TeamMemberRole
|
||||
}
|
||||
},
|
||||
UpdateTeamMemberRoleErrors
|
||||
>(
|
||||
gql`
|
||||
mutation UpdateTeamMemberRole(
|
||||
$newRole: TeamMemberRole!,
|
||||
$userUid: ID!,
|
||||
teamID: ID!
|
||||
) {
|
||||
updateTeamMemberRole(
|
||||
newRole: $newRole
|
||||
userUid: $userUid
|
||||
teamID: $teamID
|
||||
) {
|
||||
membershipID
|
||||
role
|
||||
}
|
||||
}
|
||||
`,
|
||||
{
|
||||
newRole,
|
||||
userUid,
|
||||
teamID,
|
||||
}
|
||||
),
|
||||
TE.map(({ updateTeamMemberRole }) => updateTeamMemberRole)
|
||||
)
|
||||
|
||||
export const removeTeamMember = (userUid: string, teamID: string) =>
|
||||
runMutation<void, RemoveTeamMemberErrors>(
|
||||
gql`
|
||||
mutation RemoveTeamMember($userUid: ID!, $teamID: ID!) {
|
||||
removeTeamMember(userUid: $userUid, teamID: $teamID)
|
||||
}
|
||||
`,
|
||||
{
|
||||
userUid,
|
||||
teamID,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user