import React from "react"; import {Faj, FajLabel} from "../domain-models/faj"; import {Modifier} from "../domain-models/tulajdonsag"; import {SignedNumberToText} from "./Helpers"; function fajiModositoText(faj: Faj, szamolas: (f: Faj) => number) : string { const mod = szamolas(faj) return (mod !== 0) ? SignedNumberToText(mod) + ' (' + FajLabel(faj) + ')' : '' } function TulajdonsagInput(props: { tulajdonsag: string, currentFaj : () => Faj, fajiModosito: (faj: Faj) => number, register: () => any, getCurrentValue: () => number tooLowError: string, tooHighError: string }) { const { tulajdonsag, register, currentFaj, getCurrentValue, fajiModosito, tooLowError, tooHighError, } = props; return (
{fajiModositoText(currentFaj(), fajiModosito)} Összesen: { (getCurrentValue() + (fajiModosito(currentFaj()))).toString() } Módosító: { SignedNumberToText(Modifier(getCurrentValue() + fajiModosito(currentFaj()))) } {getCurrentValue() < 3 && ( {tooLowError})} {getCurrentValue() > 18 && ( {tooHighError})}
) } export default TulajdonsagInput;