Linting fixes

This commit is contained in:
Fred Carlsen
2019-02-13 01:50:06 +01:00
committed by Jacob Evans
parent 1c040bd616
commit b9a93c82d7
3 changed files with 19 additions and 27 deletions

View File

@@ -15,6 +15,7 @@ interface InputProps {
width?: InputWidth;
label: string;
type?: string;
defaultValue?: string;
errors?: ErrorProps;
isErrors?: boolean;
required?: boolean;
@@ -64,7 +65,7 @@ export const CheckBoxInput = (props: CheckBoxProps) => {
};
export const Input = React.forwardRef((props: InputProps, ref?: React.Ref<HTMLInputElement>) => {
const { name, label, type, errors } = props;
const { name, label, type, errors, defaultValue } = props;
const id = `input-${name}`;
const componentType = type === 'textarea' ? 'textarea' : 'input';
const isErrors = errors.hasOwnProperty(name) && errors[name] !== null;
@@ -73,7 +74,7 @@ export const Input = React.forwardRef((props: InputProps, ref?: React.Ref<HTMLIn
return (
<InputWrapper {...props}>
<Label htmlFor={id}>{label}</Label>
<StyledInput as={componentType} ref={ref} id={id} isErrors={isErrors} {...props} />
<StyledInput as={componentType} ref={ref} id={id} isErrors={isErrors} defaultValue={defaultValue} {...props} />
{isErrors && <Error>{errorMessage}</Error>}
</InputWrapper>
);

View File

@@ -10,6 +10,7 @@ import { colors } from 'ts/style/colors';
import { constants } from 'ts/utils/constants';
import { AddressTableRow } from 'ts/pages/governance/address_table_row';
import { Button } from 'ts/components/button';
import { Input, InputWidth } from 'ts/components/modals/input';
import { ChangeEvent } from 'react';
@@ -19,10 +20,6 @@ interface InputProps {
onChangePath?: (selectedPath: string) => void;
}
interface AddressTableState {
selectedAddressIndex?: number;
}
interface RowProps {
color: string;
width: number;
@@ -32,38 +29,34 @@ export class DerivationPathInput extends React.Component<InputProps> {
public pathRef: React.RefObject<HTMLInputElement> = React.createRef();
constructor(props: InputProps) {
super(props);
this.state = {
selectedAddressIndex: 0,
};
}
public render(): React.ReactNode {
// const { userAddresses, addressBalances } = this.props;
const { path } = this.props;
return (
<Wrapper>
<Input name="derivationPath" label="Derivation Path" type="text" ref={this.pathRef} />
<Input name="derivationPath" label="Derivation Path" type="text" defaultValue={path} ref={this.pathRef} />
<ButtonUpdate onClick={this._updatePath.bind(this)}>Update</ButtonUpdate>
</Wrapper>
);
}
private _onSelectAddress(e: ChangeEvent<HTMLInputElement>): void {
const selectedAddressIndex = parseInt(e.currentTarget.value, 10);
this.setState({ selectedAddressIndex });
if (this.props.onSelectAddress) {
this.props.onSelectAddress(this.state.selectedAddressIndex);
private _updatePath(): void {
if (this.props.onChangePath) {
this.props.onChangePath(this.pathRef.current.value);
}
}
}
const Wrapper = styled.div<{ marginBottom?: string }>`
background-color: #fff;
border-radius: 4px;
margin-bottom: ${props => props.marginBottom || '12px'};
padding: 10px 30px;
height: 230px;
overflow-y: auto;
display: flex;
`;
const Table = styled.table`
border-collapse: collapse;
width: 100%;
`;
const ButtonUpdate = styled(Button).attrs({
isTransparent: true,
type: 'button',
})`
margin-left: 30px;
`;

View File

@@ -166,9 +166,7 @@ export class ModalVote extends React.Component<Props> {
public render(): React.ReactNode {
const { isOpen, onDismiss } = this.props;
const { isSuccessful, errors, votePreference, selectedAddress, currentBalance } = this.state;
const formattedBalance = Web3Wrapper.toUnitAmount(currentBalance, constants.DECIMAL_PLACES_ETH)
.toNumber()
.toFixed(configs.AMOUNT_DISPLAY_PRECSION);
const formattedBalance = Web3Wrapper.toUnitAmount(currentBalance, constants.DECIMAL_PLACES_ETH);
return (
<>
<DialogOverlay