refactor: add error info to send invite results
This commit is contained in:
@@ -288,9 +288,10 @@ import { Email, EmailCodec } from "../../helpers/backend/types/Email"
|
|||||||
import { TeamMemberRole } from "../../helpers/backend/graphql"
|
import { TeamMemberRole } from "../../helpers/backend/graphql"
|
||||||
import {
|
import {
|
||||||
createTeamInvitation,
|
createTeamInvitation,
|
||||||
|
CreateTeamInvitationErrors,
|
||||||
revokeTeamInvitation,
|
revokeTeamInvitation,
|
||||||
} from "../../helpers/backend/mutations/TeamInvitation"
|
} from "../../helpers/backend/mutations/TeamInvitation"
|
||||||
import { useGQLQuery } from "~/helpers/backend/GQLClient"
|
import { GQLError, useGQLQuery } from "~/helpers/backend/GQLClient"
|
||||||
import {
|
import {
|
||||||
GetPendingInvitesDocument,
|
GetPendingInvitesDocument,
|
||||||
GetPendingInvitesQuery,
|
GetPendingInvitesQuery,
|
||||||
@@ -374,11 +375,17 @@ const removeNewInvitee = (id: number) => {
|
|||||||
newInvites.value.splice(id, 1)
|
newInvites.value.splice(id, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SendInvitesErrorType = {
|
||||||
|
email: Email
|
||||||
|
status: "error"
|
||||||
|
error: GQLError<CreateTeamInvitationErrors>
|
||||||
|
} | {
|
||||||
|
email: Email
|
||||||
|
status: "success"
|
||||||
|
}
|
||||||
|
|
||||||
const sendInvitesResult = ref<
|
const sendInvitesResult = ref<
|
||||||
Array<{
|
Array<SendInvitesErrorType>
|
||||||
email: Email
|
|
||||||
status: "error" | "success"
|
|
||||||
}>
|
|
||||||
>([])
|
>([])
|
||||||
|
|
||||||
const sendingInvites = ref<boolean>(false)
|
const sendingInvites = ref<boolean>(false)
|
||||||
@@ -418,9 +425,10 @@ const sendInvites = async () => {
|
|||||||
pipe(
|
pipe(
|
||||||
el,
|
el,
|
||||||
E.foldW(
|
E.foldW(
|
||||||
() => ({
|
(err) => ({
|
||||||
status: "error" as const,
|
status: "error" as const,
|
||||||
email: newInvites.value[i].key as Email,
|
email: newInvites.value[i].key as Email,
|
||||||
|
error: err
|
||||||
}),
|
}),
|
||||||
() => ({
|
() => ({
|
||||||
status: "success" as const,
|
status: "success" as const,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
} from "../graphql"
|
} from "../graphql"
|
||||||
import { Email } from "../types/Email"
|
import { Email } from "../types/Email"
|
||||||
|
|
||||||
type CreateTeamInvitationErrors =
|
export type CreateTeamInvitationErrors =
|
||||||
| "invalid/email"
|
| "invalid/email"
|
||||||
| "team/invalid_id"
|
| "team/invalid_id"
|
||||||
| "team/member_not_found"
|
| "team/member_not_found"
|
||||||
|
|||||||
Reference in New Issue
Block a user