43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { FunctionalComponent, h } from "preact";
|
|
import { Project } from "../../models/project";
|
|
import { useProjectEstimations } from "../../hooks/use-project-estimations";
|
|
import { getCurrency } from "../../models/params";
|
|
|
|
export interface FinancialPreviewProps {
|
|
project: Project
|
|
}
|
|
|
|
const FinancialPreview: FunctionalComponent<FinancialPreviewProps> = ({ project }) => {
|
|
const estimations = useProjectEstimations(project);
|
|
const costPerTimeUnit = 500;
|
|
const maxCost = Math.ceil((estimations.p99.e + estimations.p99.sd) * costPerTimeUnit);
|
|
const minCost = Math.max(Math.ceil((estimations.p99.e - estimations.p99.sd) * costPerTimeUnit), 0);
|
|
return (
|
|
<div class="table-container">
|
|
<table class="table is-bordered is-striped is-fullwidth">
|
|
<thead>
|
|
<tr>
|
|
<th colSpan={2}>Prévisionnel financier</th>
|
|
</tr>
|
|
<tr>
|
|
<th class="is-narrow">Temps</th>
|
|
<th>Coût</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="is-narrow">Maximum</td>
|
|
<td>{maxCost} {getCurrency(project)}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="is-narrow">Minimum</td>
|
|
<td>{minCost} {getCurrency(project)}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default FinancialPreview;
|