import { GraphNode } from '@bob-the-algorithm/core'; import { Popover, PopoverTrigger, PopoverContent } from '@nextui-org/react'; import { useExperimentResult } from '../../features/experiment'; import { useMemo } from 'react'; import { formatTime } from '../../utils/time'; type PlanProps = { node: GraphNode; }; const timespan = 24 * 60 * 60 * 1000; const randomColor = () => Math.floor(Math.random() * 16777215).toString(16); const HorizontalPlan: React.FC = ({ node }) => { const data = useExperimentResult(); const nodes = useMemo(() => { if (!data) { return []; } const result: GraphNode[] = []; let current = node; if (!current) { return []; } while (current) { result.push(current); if (!current.parent) { break; } current = data.nodes.find((n) => n.id === current?.parent)!; } return result; }, [data, node]); if (!data) { return null; } return (
{nodes.map((node) => { const time = ( {formatTime(node.time)} - {formatTime(node.time + node.duration)} ); let title = ''; if (node.planable) { const planable = data!.planables.find((n) => n.id === node.planable); title = `Planable: ${planable?.id}`; } if (node.type === 'travel') { title = `Travel: ${node.context.location}`; } return (
{title}
{time}
); })}
); }; export { HorizontalPlan };