BOD-20 added onclick to production schedule + parts totals.

This commit is contained in:
Patrick Fic
2020-04-27 15:08:37 -07:00
parent 2b19d1af0b
commit f04a6fc2af
25 changed files with 580 additions and 120 deletions

View File

@@ -0,0 +1,43 @@
import React, { useState } from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { Pie } from "@nivo/pie";
import { useTranslation } from "react-i18next";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
export function PartsStatusPie({ partsList }) {
const { t } = useTranslation();
//const [pieData, setPieData] = useState([]);
const result = partsList
? partsList.reduce((names, name) => {
const val = name || "?";
const count = names[val] || 0;
names[val] = count + 1;
return names;
}, {})
: {};
const pieData = Object.keys(result).map((i) => {
console.log("i", i);
return {
id: i,
label: i,
value: result[i],
};
});
const commonProperties = {
width: 250,
height: 250,
margin: { top: 40, right: 60, bottom: 40, left: 60 },
animate: true,
};
return <Pie {...commonProperties} data={pieData} innerRadius={0.5} />;
}
export default connect(mapStateToProps, null)(PartsStatusPie);