2022-08-11 11:45:28 +05:30
|
|
|
import { blue } from '@ant-design/colors';
|
|
|
|
|
import { CopyFilled } from '@ant-design/icons';
|
|
|
|
|
import { Button, Row } from 'antd';
|
|
|
|
|
import Editor from 'components/Editor';
|
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
|
import { useCopyToClipboard } from 'react-use';
|
2022-08-19 17:16:04 +05:30
|
|
|
import { ILog } from 'types/api/logs/log';
|
2022-08-11 11:45:28 +05:30
|
|
|
|
2022-08-19 17:16:04 +05:30
|
|
|
interface JSONViewProps {
|
|
|
|
|
logData: ILog;
|
|
|
|
|
}
|
|
|
|
|
function JSONView({ logData }: JSONViewProps): JSX.Element {
|
|
|
|
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
|
|
|
const LogJsonData = useMemo(() => JSON.stringify(logData, null, 2), [logData]);
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<Row
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
|
margin: '0.5rem 0',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
|
onClick={(): void => copyToClipboard(LogJsonData)}
|
|
|
|
|
>
|
|
|
|
|
<CopyFilled /> <span style={{ color: blue[5] }}>Copy to Clipboard</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</Row>
|
|
|
|
|
<div style={{ marginTop: '0.5rem' }}>
|
|
|
|
|
<Editor
|
|
|
|
|
value={LogJsonData}
|
|
|
|
|
language="json"
|
|
|
|
|
height="70vh"
|
|
|
|
|
readOnly
|
|
|
|
|
onChange={(): void => {}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2022-08-11 11:45:28 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default JSONView;
|