ghost-portal/packages/ui-app/src/InputExtrinsic/SelectMethod.tsx
YJ 57800cdb83 Fixes #103: Convert functional components to pure (#135)
* ui-signer pureComponentify

* ui-react pureCompify

* Status queue prop

* ui-app Button

* ui-app InputExtrinsic

* apps, app-rpc, ui-app, ui-react

* app-extrinsics, app-explorer, apps

* fixes for tslint

* more linter fixes

* Update index.tsx

* Update index.tsx

* Update Nonce.tsx

* Update index.tsx

* Update Results.tsx

* Update index.tsx

* Update Queries.tsx

* Update NodeInfo.tsx

* Update index.tsx

* Update Item.tsx

* style fixes

* TSLINTs
2018-07-13 07:40:31 +02:00

60 lines
1.8 KiB
TypeScript

// Copyright 2017-2018 @polkadot/ui-app authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { SectionItem } from '@polkadot/params/types';
import { Extrinsics, Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { I18nProps } from '../types';
import { DropdownOptions } from './types';
import React from 'react';
import extrinsics from '@polkadot/extrinsics';
import Dropdown from '../Dropdown';
import classes from '../util/classes';
import translate from '../translate';
type Props = I18nProps & {
isError?: boolean,
label?: string,
onChange: (value: SectionItem<Extrinsics>) => void,
options: DropdownOptions,
type: 'private' | 'public',
value: SectionItem<Extrinsics>,
withLabel?: boolean
};
// ({ className, isError, label = '', onChange, options, style, t, type, value: { name, section }, withLabel }: Props) {
class SelectMethod extends React.PureComponent<Props> {
render () {
const { className, isError, label = '', onChange, options, style, t, type, value: { name, section }, withLabel } = this.props;
if (!options.length) {
return null;
}
const transform = (name: Extrinsic$Sections): SectionItem<Extrinsics> =>
extrinsics[section][type][name];
return (
<Dropdown
className={classes('ui--DropdownLinked-Items', className)}
isError={isError}
label={label || t('input.extrinsic.method', {
defaultValue: 'with the extrinsic'
})}
onChange={onChange}
options={options}
style={style}
transform={transform}
value={name}
withLabel={withLabel}
/>
);
}
}
export default translate(SelectMethod);