feat: add admin tables for comments and recordings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -912,6 +912,8 @@ export default {
|
||||
users: "Users",
|
||||
videos: "Videos",
|
||||
articles: "Articles",
|
||||
comments: "Comments",
|
||||
recordings: "Recordings",
|
||||
},
|
||||
common: {
|
||||
save_changes: "Save changes",
|
||||
@@ -1024,6 +1026,34 @@ export default {
|
||||
delete_success: "Article deleted",
|
||||
delete_error: "Failed to delete article",
|
||||
},
|
||||
comments: {
|
||||
title: "Comments",
|
||||
search_placeholder: "Search comments…",
|
||||
col_user: "User",
|
||||
col_comment: "Comment",
|
||||
col_on: "On",
|
||||
col_date: "Date",
|
||||
no_results: "No comments found",
|
||||
delete_title: "Delete comment",
|
||||
delete_success: "Comment deleted",
|
||||
delete_error: "Failed to delete comment",
|
||||
},
|
||||
recordings: {
|
||||
title: "Recordings",
|
||||
search_placeholder: "Search recordings…",
|
||||
col_title: "Title",
|
||||
col_status: "Status",
|
||||
col_duration: "Duration",
|
||||
col_date: "Date",
|
||||
no_results: "No recordings found",
|
||||
published: "Published",
|
||||
draft: "Draft",
|
||||
public: "Public",
|
||||
delete_title: "Delete recording",
|
||||
delete_description: 'Permanently delete "{title}"? This cannot be undone.',
|
||||
delete_success: "Recording deleted",
|
||||
delete_error: "Failed to delete recording",
|
||||
},
|
||||
article_form: {
|
||||
new_title: "New article",
|
||||
edit_title: "Edit article",
|
||||
|
||||
@@ -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