mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 19:30:57 +00:00
- Updated ContractDocumentViewModelBuilder to include cargoTypeName, containerType, and cargoSummary in the schedule. - Modified contract dynamic template tests to validate the new cargo fields. - Enhanced contract renderer service tests to reflect changes in cargo data structure. - Updated contract view model interface to include new cargo-related fields. - Improved dynamic template rendering to display cargo type and container type. - Refactored exchange settings controller and service to streamline error handling and feed status management. - Introduced article HTML conversion functions to support Quill editor integration for structured article editing. - Added tests for article HTML conversion to ensure correct round-trip processing of clauses and bullets.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { api as client } from "../auth/http";
|
|
import { unwrap } from "@/utils/endpoint";
|
|
import { URL_CONSTANTS } from "@/constants/URLS";
|
|
import type { ApiResponse } from "@/types/apiResponse";
|
|
|
|
const BASE = URL_CONSTANTS.EXCHANGE_SETTINGS.BASE;
|
|
|
|
/**
|
|
* Where the rate the API last served came from. `live` means CBE answered;
|
|
* `stored` means it is failing and the fallback is in use.
|
|
*/
|
|
export type ExchangeRateSource = "live" | "stored";
|
|
|
|
/** Health of the CBE exchange-rate feed. */
|
|
export interface ExchangeFeedStatus {
|
|
rate: number | null;
|
|
source: ExchangeRateSource | null;
|
|
lastSuccessAt: string | null;
|
|
lastError: string | null;
|
|
}
|
|
|
|
export interface ExchangeSettings {
|
|
fallbackRate: number;
|
|
/** `AUTO` when synced from CBE, `MANUAL` when set here. */
|
|
fallbackSource: "AUTO" | "MANUAL";
|
|
lastSyncedAt: string | null;
|
|
updatedById: string | null;
|
|
feed?: ExchangeFeedStatus;
|
|
}
|
|
|
|
export const exchangeSettingsService = {
|
|
get: async (): Promise<ExchangeSettings> => {
|
|
const response = await client.get<ApiResponse<ExchangeSettings>>(BASE);
|
|
return unwrap(response.data);
|
|
},
|
|
|
|
setFallbackRate: async (fallbackRate: number): Promise<ExchangeSettings> => {
|
|
const response = await client.patch<ApiResponse<ExchangeSettings>>(BASE, {
|
|
fallbackRate,
|
|
});
|
|
return unwrap(response.data);
|
|
},
|
|
};
|