import { Component, createEffect, createResource } from 'solid-js';

import OlMap from 'ol/Map';

import dispatch from '../../workers/dispatcher-main';
import getUri from '../../lib/ids';

interface Props {
  trksegId: string;
  map: () => OlMap | null;
}

export const Trkseg: Component<Props> = ({ map, trksegId }) => {
  const [trkseg] = createResource(
    trksegId,
    async () =>
      await dispatch({
        action: 'getTrkseg',
        params: {
          id: trksegId,
        },
      })
  );

  createEffect(() => {
    console.log({ caller: 'Trkseg', map: map(), trksegId, trkseg: trkseg() });
  });

  return <></>;
};

export default Trkseg;
