2020-12-22 02:00:36 -07:00
|
|
|
import {
|
|
|
|
Modal,
|
|
|
|
ModalBody,
|
|
|
|
ModalHeader,
|
|
|
|
ModalOverlay,
|
|
|
|
ModalContent,
|
|
|
|
useDisclosure,
|
|
|
|
Skeleton,
|
|
|
|
ModalCloseButton,
|
|
|
|
} from '@chakra-ui/react';
|
|
|
|
import { PathButton } from '~/components';
|
|
|
|
import { useColorValue } from '~/context';
|
|
|
|
import { useLGState } from '~/hooks';
|
|
|
|
import { Chart } from './chart';
|
|
|
|
|
|
|
|
import type { TPath } from './types';
|
|
|
|
|
|
|
|
export const Path = (props: TPath) => {
|
|
|
|
const { device } = props;
|
|
|
|
const { getResponse } = useLGState();
|
|
|
|
const { isOpen, onClose, onOpen } = useDisclosure();
|
|
|
|
const { displayTarget } = useLGState();
|
|
|
|
const response = getResponse(device);
|
|
|
|
const output = response?.output as TStructuredResponse;
|
2020-12-25 00:45:23 -07:00
|
|
|
const bg = useColorValue('whiteFaded.50', 'blackFaded.900');
|
2020-12-22 02:00:36 -07:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PathButton onOpen={onOpen} />
|
|
|
|
<Modal isOpen={isOpen} onClose={onClose} size="full" isCentered>
|
|
|
|
<ModalOverlay />
|
2020-12-25 00:45:23 -07:00
|
|
|
<ModalContent bg={bg} maxW={{ base: '100%', lg: '80%' }} maxH={{ base: '80%', lg: '60%' }}>
|
2020-12-22 02:00:36 -07:00
|
|
|
<ModalHeader>{`Path to ${displayTarget.value}`}</ModalHeader>
|
|
|
|
<ModalCloseButton />
|
|
|
|
<ModalBody>
|
|
|
|
{response !== null ? <Chart data={output} /> : <Skeleton w="500px" h="300px" />}
|
|
|
|
</ModalBody>
|
|
|
|
</ModalContent>
|
|
|
|
</Modal>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|