import { Flex, Grid, Skeleton, useColorModeValue } from '@chakra-ui/react';
import React from 'react';
import type { DecodedInput } from 'types/api/decodedInput';
import type { ArrayElement } from 'types/utils';
import CopyToClipboard from 'ui/shared/CopyToClipboard';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TruncatedValue from 'ui/shared/TruncatedValue';
interface Props {
data: DecodedInput['parameters'];
isLoading?: boolean;
}
const HeaderItem = ({ children, isLoading }: { children: React.ReactNode; isLoading?: boolean }) => {
return (
{ children }
);
};
const Row = ({ name, type, indexed, value, isLoading }: ArrayElement & { isLoading?: boolean }) => {
const content = (() => {
if (type === 'address' && typeof value === 'string') {
return (
);
}
if (typeof value === 'object') {
const text = JSON.stringify(value, undefined, 4);
return (
);
}
return (
);
})();
return (
<>
{ indexed !== undefined && (
{ indexed ? 'true' : 'false' }
) }
{ content }
>
);
};
const LogDecodedInputDataTable = ({ data, isLoading }: Props) => {
const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const hasIndexed = data.some(({ indexed }) => indexed !== undefined);
const gridTemplateColumnsBase = hasIndexed ?
'50px 60px 40px minmax(0, 1fr)' :
'50px 60px minmax(0, 1fr)';
const gridTemplateColumnsLg = hasIndexed ?
'80px 80px 80px minmax(0, 1fr)' :
'80px 80px minmax(0, 1fr)';
return (
Name
Type
{ hasIndexed && Indexed? }
Data
{ data.map((item) => {
return
;
}) }
);
};
export default LogDecodedInputDataTable;