fix(admin-web): fix nested data access in pendingActionService

API returns nested structure: { success, data: { code, message, data: {...} } }
After apiClient interceptor unwraps response.data, we still need to access
.data.data to get the actual business data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-02 19:18:54 -08:00
parent ed463d67ab
commit 06d3489b49
1 changed files with 20 additions and 10 deletions

View File

@ -17,24 +17,30 @@ import type {
/** /**
* *
* apiClient response.data *
* API apiClient :
* { success: true, data: { code: "OK", message: "success", data: {...} } }
*
* 访 .data.data
*/ */
export const pendingActionService = { export const pendingActionService = {
/** /**
* *
*/ */
async getList(params: QueryPendingActionsParams = {}): Promise<PendingActionListResponse> { async getList(params: QueryPendingActionsParams = {}): Promise<PendingActionListResponse> {
// apiClient 拦截器已返回 response.data这里直接返回 const response = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.LIST, { params });
const data = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.LIST, { params }); // eslint-disable-next-line @typescript-eslint/no-explicit-any
return (data as { data: PendingActionListResponse }).data; const result = (response as any)?.data?.data;
return result ?? { items: [], total: 0, page: 1, limit: 20 };
}, },
/** /**
* *
*/ */
async getDetail(id: string): Promise<PendingAction> { async getDetail(id: string): Promise<PendingAction> {
const data = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.DETAIL(id)); const response = await apiClient.get(API_ENDPOINTS.PENDING_ACTIONS.DETAIL(id));
return (data as { data: PendingAction }).data; // eslint-disable-next-line @typescript-eslint/no-explicit-any
return (response as any)?.data?.data;
}, },
/** /**
@ -42,7 +48,8 @@ export const pendingActionService = {
*/ */
async create(data: CreatePendingActionRequest): Promise<PendingAction> { async create(data: CreatePendingActionRequest): Promise<PendingAction> {
const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.CREATE, data); const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.CREATE, data);
return (response as { data: PendingAction }).data; // eslint-disable-next-line @typescript-eslint/no-explicit-any
return (response as any)?.data?.data;
}, },
/** /**
@ -50,7 +57,8 @@ export const pendingActionService = {
*/ */
async batchCreate(data: BatchCreatePendingActionRequest): Promise<BatchCreateResult> { async batchCreate(data: BatchCreatePendingActionRequest): Promise<BatchCreateResult> {
const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.BATCH_CREATE, data); const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.BATCH_CREATE, data);
return (response as { data: BatchCreateResult }).data; // eslint-disable-next-line @typescript-eslint/no-explicit-any
return (response as any)?.data?.data;
}, },
/** /**
@ -58,7 +66,8 @@ export const pendingActionService = {
*/ */
async update(id: string, data: UpdatePendingActionRequest): Promise<PendingAction> { async update(id: string, data: UpdatePendingActionRequest): Promise<PendingAction> {
const response = await apiClient.put(API_ENDPOINTS.PENDING_ACTIONS.UPDATE(id), data); const response = await apiClient.put(API_ENDPOINTS.PENDING_ACTIONS.UPDATE(id), data);
return (response as { data: PendingAction }).data; // eslint-disable-next-line @typescript-eslint/no-explicit-any
return (response as any)?.data?.data;
}, },
/** /**
@ -66,7 +75,8 @@ export const pendingActionService = {
*/ */
async cancel(id: string): Promise<PendingAction> { async cancel(id: string): Promise<PendingAction> {
const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.CANCEL(id)); const response = await apiClient.post(API_ENDPOINTS.PENDING_ACTIONS.CANCEL(id));
return (response as { data: PendingAction }).data; // eslint-disable-next-line @typescript-eslint/no-explicit-any
return (response as any)?.data?.data;
}, },
/** /**