Files
co-lite/solvway-admin-portal/app/lib/services/adminLeads.ts
T
ngqileandClaude Opus 5.5 5f4f2705e8 feat(admin-portal): xlsx export buttons on both lead listings
A binary mobile-api call with the same error shape, export proxy routes
that pass Content-Type and Content-Disposition through, and an Export
button under BO_LEADS_EXPORT that downloads with the current search or
filters and shows EXPORT_TOO_LARGE on the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-27 17:09:23 +08:00

21 lines
1.1 KiB
TypeScript

import { apiDownload, apiGet, apiPut } from "@/app/lib/clientApi";
import type { LeadDetail, LeadRow, LeadUpdatePayload } from "@/app/lib/types";
const BASE = "/api/leads";
export async function listLeads(params: { q?: string; /** 1-based. */ page: number; pageSize: number }): Promise<{ items: LeadRow[]; total: number }> {
const qs = new URLSearchParams();
if (params.q) qs.set("q", params.q);
qs.set("page", String(Math.max(0, params.page - 1)));
qs.set("size", String(params.pageSize));
const raw = await apiGet<{ content?: LeadRow[]; totalElements?: number } | null>(`${BASE}?${qs}`);
const items = Array.isArray(raw?.content) ? raw.content : [];
return { items, total: typeof raw?.totalElements === "number" ? raw.totalElements : items.length };
}
export const getLead = (uuid: string) => apiGet<LeadDetail>(`${BASE}/${uuid}`);
export const updateLead = (uuid: string, payload: LeadUpdatePayload) => apiPut<LeadDetail>(`${BASE}/${uuid}`, payload);
export const exportLeads = (params: { q?: string }) =>
apiDownload(`${BASE}/export${params.q ? `?${new URLSearchParams({ q: params.q })}` : ""}`, "leads.xlsx");