Use project parameters for calculations
This commit is contained in:
24
src/components/estimation-range.tsx
Normal file
24
src/components/estimation-range.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
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> <ProjectTimeUnit project={project} />
|
||||
</Fragment>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
export default EstimationRange;
|
16
src/components/project-time-unit.tsx
Normal file
16
src/components/project-time-unit.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import { FunctionalComponent, h } from "preact";
|
||||
import { Project } from "../models/project";
|
||||
import { getTimeUnit } from "../models/params";
|
||||
|
||||
export interface ProjectTimeUnitProps {
|
||||
project: Project
|
||||
}
|
||||
|
||||
const ProjectTimeUnit: FunctionalComponent<ProjectTimeUnitProps> = ({ project }) => {
|
||||
const timeUnit = getTimeUnit(project);
|
||||
return (
|
||||
<abbr title={timeUnit.label}>{timeUnit.acronym}</abbr>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProjectTimeUnit;
|
Reference in New Issue
Block a user