um-react/src/components/SDKVersion.tsx

34 lines
933 B
TypeScript
Raw Normal View History

2023-05-14 23:09:54 +00:00
import { InfoOutlineIcon } from '@chakra-ui/icons';
import { Tooltip, VStack, Text, Flex } from '@chakra-ui/react';
import { workerClientBus } from '~/decrypt-worker/client';
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants';
2023-05-14 23:09:54 +00:00
import usePromise from 'react-promise-suspense';
const getSDKVersion = async (): Promise<string> => {
2023-05-14 23:22:23 +00:00
return workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.VERSION, null);
2023-05-14 23:09:54 +00:00
};
export function SDKVersion() {
const sdkVersion = usePromise(getSDKVersion, []);
2023-05-14 23:09:54 +00:00
return (
<Flex as="span" pl="1" alignItems="center" data-testid="sdk-version">
2023-05-14 23:22:23 +00:00
<Tooltip
hasArrow
placement="top"
label={
<VStack>
<Text>App: __APP_VERSION__</Text>
<Text>SDK: {sdkVersion}</Text>
</VStack>
}
bg="gray.300"
color="black"
>
<InfoOutlineIcon />
</Tooltip>
</Flex>
2023-05-14 23:09:54 +00:00
);
}