- Show default stats instead of no stats if statisticsOrder object is not yet valid.
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -2,8 +2,7 @@ import React, { useMemo } from "react";
|
|||||||
import { Card, Statistic } from "antd";
|
import { Card, Statistic } from "antd";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { statisticsItems } from "./settings/defaultKanbanSettings.js";
|
import { statisticsItems, defaultKanbanSettings } from "./settings/defaultKanbanSettings.js";
|
||||||
|
|
||||||
export const StatisticType = {
|
export const StatisticType = {
|
||||||
HOURS: "hours",
|
HOURS: "hours",
|
||||||
AMOUNT: "amount",
|
AMOUNT: "amount",
|
||||||
@@ -154,7 +153,9 @@ const ProductionStatistics = ({ data, cardSettings, reducerData }) => {
|
|||||||
const sortedStatistics = useMemo(() => {
|
const sortedStatistics = useMemo(() => {
|
||||||
const statisticsMap = new Map(statistics.map((stat) => [stat.id, stat]));
|
const statisticsMap = new Map(statistics.map((stat) => [stat.id, stat]));
|
||||||
|
|
||||||
return (cardSettings?.statisticsOrder ? cardSettings.statisticsOrder : []).reduce((sorted, orderId) => {
|
return (
|
||||||
|
cardSettings?.statisticsOrder ? cardSettings.statisticsOrder : defaultKanbanSettings.statisticsOrder
|
||||||
|
).reduce((sorted, orderId) => {
|
||||||
const value = statisticsMap.get(orderId);
|
const value = statisticsMap.get(orderId);
|
||||||
if (value && value.value !== null) {
|
if (value && value.value !== null) {
|
||||||
sorted.push(value);
|
sorted.push(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user