33 lines
986 B
TypeScript
33 lines
986 B
TypeScript
import { fetchJson } from "@/lib/client/fetch-json";
|
|
|
|
export type InviteLinkSummary = {
|
|
id: number;
|
|
groupId: number;
|
|
groupName: string;
|
|
policy: "NOT_ACCEPTING" | "AUTO_ACCEPT" | "APPROVAL_REQUIRED";
|
|
groupJoinPolicy: "NOT_ACCEPTING" | "AUTO_ACCEPT" | "APPROVAL_REQUIRED";
|
|
singleUse: boolean;
|
|
expiresAt: string;
|
|
usedAt: string | null;
|
|
revokedAt: string | null;
|
|
createdAt: string;
|
|
viewerStatus?: "ALREADY_MEMBER" | "PENDING";
|
|
};
|
|
|
|
export type InviteAcceptResult = {
|
|
status: "JOINED" | "PENDING" | "ALREADY_MEMBER";
|
|
group: { id: number; name: string };
|
|
};
|
|
|
|
export async function inviteLinkGet(token: string) {
|
|
return fetchJson<{ link: InviteLinkSummary }>(`/api/invite-links/${encodeURIComponent(token)}`, {
|
|
method: "GET"
|
|
});
|
|
}
|
|
|
|
export async function inviteLinkAccept(token: string) {
|
|
return fetchJson<{ result: InviteAcceptResult }>(`/api/invite-links/${encodeURIComponent(token)}`, {
|
|
method: "POST"
|
|
});
|
|
}
|