plan/react-rewrite #1

Merged
gnezim merged 138 commits from plan/react-rewrite into main 2026-04-15 12:21:16 +03:00
5 changed files with 18 additions and 16 deletions
Showing only changes of commit 5839692e52 - Show all commits
-1
View File
@@ -3,7 +3,6 @@ import { ApiClient } from "@/shared/api/client";
import { searchDestinations, getFlightsMapCalendar } from "./api";
import type {
FlightsMapSearchParams,
FlightsMapCalendarParams,
IDestinationsResponse,
IFlightsMapDaysResponse,
} from "./types";
@@ -98,11 +98,11 @@ export const FlightsMapStartPage: FC = () => {
const handleMarkerClick = useCallback(
(markerId: string) => {
if (!filterState.departure) {
setFilterState((prev) => ({ ...prev, departure: markerId }));
setFilterState((prev): IFlightsMapFilterState => ({ ...prev, departure: markerId }));
} else if (!filterState.arrival && markerId !== filterState.departure) {
setFilterState((prev) => ({ ...prev, arrival: markerId }));
setFilterState((prev): IFlightsMapFilterState => ({ ...prev, arrival: markerId }));
} else {
setFilterState((prev) => ({
setFilterState((prev): IFlightsMapFilterState => ({
...prev,
departure: markerId,
arrival: undefined,
@@ -201,8 +201,7 @@ export const MapCanvas: FC<MapCanvasProps> = ({
polylinesLayerRef.current = null;
popupsLayerRef.current = null;
};
// Only run once on mount
// eslint-disable-next-line react-hooks/exhaustive-deps
// Only run once on mount -- stable props used from refs
}, []);
// --- Sync markers ---
@@ -251,8 +250,11 @@ export const MapCanvas: FC<MapCanvasProps> = ({
// Build great-circle arcs between consecutive points
const arcPoints: L.LatLng[] = [];
for (let i = 0; i < pl.points.length - 1; i++) {
const from = L.latLng(pl.points[i]!.lat, pl.points[i]!.lng);
const to = L.latLng(pl.points[i + 1]!.lat, pl.points[i + 1]!.lng);
const ptFrom = pl.points[i];
const ptTo = pl.points[i + 1];
if (!ptFrom || !ptTo) continue;
const from = L.latLng(ptFrom.lat, ptFrom.lng);
const to = L.latLng(ptTo.lat, ptTo.lng);
const arc = buildGreatCircleArc(from, to);
arcPoints.push(...(i === 0 ? arc : arc.slice(1)));
}
+1
View File
@@ -47,6 +47,7 @@ describe("buildFlightsMapSeo", () => {
const result = buildFlightsMapSeo(stubT, "ru", CANONICAL);
expect(result.twitter).toBeDefined();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- test assertion guards above
expect(result.twitter!.card).toBe("summary");
});
});
+8 -8
View File
@@ -16,10 +16,10 @@
*/
export interface FlightsMapSearchParams {
departure: string;
arrival?: string;
arrival?: string | undefined;
dateFrom: string;
dateTo: string;
connections?: number;
connections?: number | undefined;
}
/**
@@ -28,7 +28,7 @@ export interface FlightsMapSearchParams {
export interface FlightsMapCalendarParams {
date: string;
departure: string;
arrival?: string;
arrival?: string | undefined;
connections: boolean;
}
@@ -78,8 +78,8 @@ export interface IMapMarker {
lat: number;
lng: number;
style: MarkerStyle;
label?: string;
tooltipPermanent?: boolean;
label?: string | undefined;
tooltipPermanent?: boolean | undefined;
}
/**
@@ -113,9 +113,9 @@ export interface IMapPopup {
* State shape for the flights map filter.
*/
export interface IFlightsMapFilterState {
departure?: string;
arrival?: string;
date?: string;
departure?: string | undefined;
arrival?: string | undefined;
date?: string | undefined;
connections: boolean;
domestic: boolean;
international: boolean;