dyomedea/src/components/gpx/GpxViewer.tsx

46 lines
1.1 KiB
TypeScript

import { Component, For } from 'solid-js';
import { peekCachedSignal } from '../../workers/cached-signals';
import Tree from '../tree';
import { WptViewer } from '../wpt';
import GpxIcon from './GpxIcon';
interface Props {
gpxId: string;
restrictToHierarchy?: any;
}
const GpxViewer: Component<Props> = ({ gpxId, restrictToHierarchy }) => {
const gpx = peekCachedSignal({ id: gpxId, method: 'getGpx' });
console.log({ caller: 'GpxViewer', gpxId, restrictToHierarchy, gpx: gpx() });
const title = () => {
return gpx().metadata.name;
};
return (
<Tree
title={
<>
<GpxIcon /> {title()}
</>
}
content={undefined}
subTree={
<For
each={Object.keys(restrictToHierarchy).filter((key: string) =>
key.startsWith('gpx/')
)}
>
{(key: string) => {
const child = restrictToHierarchy[key];
if (child.type === 'wpt') {
return <WptViewer wptId={key} />;
}
return <></>;
}}
</For>
}
/>
);
};
export default GpxViewer;