feat(batch-diff): side-by-side claim diff between two batches
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
import type {
|
||||
Ack,
|
||||
BatchDiff,
|
||||
ClaimDetail,
|
||||
ClaimOutput,
|
||||
ClaimPayment,
|
||||
@@ -508,6 +509,30 @@ async function getRemittance<T = unknown>(id: string): Promise<T> {
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the side-by-side diff between two batches.
|
||||
*
|
||||
* Drives ``GET /api/batch-diff?a=<batch_id>&b=<batch_id>``. Both ids
|
||||
* are required; the endpoint returns 400 when either is missing and
|
||||
* 404 when the id is unknown — both surface here as ``ApiError`` so
|
||||
* the page can branch on ``.status`` like every other diff / fetch
|
||||
* surface in the app.
|
||||
*/
|
||||
async function getBatchDiff(a: string, b: string): Promise<BatchDiff> {
|
||||
if (!isConfigured) throw notConfiguredError();
|
||||
const res = await fetch(
|
||||
joinUrl(
|
||||
`/api/batch-diff?${qs({ a, b })}`,
|
||||
),
|
||||
{ headers: { Accept: "application/json" } },
|
||||
);
|
||||
if (!res.ok) {
|
||||
const detail = await readErrorBody(res);
|
||||
throw new ApiError(res.status, detail || res.statusText);
|
||||
}
|
||||
return (await res.json()) as BatchDiff;
|
||||
}
|
||||
|
||||
async function listProviders<T = unknown>(
|
||||
params: ListProvidersParams = {}
|
||||
): Promise<PaginatedResponse<T>> {
|
||||
@@ -672,6 +697,7 @@ export const api = {
|
||||
parse999,
|
||||
listBatches,
|
||||
getBatch,
|
||||
getBatchDiff,
|
||||
listClaims,
|
||||
getClaimDetail,
|
||||
listRemittances,
|
||||
|
||||
Reference in New Issue
Block a user