From 44e6a32c8ec1044eca057378b7ffc3210728c787 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 11 Feb 2020 22:31:19 +0100 Subject: [PATCH] Fix poposal breakdown (#2272) --- packages/react-params/src/Param/Moment.tsx | 2 +- packages/react-params/src/Param/Text.tsx | 2 +- packages/react-params/src/Param/findComponent.ts | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-params/src/Param/Moment.tsx b/packages/react-params/src/Param/Moment.tsx index 9bd6bd81aa..38ce3cf0e3 100644 --- a/packages/react-params/src/Param/Moment.tsx +++ b/packages/react-params/src/Param/Moment.tsx @@ -33,7 +33,7 @@ function onChange ({ onChange }: Props): (_: RawParamOnChangeValue) => void { }; } -export default function Code (props: Props): React.ReactNode { +export default function Code (props: Props): React.ReactElement { const { className, defaultValue, isDisabled, isError, label, onEnter, onEscape, style, type, withLabel } = props; if (isDisabled) { diff --git a/packages/react-params/src/Param/Text.tsx b/packages/react-params/src/Param/Text.tsx index b1e16dc2ff..8358027d63 100644 --- a/packages/react-params/src/Param/Text.tsx +++ b/packages/react-params/src/Param/Text.tsx @@ -20,7 +20,7 @@ function onChange ({ onChange }: Props): (_: string) => void { }; } -export default function Text (props: Props): React.ReactNode { +export default function Text (props: Props): React.ReactElement { const { className, defaultValue: { value }, isDisabled, isError, label, onEnter, onEscape, style, withLabel } = props; const defaultValue = (value || '').toString(); diff --git a/packages/react-params/src/Param/findComponent.ts b/packages/react-params/src/Param/findComponent.ts index 0ab3c95412..c910f3b7cc 100644 --- a/packages/react-params/src/Param/findComponent.ts +++ b/packages/react-params/src/Param/findComponent.ts @@ -35,17 +35,17 @@ import Vote from './Vote'; import VoteThreshold from './VoteThreshold'; interface TypeToComponent { - c: React.ComponentType; + c: React.ComponentType; t: string[]; } -const components: ComponentMap = ([ +const componentDef: TypeToComponent[] = [ { c: Account, t: ['AccountId', 'AccountIdOf', 'Address', 'AuthorityId', 'LookupSource', 'LookupTarget', 'SessionKey', 'ValidatorId'] }, { c: Amount, t: ['AccountIndex', 'AssetId', 'BlockNumber', 'Gas', 'Index', 'Nonce', 'ParaId', 'ProposalIndex', 'PropIndex', 'ReferendumIndex', 'i8', 'i16', 'i32', 'i64', 'i128', 'u8', 'u16', 'u32', 'u64', 'u128', 'u256', 'VoteIndex'] }, { c: Balance, t: ['Amount', 'AssetOf', 'Balance', 'BalanceOf'] }, { c: Bool, t: ['bool'] }, { c: Bytes, t: ['Bytes'] }, - { C: Call, t: ['Call', 'Proposal'] }, + { c: Call, t: ['Call', 'Proposal'] }, { c: Code, t: ['Code'] }, { c: DispatchError, t: ['DispatchError'] }, { c: Raw, t: ['Raw', 'Keys'] }, @@ -64,7 +64,9 @@ const components: ComponentMap = ([ { c: Vote, t: ['Vote'] }, { c: VoteThreshold, t: ['VoteThreshold'] }, { c: Unknown, t: ['Unknown'] } -] as TypeToComponent[]).reduce((components, { c, t }): ComponentMap => { +]; + +const components: ComponentMap = componentDef.reduce((components, { c, t }): ComponentMap => { t.forEach((type): void => { components[type] = c; });