import React , { FC } from "react" ; import { AnyField , GenesisProtocolForm } from "@dorgtech/daocreator-lib" ; import FormField from "../FormField" ; import { MDBRow } from "mdbreact" ; interface Props { votingMachine : GenesisProtocolForm ; editable : boolean ; } const VotingMachineEditor = ( { votingMachine , editable } ) => { const iterableFields = Object . keys ( votingMachine . $ ) ; return ( < > { iterableFields . map ( ( key , index ) => { const field = votingMachine . $ [ key ] ; const prevField = votingMachine . $ [ iterableFields [ index - 1 ] ] ; if ( index <= 3 ) { return ( < FormField field = { field } editable = { editable } key = { `genproto-field-${ index }` } tabIndex = { index } / > ) ; } else if ( index % 2 !== 0 ) { return ( < MDBRow key = { `genproto-field-${ index }` } > < FormField field = { field } editable = { editable } tabIndex = { index + 8 } /> < FormField field = { prevField } editable = { editable } tabIndex = { index + 9 } /> < /MDBRow>); } return null ; } ) } < />); } ; export default VotingMachineEditor ;