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

View File

@@ -34,7 +34,8 @@ export default function AdminAllAccountsPage() {
const loadAccounts = async () => {
try {
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 || []);
} catch (err: any) {
setError(err.message || 'Failed to load accounts');

View File

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