import { useMemo } from 'preact/hooks';
import type { Marker } from './types';
import { getRouteLength } from '../shared/routes';

type TotalProps = {
    markers: Marker[];
};

export const TotalComponent = ({ markers }: TotalProps) => {
    const routeLength = useMemo(() => getRouteLength(markers), [markers]);

    return <>{`Total route length: ${routeLength.toFixed(0)}m`}</>;
};
