This commit is contained in:
alorig
2025-12-05 14:12:06 +05:00
parent f3d67e9f4a
commit bbc70751db
3 changed files with 11 additions and 7 deletions

View File

@@ -65,9 +65,12 @@ const AdminBilling: React.FC = () => {
try { try {
setLoading(true); setLoading(true);
const [statsData, usersData, configsData] = await Promise.all([ const [statsData, usersData, configsData] = await Promise.all([
// Admin billing stats (credits, activity, revenue)
fetchAPI('/v1/billing/admin/stats/'), fetchAPI('/v1/billing/admin/stats/'),
fetchAPI('/v1/admin/users/?limit=100'), // Admin billing users list (with credits)
fetchAPI('/v1/admin/credit-costs/'), fetchAPI('/v1/admin/billing/users/?limit=100'),
// Admin billing credit costs
fetchAPI('/v1/admin/billing/credit-costs/'),
]); ]);
setStats(statsData); setStats(statsData);
@@ -87,7 +90,7 @@ const AdminBilling: React.FC = () => {
} }
try { try {
await fetchAPI(`/v1/admin/users/${selectedUser.id}/adjust-credits/`, { await fetchAPI(`/v1/admin/billing/users/${selectedUser.id}/adjust-credits/`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
amount: parseInt(creditAmount), amount: parseInt(creditAmount),
@@ -107,7 +110,7 @@ const AdminBilling: React.FC = () => {
const handleUpdateCreditCost = async (configId: number, newCost: number) => { const handleUpdateCreditCost = async (configId: number, newCost: number) => {
try { try {
await fetchAPI(`/v1/admin/credit-costs/${configId}/`, { await fetchAPI(`/v1/admin/billing/credit-costs/${configId}/`, {
method: 'PATCH', method: 'PATCH',
body: JSON.stringify({ cost: newCost }), body: JSON.stringify({ cost: newCost }),
}); });

View File

@@ -34,7 +34,8 @@ export default function AdminAllAccountsPage() {
const loadAccounts = async () => { const loadAccounts = async () => {
try { try {
setLoading(true); setLoading(true);
const data = await fetchAPI('/v1/admin/accounts/'); // Developer/admin accounts are exposed via auth accounts endpoint
const data = await fetchAPI('/v1/auth/accounts/');
setAccounts(data.results || []); setAccounts(data.results || []);
} catch (err: any) { } catch (err: any) {
setError(err.message || 'Failed to load accounts'); setError(err.message || 'Failed to load accounts');

View File

@@ -261,8 +261,8 @@ export async function getCreditUsageLimits(): Promise<{
// ============================================================================ // ============================================================================
export async function getAdminBillingStats(): Promise<AdminBillingStats> { export async function getAdminBillingStats(): Promise<AdminBillingStats> {
// Admin stats live under the admin namespace // Use business billing admin stats endpoint (returns all dashboard metrics)
return fetchAPI('/v1/admin/billing/stats/'); return fetchAPI('/v1/billing/admin/stats/');
} }
export async function getAdminInvoices(params?: { status?: string; account_id?: number; search?: string }): Promise<{ export async function getAdminInvoices(params?: { status?: string; account_id?: number; search?: string }): Promise<{