43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { request, api } from "./client";
|
|
|
|
/** Document from GET /sessions/:sessionId/questions (staff). */
|
|
export type ApiModeratorQuestionDoc = {
|
|
_id: string;
|
|
question: string;
|
|
isAnonymous?: boolean;
|
|
status?: string;
|
|
shortlisted?: boolean;
|
|
audienceListed?: boolean;
|
|
upvotes?: number;
|
|
downvotes?: number;
|
|
createdAt?: string;
|
|
participant?: {
|
|
firstName?: string;
|
|
lastName?: string;
|
|
email?: string;
|
|
displayName?: string;
|
|
} | null;
|
|
};
|
|
|
|
export type QuestionPatchBody = {
|
|
question?: string;
|
|
isAnonymous?: boolean;
|
|
shortlisted?: boolean;
|
|
audienceListed?: boolean;
|
|
status?: "pending" | "answered" | "archived";
|
|
};
|
|
|
|
export const questionsApi = {
|
|
listBySession(sessionId: string) {
|
|
return api.get<{ questions: ApiModeratorQuestionDoc[] }>(`/sessions/${sessionId}/questions`);
|
|
},
|
|
/** Skips global mutation overlay for quick moderation toggles. */
|
|
patch(id: string, body: QuestionPatchBody) {
|
|
return request<unknown>(`/questions/${id}`, {
|
|
method: "PATCH",
|
|
body: JSON.stringify(body),
|
|
skipGlobalLoading: true,
|
|
});
|
|
},
|
|
};
|