2020-04-21 18:44:10 +02:00
|
|
|
import ProjectTimeUnit from "./project-time-unit";
|
|
|
|
import { defaults, getRoundUpEstimations } from "../models/params";
|
2020-04-22 22:07:52 +02:00
|
|
|
import { Project } from "../models/project";
|
|
|
|
import { FunctionalComponent, Fragment, h } from "preact";
|
|
|
|
import { Estimation } from "../hooks/use-project-estimations";
|
2020-04-21 18:44:10 +02:00
|
|
|
|
|
|
|
export interface EstimationRangeProps {
|
|
|
|
project: Project,
|
|
|
|
estimation: Estimation
|
|
|
|
}
|
|
|
|
|
2020-04-23 13:29:24 +02:00
|
|
|
export const EstimationRange: FunctionalComponent<EstimationRangeProps> = ({ project, estimation }) => {
|
2020-04-21 18:44:10 +02:00
|
|
|
const roundUp = getRoundUpEstimations(project);
|
2020-04-23 14:00:56 +02:00
|
|
|
let e: number|string = estimation.e;
|
|
|
|
let sd: number|string = estimation.sd;
|
|
|
|
let max = e+sd;
|
|
|
|
let min = Math.max(e-sd, 0);
|
|
|
|
if (roundUp) {
|
|
|
|
sd = Math.ceil(sd);
|
|
|
|
e = Math.ceil(e);
|
|
|
|
max = Math.ceil(max);
|
|
|
|
min = Math.ceil(min);
|
|
|
|
} else {
|
|
|
|
sd = sd.toFixed(2);
|
|
|
|
e = e.toFixed(2);
|
2020-04-21 20:45:47 +02:00
|
|
|
}
|
2020-04-21 18:44:10 +02:00
|
|
|
return (
|
|
|
|
<Fragment>
|
2020-04-21 20:45:47 +02:00
|
|
|
<abbr title={`max: ${max.toFixed(2)}, min: ${min.toFixed(2)}`}>{`${e} ± ${sd}`}</abbr> <ProjectTimeUnit project={project} />
|
2020-04-21 18:44:10 +02:00
|
|
|
</Fragment>
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default EstimationRange;
|