mirror of
https://github.com/andwati/cymelle.git
synced 2026-10-24 02:42:15 +00:00
21 lines
505 B
TypeScript
21 lines
505 B
TypeScript
import { apiRequest } from "#/api/client";
|
|
import type { FareCalculationResponse } from "#/types/fare";
|
|
|
|
export function calculateFare(
|
|
distanceKm: number,
|
|
surgeMultiplier?: number,
|
|
signal?: AbortSignal,
|
|
) {
|
|
const params = new URLSearchParams();
|
|
params.set("distanceKm", String(distanceKm));
|
|
|
|
if (surgeMultiplier !== undefined) {
|
|
params.set("surgeMultiplier", String(surgeMultiplier));
|
|
}
|
|
|
|
return apiRequest<FareCalculationResponse>(
|
|
`/fare/calculate?${params.toString()}`,
|
|
{ signal },
|
|
);
|
|
}
|