mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
fix: admin per-subscription panel data + hide purchased tariffs in create
- getPanelInfo/getNodeUsage/getUserDevices: pass subscriptionId - deleteUserDevice/resetUserDevices: pass subscriptionId - Reload panel data when switching between subscriptions - Create subscription: filter out already purchased tariffs
This commit is contained in:
@@ -603,26 +603,33 @@ export const adminUsersApi = {
|
||||
},
|
||||
|
||||
// Get panel info
|
||||
getPanelInfo: async (userId: number): Promise<UserPanelInfo> => {
|
||||
const response = await apiClient.get(`/cabinet/admin/users/${userId}/panel-info`);
|
||||
getPanelInfo: async (userId: number, subscriptionId?: number): Promise<UserPanelInfo> => {
|
||||
const response = await apiClient.get(`/cabinet/admin/users/${userId}/panel-info`, {
|
||||
params: subscriptionId != null ? { subscription_id: subscriptionId } : undefined,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Get node usage (always 30 days with daily breakdown)
|
||||
getNodeUsage: async (userId: number): Promise<UserNodeUsageResponse> => {
|
||||
const response = await apiClient.get(`/cabinet/admin/users/${userId}/node-usage`);
|
||||
getNodeUsage: async (userId: number, subscriptionId?: number): Promise<UserNodeUsageResponse> => {
|
||||
const response = await apiClient.get(`/cabinet/admin/users/${userId}/node-usage`, {
|
||||
params: subscriptionId != null ? { subscription_id: subscriptionId } : undefined,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Get user devices
|
||||
getUserDevices: async (
|
||||
userId: number,
|
||||
subscriptionId?: number,
|
||||
): Promise<{
|
||||
devices: { hwid: string; platform: string; device_model: string; created_at: string | null }[];
|
||||
total: number;
|
||||
device_limit: number;
|
||||
}> => {
|
||||
const response = await apiClient.get(`/cabinet/admin/users/${userId}/devices`);
|
||||
const response = await apiClient.get(`/cabinet/admin/users/${userId}/devices`, {
|
||||
params: subscriptionId != null ? { subscription_id: subscriptionId } : undefined,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -630,16 +637,22 @@ export const adminUsersApi = {
|
||||
deleteUserDevice: async (
|
||||
userId: number,
|
||||
hwid: string,
|
||||
subscriptionId?: number,
|
||||
): Promise<{ success: boolean; message: string; deleted_hwid: string | null }> => {
|
||||
const response = await apiClient.delete(`/cabinet/admin/users/${userId}/devices/${hwid}`);
|
||||
const response = await apiClient.delete(`/cabinet/admin/users/${userId}/devices/${hwid}`, {
|
||||
params: subscriptionId != null ? { subscription_id: subscriptionId } : undefined,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Reset all devices
|
||||
resetUserDevices: async (
|
||||
userId: number,
|
||||
subscriptionId?: number,
|
||||
): Promise<{ success: boolean; message: string; deleted_count: number }> => {
|
||||
const response = await apiClient.delete(`/cabinet/admin/users/${userId}/devices`);
|
||||
const response = await apiClient.delete(`/cabinet/admin/users/${userId}/devices`, {
|
||||
params: subscriptionId != null ? { subscription_id: subscriptionId } : undefined,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user