feat(api, i18n): add admin report job functionalities and enhance locale support

- Introduced new API functions for managing admin report jobs, including download and post operations.
- Updated English, Nepali, and Chinese locale files to include new messages related to report job actions and rollback confirmations.
- Enhanced user experience by providing clearer instructions and feedback in the admin interface.
- Refactored related components to integrate new functionalities and improve overall usability.
This commit is contained in:
2026-05-26 11:48:51 +08:00
parent 7fb5ec6dff
commit a76b681828
21 changed files with 1139 additions and 118 deletions

View File

@@ -0,0 +1,65 @@
import { adminHttp, adminRequest } from "@/lib/admin-http";
import { withAdminAuthHeader } from "@/lib/admin-auth";
import { withAdminLocaleHeaders } from "@/lib/admin-locale";
import { API_V1_PREFIX } from "./paths";
import type {
AdminReportJobCreatePayload,
AdminReportJobCreateResult,
AdminReportJobListData,
AdminReportJobRow,
} from "@/types/api/admin-report-jobs";
const A = `${API_V1_PREFIX}/admin/report-jobs`;
export async function getAdminReportJobs(params?: {
page?: number;
per_page?: number;
}): Promise<AdminReportJobListData> {
return adminRequest.get<AdminReportJobListData>(A, { params });
}
export async function postAdminReportJob(
payload: AdminReportJobCreatePayload,
): Promise<AdminReportJobCreateResult> {
return adminRequest.post<AdminReportJobCreateResult>(A, payload);
}
export async function getAdminReportJob(id: number): Promise<AdminReportJobRow> {
return adminRequest.get<AdminReportJobRow>(`${A}/${id}`);
}
function filenameFromContentDisposition(header: string | undefined): string | null {
if (!header) {
return null;
}
const utf8 = /filename\*=UTF-8''([^;]+)/i.exec(header);
if (utf8?.[1]) {
try {
return decodeURIComponent(utf8[1].trim());
} catch {
return utf8[1].trim();
}
}
const plain = /filename="?([^";]+)"?/i.exec(header);
return plain?.[1]?.trim() ?? null;
}
export async function downloadAdminReportJob(
id: number,
): Promise<{ blob: Blob; filename: string | null }> {
const res = await adminHttp.request<Blob>(
withAdminAuthHeader(
withAdminLocaleHeaders({
url: `${A}/${id}/download`,
method: "GET",
responseType: "blob",
}),
),
);
const filename = filenameFromContentDisposition(
typeof res.headers["content-disposition"] === "string" ? res.headers["content-disposition"] : undefined,
);
return { blob: res.data, filename };
}

View File

@@ -20,6 +20,12 @@ export {
getAdminReportPlayerWinLoss,
getAdminReportRebateCommission,
} from "@/api/admin-reports";
export {
downloadAdminReportJob,
getAdminReportJob,
getAdminReportJobs,
postAdminReportJob,
} from "@/api/admin-report-jobs";
export {
getAdminDraw,
getAdminDrawFinanceSummary,