types.ts cleanup

main
Inga 🏳‍🌈 1 year ago
parent 221467fa27
commit ddeb4e3e64
  1. 6
      src/routePlanner/export.tsx
  2. 8
      src/routePlanner/map.tsx
  3. 8
      src/routePlanner/marker.tsx
  4. 7
      src/routePlanner/markers.tsx
  5. 6
      src/routePlanner/total.tsx
  6. 26
      src/routePlanner/types.ts

@ -1,5 +1,9 @@
import { exportMarkersToGpx } from '../exporters/gpx'; import { exportMarkersToGpx } from '../exporters/gpx';
import type { ExportProps } from './types'; import type { Marker } from './types';
type ExportProps = {
markers: Marker[];
};
export const ExportComponent = ({ markers }: ExportProps) => { export const ExportComponent = ({ markers }: ExportProps) => {
return ( return (

@ -2,7 +2,8 @@ import { useRef } from 'preact/hooks';
import { type MapViewParameters, useMap } from '../hooks/leaflet/useMap'; import { type MapViewParameters, useMap } from '../hooks/leaflet/useMap';
import { useMapClick } from '../hooks/leaflet/useMapClick'; import { useMapClick } from '../hooks/leaflet/useMapClick';
import { useMarkersOnMap } from './hooks/useMarkersOnMap'; import { useMarkersOnMap } from './hooks/useMarkersOnMap';
import type { MapProps } from './types'; import type { Coordinates } from '../shared/types';
import type { Marker } from './types';
const defaultMapViewParameters: MapViewParameters = [[47.42111, 10.98528], 13]; const defaultMapViewParameters: MapViewParameters = [[47.42111, 10.98528], 13];
@ -13,6 +14,11 @@ const markerLayersStyle = {
}, },
}; };
type MapProps = {
markers: Marker[];
onMapClick: (coordinates: Coordinates) => void;
};
export const MapComponent = ({ markers, onMapClick }: MapProps) => { export const MapComponent = ({ markers, onMapClick }: MapProps) => {
const mapContainerRef = useRef<HTMLDivElement>(null); const mapContainerRef = useRef<HTMLDivElement>(null);
const mapRef = useMap(mapContainerRef, defaultMapViewParameters); const mapRef = useMap(mapContainerRef, defaultMapViewParameters);

@ -1,5 +1,11 @@
import { usePrompt } from '../hooks/usePrompt'; import { usePrompt } from '../hooks/usePrompt';
import type { MarkerProps } from './types'; import type { Marker } from './types';
type MarkerProps = {
marker: Marker;
isFirst: boolean;
isLast: boolean;
};
export const MarkerComponent = ({ marker, isFirst, isLast }: MarkerProps) => { export const MarkerComponent = ({ marker, isFirst, isLast }: MarkerProps) => {
const changeLongLabel = usePrompt( const changeLongLabel = usePrompt(

@ -1,7 +1,12 @@
import { useRef } from 'preact/hooks'; import { useRef } from 'preact/hooks';
import { useSortable } from '../hooks/useSortable'; import { useSortable } from '../hooks/useSortable';
import { MarkerComponent } from './marker'; import { MarkerComponent } from './marker';
import type { MarkersProps } from './types'; import type { Marker, ReorderListParams } from './types';
type MarkersProps = {
markers: Marker[];
onMarkersReorder: (params: ReorderListParams) => void;
};
export const MarkersComponent = ({ export const MarkersComponent = ({
markers, markers,

@ -1,7 +1,11 @@
import { useMemo } from 'preact/hooks'; import { useMemo } from 'preact/hooks';
import type { TotalProps } from './types'; import type { Marker } from './types';
import { getRouteLength } from '../shared/routes'; import { getRouteLength } from '../shared/routes';
type TotalProps = {
markers: Marker[];
};
export const TotalComponent = ({ markers }: TotalProps) => { export const TotalComponent = ({ markers }: TotalProps) => {
const routeLength = useMemo( const routeLength = useMemo(
() => getRouteLength(markers.map(({ coordinates }) => coordinates)), () => getRouteLength(markers.map(({ coordinates }) => coordinates)),

@ -1,4 +1,4 @@
import type { Coordinates, Waypoint } from '../shared/types'; import type { Waypoint } from '../shared/types';
export type Marker = Waypoint & { export type Marker = Waypoint & {
key: string; key: string;
@ -20,27 +20,3 @@ export type ReorderListParams = {
oldIndex: number; oldIndex: number;
newIndex: number; newIndex: number;
}; };
export type MarkersProps = {
markers: Marker[];
onMarkersReorder: (params: ReorderListParams) => void;
};
export type TotalProps = {
markers: Marker[];
};
export type MapProps = {
markers: Marker[];
onMapClick: (coordinates: Coordinates) => void;
};
export type ExportProps = {
markers: Marker[];
};
export type MarkerProps = {
marker: Marker;
isFirst: boolean;
isLast: boolean;
};

Loading…
Cancel
Save