import React, { FunctionComponent } from "react"; import { Project } from "../../models/project"; import { useProjectEstimations } from "../../hooks/use-project-estimations"; import { getCurrency, defaults, getTaskCategoryCost, getRoundUpEstimations } from "../../models/params"; import { getMinMaxCosts, Cost } from "../../util/stat"; import * as style from './style.module.css'; import ProjectTimeUnit from "../../components/project-time-unit"; export interface FinancialPreviewProps { project: Project } const FinancialPreview: FunctionComponent = ({ project }) => { const estimations = useProjectEstimations(project); const costs = getMinMaxCosts(project, estimations.p99); const roundUp = getRoundUpEstimations(project); return (
Prévisionnel financier
confiance >= 99.7%
Temps Coût
Maximum
Minimum
); }; export interface CostDetailsProps { project: Project cost: Cost roundUp: boolean } export const CostDetails:FunctionComponent = ({ project, cost, roundUp }) => { return (
≈ {cost.totalCost} {getCurrency(project)} { roundUp ? Math.ceil(cost.totalTime) : cost.totalTime.toFixed(2) } { Object.keys(cost.details).map(taskCategoryId => { const taskCategory = project.params.taskCategories[taskCategoryId]; const details = cost.details[taskCategoryId]; return ( ) }) }
{taskCategory.label} {details.cost} {getCurrency(project)} { roundUp ? Math.ceil(details.time) : details.time.toFixed(2) } × {getTaskCategoryCost(taskCategory)} {getCurrency(project)}
); }; export default FinancialPreview;