Added graphs, fixed rps total calculation
This commit is contained in:
@@ -84,7 +84,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
|
||||
dataSource={joblines}
|
||||
scroll={{
|
||||
x: true,
|
||||
//y: "40rem"
|
||||
y: "20rem",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,28 +1,15 @@
|
||||
import { Skeleton, Space, Statistic } from "antd";
|
||||
import { Skeleton, Statistic } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import React, { useMemo } from "react";
|
||||
import ErrorResultAtom from "../../atoms/error-result/error-result.atom";
|
||||
import TargetPriceDiffPcAtom from "../../atoms/target-price-diff/target-price-diff-pc.atom";
|
||||
import _ from "lodash";
|
||||
import Dinero from "dinero.js";
|
||||
|
||||
export default function JobsTargetsStatsMolecule({ loading, job }) {
|
||||
const currentRpsPc = useMemo(() => {
|
||||
if (!job) {
|
||||
return 0;
|
||||
}
|
||||
return (
|
||||
(_.sum(job.joblines.map((jl) => jl.price_diff_pc)) /
|
||||
job.joblines.length) *
|
||||
100
|
||||
).toFixed(1);
|
||||
}, [job]);
|
||||
|
||||
const currentRpsDollars = useMemo(() => {
|
||||
if (!job) {
|
||||
return 0;
|
||||
}
|
||||
return job.joblines.reduce((acc, val) => {
|
||||
console.log("val.price_diff :>> ", val.price_diff);
|
||||
if (val.price_diff > 0) {
|
||||
return acc.add(
|
||||
Dinero({ amount: Math.round((val.price_diff || 0) * 100) })
|
||||
@@ -33,6 +20,17 @@ export default function JobsTargetsStatsMolecule({ loading, job }) {
|
||||
}, Dinero());
|
||||
}, [job]);
|
||||
|
||||
const currentRpsPc = useMemo(() => {
|
||||
//TODO Redo this to do total of db price - act price / db price
|
||||
if (!job) {
|
||||
return 0;
|
||||
}
|
||||
const dbPriceSum = job.joblines.reduce((acc, val) => {
|
||||
return acc + val.db_price;
|
||||
}, 0);
|
||||
return (currentRpsDollars.getAmount() / dbPriceSum).toFixed(1);
|
||||
}, [job, currentRpsDollars]);
|
||||
|
||||
if (loading) return <Skeleton active />;
|
||||
if (!job) return <ErrorResultAtom title="Error displaying job data." />;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user