BOD-20 added onclick to production schedule + parts totals.
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user