import ProjectTimeUnit from "./project-time-unit";
import { defaults, getRoundUpEstimations } from "../models/params";

export interface EstimationRangeProps {
    project: Project,
    estimation: Estimation
    sdFactor: number
}

export const EstimationRange: FunctionalComponent<EstimationRangeProps> = ({ project, estimation, sdFactor }) => {
    const roundUp = getRoundUpEstimations(project);
    const e = roundUp ? Math.ceil(estimation.e) : estimation.e;
    const sd = roundUp ? Math.ceil(estimation.sd * sdFactor) : (estimation.sd * sdFactor);
    const max = e+sd;
    const min = Math.max(e-sd, 0);
    return (
        <Fragment>
            <abbr title={`max: ${max}, min: ${min}`}>{`${e} ± ${sd}`}</abbr>&nbsp;<ProjectTimeUnit project={project} />
        </Fragment>
        
    );
}

export default EstimationRange;