Initial attendee management
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import type {
|
||||
AttendeeDto,
|
||||
AttendeeList,
|
||||
BulkCreateAttendees,
|
||||
BulkCreateAttendeesResult,
|
||||
ConnectPayment,
|
||||
ConnectPaymentResult,
|
||||
CreateAttendee,
|
||||
CreateFirstGroup,
|
||||
CreateFirstGroupResult,
|
||||
GroupDto,
|
||||
GroupInviteInfoDto,
|
||||
GroupList,
|
||||
InviteTokenResult,
|
||||
JoinGroupViaInvite,
|
||||
OnboardingStatusDto,
|
||||
ProblemDetails,
|
||||
} from '@gruperly/shared'
|
||||
@@ -15,7 +24,7 @@ export class ApiError extends Error {
|
||||
readonly status: number,
|
||||
readonly problem: ProblemDetails | null,
|
||||
) {
|
||||
super(problem?.title ?? `Error ${status}`)
|
||||
super(problem?.detail ?? problem?.title ?? `Error ${status}`)
|
||||
this.name = 'ApiError'
|
||||
}
|
||||
}
|
||||
@@ -62,4 +71,38 @@ export const createFirstGroup = (payload: CreateFirstGroup) =>
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const getGroups = () => apiFetch<GroupList>('/api/v1/groups')
|
||||
export const getGroups = () => apiFetch<GroupList>('/api/v1/groups')
|
||||
|
||||
export const getGroup = (groupId: string) =>
|
||||
apiFetch<GroupDto>(`/api/v1/groups/${groupId}`)
|
||||
|
||||
export const getInviteToken = (groupId: string, regenerate = false) =>
|
||||
regenerate
|
||||
? apiFetch<InviteTokenResult>(`/api/v1/groups/${groupId}/invite-token?regenerate=true`, {
|
||||
method: 'POST',
|
||||
})
|
||||
: apiFetch<InviteTokenResult>(`/api/v1/groups/${groupId}/invite-token`)
|
||||
|
||||
export const getInviteInfo = (token: string) =>
|
||||
apiFetch<GroupInviteInfoDto>(`/api/v1/invitations/${token}`)
|
||||
|
||||
export const joinViaInvite = (token: string, payload: JoinGroupViaInvite) =>
|
||||
apiFetch<{ attendee: AttendeeDto; message: string }>(`/api/v1/invitations/${token}/join`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const createAttendee = (groupId: string, payload: CreateAttendee) =>
|
||||
apiFetch<AttendeeDto>(`/api/v1/groups/${groupId}/attendees`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const bulkCreateAttendees = (groupId: string, payload: BulkCreateAttendees) =>
|
||||
apiFetch<BulkCreateAttendeesResult>(`/api/v1/groups/${groupId}/attendees/bulk`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const getGroupAttendees = (groupId: string, page = 1, pageSize = 20) =>
|
||||
apiFetch<AttendeeList>(`/api/v1/groups/${groupId}/attendees?page=${page}&pageSize=${pageSize}`)
|
||||
Reference in New Issue
Block a user