Skip to content

Commit

Permalink
Minor codestyle fixes (#23)
Browse files Browse the repository at this point in the history
* Minor code style fixes
* Few types added
  • Loading branch information
builat authored and Aleksey Dmitriev committed Aug 26, 2018
1 parent 5ec330e commit b3dfd24
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class HeaderStats extends React.Component<StatsActions & AppActions & StatsState
}


function mapStateToProps (state: AppState): any {
function mapStateToProps (state: AppState): StatsState {
return state.stats;
}

Expand Down
12 changes: 6 additions & 6 deletions client/src/components/header/header.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import './header.scss';
import { BurgerIcon, LogoVerticalIcon } from '../common/icons/common.icons';

class Header extends React.Component<SettingsActions> {
constructor (props: any) {
super(props);
this.showSidebar = this.showSidebar.bind(this);
constructor (props: SettingsActions) {
super(props);

this.showSidebar = this.showSidebar.bind(this);
}

render (): JSX.Element {
return (
<div className='bi-header g-flex g-flex-column__item-fixed'>
Expand All @@ -42,7 +42,7 @@ class Header extends React.Component<SettingsActions> {
);
}

private showSidebar (): void {
private showSidebar (): void {
this.props.setSidebarDisplayStatus(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,39 @@ import { AddressId } from '../../../models/generated/addressId';

import { CrossIcon } from '../../common/icons/common.icons';

import './payment-request-modal.scss';

type IPaymentRequestModalProps = RouteComponentProps<any> & {
isOpen: boolean;
onClose: () => void;
address: AddressId;
};

import './payment-request-modal.scss';
interface IPaymentRequestState {
amount: number;
copied: boolean;
description: string;
}

class PaymentRequestModal extends React.PureComponent<IPaymentRequestModalProps, IPaymentRequestState> {

class PaymentRequestModal extends React.PureComponent<IPaymentRequestModalProps> {
link: HTMLDivElement;

state: any = {
state: IPaymentRequestState = {
amount: 0,
copied: false,
description: ''
};

constructor (props: any) {
super(props);

this.setAmount = this.setAmount.bind(this);
this.setDescription = this.setDescription.bind(this);
this.copyLinkToClipboard = this.copyLinkToClipboard.bind(this);
this.selectLink = this.selectLink.bind(this);
constructor (props: IPaymentRequestModalProps){
super(props);
this.setAmount = this.setAmount.bind(this);
this.setDescription = this.setDescription.bind(this);
this.copyLinkToClipboard = this.copyLinkToClipboard.bind(this);
this.selectLink = this.selectLink.bind(this);
}

render (): JSX.Element {
const link = this.getLink();

Expand Down Expand Up @@ -137,7 +144,7 @@ class PaymentRequestModal extends React.PureComponent<IPaymentRequestModalProps>

private setAmount (event: React.ChangeEvent<HTMLInputElement>): void {
this.setState({
amount: event.target.value
amount: parseInt(event.target.value, 10)
});
}

Expand Down
30 changes: 13 additions & 17 deletions client/src/components/search/search.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ import { SearchIcon } from '../common/icons/common.icons';

import './search.scss';

class Search extends React.PureComponent<RouteComponentProps<{}>> {
state: {
isInputFocused: boolean,
} = {
interface ISearchState {
isInputFocused: boolean;
}

class Search extends React.PureComponent<RouteComponentProps<{}>, ISearchState> {
state: ISearchState = {
isInputFocused: false
};

inputElement: HTMLInputElement;

onInputChangedDebounced: () => void;

constructor (props: any) {
constructor (props: RouteComponentProps<{}>) {
super(props);

this.focusInput = this.focusInput.bind(this);
this.onInputBlur = this.onInputBlur.bind(this);
this.onInputChanged = this.onInputChanged.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.focusInput = this.focusInput.bind(this);
this.onInputBlur = this.onInputBlur.bind(this);
this.onInputChanged = this.onInputChanged.bind(this);
this.onSubmit = this.onSubmit.bind(this);

this.onInputChangedDebounced = debounce(this.onInputChanged, 500);
}
Expand Down Expand Up @@ -73,7 +75,6 @@ class Search extends React.PureComponent<RouteComponentProps<{}>> {

private onSubmit (event: SyntheticEvent<HTMLFormElement>): void {
event.preventDefault();

this.onInputChanged();
}

Expand All @@ -84,13 +85,8 @@ class Search extends React.PureComponent<RouteComponentProps<{}>> {
}

private onInputChanged (): void {
const params = {
query: this.inputElement.value
};

if (!params.query) {
delete params.query;
}
const query = this.inputElement.value;
const params = query ? ({query}) : ({});

this.props.history.push(`/search?${queryString.stringify(params)}`);
}
Expand Down
14 changes: 10 additions & 4 deletions client/src/components/sidebar/sidebar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ const SIDEBAR_MENU_ITEMS: ISidebarMenuItem[] = [
}
];

class Sidebar extends React.Component<SettingsActions & ApiActions & { settings: SettingsState, api: ApiState }> {
state: any = {
interface ISidebarState {
isClient: boolean;
}

type ISidebarProps = SettingsActions & ApiActions & { settings: SettingsState, api: ApiState };

class Sidebar extends React.Component<ISidebarProps, ISidebarState> {
state: ISidebarState = {
isClient: false
};

constructor (props: any) {
constructor (props: ISidebarProps) {
super(props);

this.toggleCollapse = this.toggleCollapse.bind(this);
Expand Down Expand Up @@ -165,7 +171,7 @@ class Sidebar extends React.Component<SettingsActions & ApiActions & { settings:
}
}

function mapStateToProps (state: AppState): any {
function mapStateToProps (state: AppState): { settings: SettingsState, api: ApiState } {
return { settings: state.settings, api: state.api };
}

Expand Down

0 comments on commit b3dfd24

Please sign in to comment.