Add data model types, datetime utils, and dictionary hook

Port Angular flight types (ISimpleFlight, IFlightLeg, ITimesSet, etc.)
to minimal React-friendly interfaces. Add formatDuration/formatTime/
formatDate/isDayChange as pure functions. Stub useCityName hook as
passthrough pending customer dictionary API endpoint.
This commit is contained in:
2026-04-15 07:55:00 +03:00
parent fc03c08278
commit b3ab73253d
6 changed files with 660 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import { describe, it, expect } from "vitest";
import { useCityName } from "./useDictionaries.js";
describe("useCityName", () => {
it("returns the code itself (Phase 2 passthrough)", () => {
expect(useCityName("SVO")).toBe("SVO");
});
it("returns the code for any input", () => {
expect(useCityName("LED")).toBe("LED");
expect(useCityName("MOW")).toBe("MOW");
expect(useCityName("JFK")).toBe("JFK");
});
it("handles empty string", () => {
expect(useCityName("")).toBe("");
});
});
+22
View File
@@ -0,0 +1,22 @@
/**
* Airport/city dictionary hooks.
*
* Phase 2 stub: returns the IATA code itself as the city name.
* The real implementation will call the customer's dictionary API
* (similar to Angular DictionariesService.getCityOrAirport).
*
* TODO: Replace passthrough with actual API call once the dictionary
* endpoint is provided by the customer. The Angular app loads dictionaries
* via networkService.getDictionary('cities') / getDictionary('airports')
* and builds an in-memory Map<code, CityModel>.
*/
/**
* Returns the city name for a given IATA airport/city code.
*
* Phase 2: passthrough — returns the code itself.
*/
export function useCityName(code: string): string {
// TODO: Look up from dictionary cache/API when available
return code;
}