feat: add admin tables for comments and recordings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { apiUrl, getGraphQLClient } from "$lib/api";
|
||||
import type {
|
||||
Analytics,
|
||||
Article,
|
||||
Comment,
|
||||
CurrentUser,
|
||||
Model,
|
||||
Recording,
|
||||
@@ -1776,3 +1777,88 @@ export async function getAnalytics(fetchFn?: typeof globalThis.fetch) {
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Admin: Comments ──────────────────────────────────────────────────────────
|
||||
|
||||
const ADMIN_LIST_COMMENTS_QUERY = gql`
|
||||
query AdminListComments($search: String, $limit: Int, $offset: Int) {
|
||||
adminListComments(search: $search, limit: $limit, offset: $offset) {
|
||||
items {
|
||||
id
|
||||
collection
|
||||
item_id
|
||||
comment
|
||||
user_id
|
||||
date_created
|
||||
user {
|
||||
id
|
||||
artist_name
|
||||
avatar
|
||||
}
|
||||
}
|
||||
total
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export async function adminListComments(
|
||||
opts: { search?: string; limit?: number; offset?: number } = {},
|
||||
fetchFn?: typeof globalThis.fetch,
|
||||
token?: string,
|
||||
): Promise<{ items: Comment[]; total: number }> {
|
||||
return loggedApiCall("adminListComments", async () => {
|
||||
const client = token ? getAuthClient(token) : getGraphQLClient(fetchFn);
|
||||
const data = await client.request<{ adminListComments: { items: Comment[]; total: number } }>(
|
||||
ADMIN_LIST_COMMENTS_QUERY,
|
||||
opts,
|
||||
);
|
||||
return data.adminListComments;
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Admin: Recordings ────────────────────────────────────────────────────────
|
||||
|
||||
const ADMIN_LIST_RECORDINGS_QUERY = gql`
|
||||
query AdminListRecordings($search: String, $status: String, $limit: Int, $offset: Int) {
|
||||
adminListRecordings(search: $search, status: $status, limit: $limit, offset: $offset) {
|
||||
items {
|
||||
id
|
||||
title
|
||||
slug
|
||||
status
|
||||
duration
|
||||
public
|
||||
featured
|
||||
user_id
|
||||
date_created
|
||||
}
|
||||
total
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export async function adminListRecordings(
|
||||
opts: { search?: string; status?: string; limit?: number; offset?: number } = {},
|
||||
fetchFn?: typeof globalThis.fetch,
|
||||
token?: string,
|
||||
): Promise<{ items: Recording[]; total: number }> {
|
||||
return loggedApiCall("adminListRecordings", async () => {
|
||||
const client = token ? getAuthClient(token) : getGraphQLClient(fetchFn);
|
||||
const data = await client.request<{
|
||||
adminListRecordings: { items: Recording[]; total: number };
|
||||
}>(ADMIN_LIST_RECORDINGS_QUERY, opts);
|
||||
return data.adminListRecordings;
|
||||
});
|
||||
}
|
||||
|
||||
const ADMIN_DELETE_RECORDING_MUTATION = gql`
|
||||
mutation AdminDeleteRecording($id: String!) {
|
||||
adminDeleteRecording(id: $id)
|
||||
}
|
||||
`;
|
||||
|
||||
export async function adminDeleteRecording(id: string): Promise<void> {
|
||||
return loggedApiCall("adminDeleteRecording", async () => {
|
||||
await getGraphQLClient().request(ADMIN_DELETE_RECORDING_MUTATION, { id });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user