2020-04-23 09:15:27 +02:00
|
|
|
import { FunctionalComponent, h } from "preact";
|
|
|
|
import { Project } from "../../models/project";
|
|
|
|
import { useProjectEstimations } from "../../hooks/use-project-estimations";
|
|
|
|
import { getCurrency, getRoundUpEstimations } from "../../models/params";
|
|
|
|
import ProjectTimeUnit from "../../components/project-time-unit";
|
2020-04-23 13:29:24 +02:00
|
|
|
import { getTaskCategoryWeightedMean, getProjectWeightedMean, getTaskCategoriesMeanRepartition } from "../../util/stat";
|
2020-04-23 09:15:27 +02:00
|
|
|
|
|
|
|
export interface RepartitionPreviewProps {
|
|
|
|
project: Project
|
|
|
|
}
|
|
|
|
|
|
|
|
const RepartitionPreview: FunctionalComponent<RepartitionPreviewProps> = ({ project }) => {
|
2020-04-23 13:29:24 +02:00
|
|
|
const repartition = getTaskCategoriesMeanRepartition(project);
|
2020-04-23 09:15:27 +02:00
|
|
|
return (
|
|
|
|
<div class="table-container">
|
|
|
|
<table class="table is-bordered is-striped is-fullwidth">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-04-23 09:38:59 +02:00
|
|
|
<th colSpan={2}>Répartition moyenne</th>
|
2020-04-23 09:15:27 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Catégorie</th>
|
2020-04-23 09:38:59 +02:00
|
|
|
<th>Temps (en %)</th>
|
2020-04-23 09:15:27 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{
|
|
|
|
Object.values(project.params.taskCategories).map(tc => {
|
2020-04-23 13:29:24 +02:00
|
|
|
let percent = (repartition[tc.id] * 100).toFixed(0);
|
2020-04-23 09:15:27 +02:00
|
|
|
return (
|
|
|
|
<tr key={`task-category-${tc.id}`}>
|
|
|
|
<td>{tc.label}</td>
|
2020-04-23 09:38:59 +02:00
|
|
|
<td>{percent} %</td>
|
2020-04-23 09:15:27 +02:00
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RepartitionPreview;
|