feat: add admin tables for comments and recordings
All checks were successful
Build and Push Backend Image / build (push) Successful in 44s
Build and Push Frontend Image / build (push) Successful in 4m20s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 11:29:48 +01:00
parent dfe49b5882
commit 754a236e51
12 changed files with 720 additions and 12 deletions

View File

@@ -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 });
});
}