import React from 'react' import { connect, ConnectedProps } from 'react-redux' import ReactTooltip from 'react-tooltip' import { t } from 'ttag' import EditableLabel from '../components/EditableLabel' import { setFunctionTransfer, toggleFunction } from '../actions/customFunctions' const connector = connect(null, (dispatch: (action: any) => any) => { return { onTransferChange: (id: string, transfer: number | null) => dispatch(setFunctionTransfer(id, transfer)), onToggleFunction: (id: string) => dispatch(toggleFunction(id)), } }) type FunctionProps = ConnectedProps & { customFunction: any activateModal: () => void } const Function = ({ customFunction, activateModal, onTransferChange, onToggleFunction }: FunctionProps) => { const { name, func, value, transfer, id } = customFunction return ( onToggleFunction(id)} /> {name} {value ? parseFloat(value).toFixed(2) : ''} { const trnsfr = parseFloat(newValue) if (Number.isNaN(trnsfr)) { return onTransferChange(id, null) } onTransferChange(id, trnsfr) }} /> { e.stopPropagation() activateModal() }} />
{name}
{func !== null ?
{func}
: null}
{t`Value:`} {value ? parseFloat(value).toFixed(2) : '--'}
{t`Transfer limit (+/-):`} {transfer}
) } export default connector(Function)