diff --git a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx
index 9b96febaf..bffc9cfcb 100644
--- a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx
+++ b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx
@@ -1,12 +1,14 @@
import { CalendarOutlined } from "@ant-design/icons";
import { Card, Col, Row, Statistic } from "antd";
-import React from "react";
+import React, { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import ScoreboardJobsList from "../scoreboard-jobs-list/scoreboard-jobs-list.component";
import * as Util from "./scoreboard-targets-table.util";
+import _ from "lodash";
+import moment from "moment";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -16,25 +18,78 @@ const mapDispatchToProps = (dispatch) => ({
});
const rowGutter = [16, 16];
-const statSpans = { xs: 24, sm: 6 };
+const statSpans = { xs: 24, sm: 3 };
export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) {
const { t } = useTranslation();
+ const values = useMemo(() => {
+ const dateHash = _.groupBy(scoreBoardlist, "date");
+ console.log(
+ "🚀 ~ file: scoreboard-targets-table.component.jsx ~ line 31 ~ values ~ dateHash",
+ dateHash
+ );
+
+ let ret = {
+ todayBody: 0,
+ todayPaint: 0,
+ weeklyPaint: 0,
+ weeklyBody: 0,
+ toDateBody: 0,
+ toDatePaint: 0,
+ };
+
+ const today = moment().tz(bodyshop.timezone);
+ if (dateHash[today.format("YYYY-MM-DD")]) {
+ dateHash[today.format("YYYY-MM-DD")].forEach((d) => {
+ ret.todayBody = ret.todayBody + d.bodyhrs;
+ ret.todayPaint = ret.todayPaint + d.painthrs;
+ });
+ }
+
+ let StartOfWeek = moment().tz(bodyshop.timezone).startOf("week");
+ while (StartOfWeek.isSameOrBefore(today)) {
+ if (dateHash[StartOfWeek.format("YYYY-MM-DD")]) {
+ dateHash[StartOfWeek.format("YYYY-MM-DD")].forEach((d) => {
+ ret.weeklyBody = ret.weeklyBody + d.bodyhrs;
+ ret.weeklyPaint = ret.weeklyPaint + d.painthrs;
+ });
+ }
+ StartOfWeek = StartOfWeek.add(1, "day");
+ }
+
+ let startOfMonth = moment().tz(bodyshop.timezone).startOf("month");
+ while (startOfMonth.isSameOrBefore(today)) {
+ if (dateHash[startOfMonth.format("YYYY-MM-DD")]) {
+ dateHash[startOfMonth.format("YYYY-MM-DD")].forEach((d) => {
+ ret.toDateBody = ret.toDateBody + d.bodyhrs;
+ ret.toDatePaint = ret.toDatePaint + d.painthrs;
+ });
+ }
+ startOfMonth = startOfMonth.add(1, "day");
+ }
+
+ return ret;
+ }, [scoreBoardlist, bodyshop.timezone]);
+ console.log(
+ "🚀 ~ file: scoreboard-targets-table.component.jsx ~ line 51 ~ values ~ values",
+ values
+ );
+
return (
\n\n