guesstimate/client/src/routes/project/repartition-preview.tsx

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-07-09 13:00:42 +02:00
import React, { FunctionComponent } from "react";
2020-04-23 09:15:27 +02:00
import { Project } from "../../models/project";
2020-07-09 13:00:42 +02:00
import { getTaskCategoriesMeanRepartition } from "../../util/stat";
2020-04-23 09:15:27 +02:00
export interface RepartitionPreviewProps {
project: Project
}
2020-07-09 13:00:42 +02:00
const RepartitionPreview: FunctionComponent<RepartitionPreviewProps> = ({ project }) => {
const repartition = getTaskCategoriesMeanRepartition(project);
2020-04-23 09:15:27 +02:00
return (
2020-07-09 13:00:42 +02:00
<div className="table-container">
<table className="table is-bordered is-striped is-fullwidth">
2020-04-23 09:15:27 +02:00
<thead>
<tr>
<th colSpan={2}>Répartition moyenne</th>
2020-04-23 09:15:27 +02:00
</tr>
<tr>
<th>Catégorie</th>
<th>Temps (en %)</th>
2020-04-23 09:15:27 +02:00
</tr>
</thead>
<tbody>
{
Object.values(project.params.taskCategories).map(tc => {
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>
<td>{percent} %</td>
2020-04-23 09:15:27 +02:00
</tr>
);
})
}
</tbody>
</table>
</div>
);
};
export default RepartitionPreview;