Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getOperatorType = (dataType: string) => {
if (dataType === AttrbuteDataType.INT || dataType === AttrbuteDataType.DECIMAL || dataType === AttrbuteDataType.CURRENCY) {
return 'numeric';
}
if (dataType === AttrbuteDataType.STRING || dataType === AttrbuteDataType.ACCOUNT_ADDRESS || dataType === AttrbuteDataType.HASH) {
return 'string';
}
if (dataType === AttrbuteDataType.BOOLEAN) {
return 'boolean';
}
return 'dateTime';
}
render () {
const {
t,
attribute,
value,
disabled,
onChange,
classes
} = this.props;
const { stateVal, suggestions } = this.state;
const isLong = attribute.dataType === AttrbuteDataType.STRING || attribute.dataType === AttrbuteDataType.HASH || attribute.dataType === AttrbuteDataType.ACCOUNT_ADDRESS;
if (attribute.dataType === AttrbuteDataType.DATETIME) {
const newValue = value? new Date(Number(value)) : '';
return (
onChange(String(new Date(val).getTime()))}
/>
)
}
{value}
)
} else if (dataType === AttrbuteDataType.ACCOUNT_ADDRESS) {
const colors = Buffer.from(Buffer.from(value.substring(3, 6) + value.slice(-3), 'utf8').map(b => Math.floor((b - 48) * 255)/74)).toString('hex');
const address = formatReferenceValue(attribute, (truncate ? truncateHash(value) : value), value, onClickPrimaryKey)
return (
{address}
);
} else if (dataType === AttrbuteDataType.HASH) {
const hash = formatReferenceValue(attribute, (truncate ? truncateHash(value) : value), value, onClickPrimaryKey);
return (
{hash}
);
} else if (dataType === AttrbuteDataType.DECIMAL || dataType === AttrbuteDataType.INT || dataType === AttrbuteDataType.CURRENCY) {
return formatNumber(Number(value), attribute, truncate);
} else if (dataType === AttrbuteDataType.STRING && value.length > 100) {
return (
{value.substring(0, 100)}
)
} else if (dataType === AttrbuteDataType.ACCOUNT_ADDRESS) {
const colors = Buffer.from(Buffer.from(value.substring(3, 6) + value.slice(-3), 'utf8').map(b => Math.floor((b - 48) * 255)/74)).toString('hex');
return (
{formatReferenceValue(attribute, truncateHash(value), value, onClickPrimaryKey)}
);
} else if (dataType === AttrbuteDataType.HASH) {
return (
{formatReferenceValue(attribute, truncateHash(value), value, onClickPrimaryKey)}
);
} else if (dataType === AttrbuteDataType.DECIMAL || dataType === AttrbuteDataType.INT || dataType === AttrbuteDataType.CURRENCY) {
return formatNumber(Number(value), attribute);
} else if (dataType === AttrbuteDataType.STRING && value.length > 100) {
return (
{value.substring(0, 100)}