Skip to content

Commit 62660e2

Browse files
committed
cleanup cost estimator
1 parent 6aa3088 commit 62660e2

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

stormpiper/stormpiper/spa/src/components/cost-analysis/cost-summary.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { styled } from "@mui/material/styles";
1111
import AutorenewIcon from "@mui/icons-material/Autorenew";
1212

13-
import { api_fetch } from "../../utils/utils";
13+
import { api_fetch, moneyFormatter } from "../../utils/utils";
1414
const CostTimeseriesChart = lazy(() => import("./cost-timeseries-chart"));
1515

1616
const Item = styled(Paper)(({ theme }) => ({
@@ -21,12 +21,6 @@ const Item = styled(Paper)(({ theme }) => ({
2121
color: theme.palette.text.secondary,
2222
}));
2323

24-
function moneyFormatter(val) {
25-
if (val == null) return "--";
26-
const n = Math.round(val).toLocaleString();
27-
return `$${n}`;
28-
}
29-
3024
function CostDetails({ tmntDetails }) {
3125
const data = [
3226
{

stormpiper/stormpiper/spa/src/components/cost-estimator/kc-estimator.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import {
99
Grid,
1010
Paper,
1111
} from "@mui/material";
12+
import { moneyFormatter } from "../../utils/utils";
1213

1314
import KCdata from "../../assets/data/kc_cost_table.json";
1415

1516
const TACOMA_TYPES = [...new Set(KCdata.map((k) => k.tacoma_type))];
16-
const TACOMA_TYPE_OPTIONS = TACOMA_TYPES.map((k) => {
17-
return { value: k, label: k };
18-
});
17+
const TACOMA_TYPE_OPTIONS = TACOMA_TYPES.sort()
18+
.filter((k) => !["none", "--"].includes(Object(k).toString().toLowerCase()))
19+
.map((k) => {
20+
return { value: k, label: k };
21+
});
1922
const KC_VARIATIONS = [...new Set(KCdata.map((k) => k.description))];
2023
const KC_VARIATION_OPTIONS = KC_VARIATIONS.map((k) => {
2124
return { value: k, label: k, bold: false };
@@ -238,7 +241,7 @@ export default function KCCostEstimator({ initialBMPType, getResult }) {
238241
<Grid item key={index} xs={1}>
239242
<Item>
240243
<Typography fontWeight="bold"> {d.title} </Typography>
241-
<Typography> {`${value}`} </Typography>
244+
<Typography> {`${moneyFormatter(value)}`} </Typography>
242245
</Item>
243246
</Grid>
244247
);

stormpiper/stormpiper/spa/src/utils/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ export const strFormatter = (params) => {
105105
return params.value.replace("_simple", "").replaceAll("_", " ");
106106
};
107107

108+
export const moneyFormatter = (val) => {
109+
if (val == null) return "--";
110+
const n = Math.round(val).toLocaleString();
111+
return `$${n}`;
112+
};
113+
108114
export const toValidHtmlId = (str) => {
109115
// Convert to lowercase
110116
let validId = String(str).toLowerCase();

0 commit comments

Comments
 (0)