IO-2239 Added totals on cards in job scoreboards

This commit is contained in:
swtmply
2023-04-12 03:13:19 +08:00
parent a3375e6152
commit f3714cea1e
3 changed files with 52 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { useTranslation } from "react-i18next";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
@@ -13,6 +14,7 @@ const mapDispatchToProps = (dispatch) => ({
export function ScoreboardDayStats({ bodyshop, date, entries }) {
const { dailyPaintTarget, dailyBodyTarget } = bodyshop.scoreboard_target;
const { t } = useTranslation();
//let totalHrs = 0;
const paintHrs = entries.reduce((acc, value) => {
@@ -41,6 +43,10 @@ export function ScoreboardDayStats({ bodyshop, date, entries }) {
label="P"
value={paintHrs.toFixed(1)}
/>
<Statistic
title={t("general.labels.total")}
value={(bodyHrs + paintHrs).toFixed(1)}
/>
</Card>
);
}