All files / src/pages/flowsheet-page/economics/cost-items-panel/unit-costs/category-group DriverInputsSummary.tsx

0% Statements 0/22
9.09% Branches 1/11
0% Functions 0/3
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                         
import type {
  BulkEquipmentSetupResult,
  CapitalCostLineRead,
  CostCurveRead,
} from "@/api/apiStore.gen";
import { requiredDriverSpecsFromCurve } from "../../../cost-curves/model/driverSpecs";
import { generatedCapitalLineForCostableItem } from "../../model/capitalLineHelpers";
import type { UnitCostRow } from "../../model/capitalLineTypes";
import {
  currentCostDriverLabel,
  currentDriverInputLabel,
  driverInputResultLabel,
} from "./bulkSetupHelpers";
 
export function DriverInputsSummary({
  row,
  selectedCurve,
  capitalLines,
  previewResult,
}: {
  row: UnitCostRow;
  selectedCurve?: CostCurveRead;
  capitalLines: CapitalCostLineRead[];
  previewResult?: BulkEquipmentSetupResult;
}) {
  const specs = requiredDriverSpecsFromCurve(selectedCurve);
  if (specs.length === 0) {
    return (
      <span className="truncate">
        {currentCostDriverLabel(row, capitalLines)}
      </span>
    );
  }
  const capitalLine = generatedCapitalLineForCostableItem(
    capitalLines,
    row.costableItem,
  );
  return (
    <div className="grid gap-1">
      {specs.map((spec) => {
        const result = previewResult?.driver_input_results?.[spec.key];
        return (
          <div
            key={spec.key}
            className="grid min-w-0 grid-cols-[minmax(5rem,0.65fr)_minmax(7rem,1fr)] gap-2"
          >
            <span className="min-w-0 truncate font-medium text-foreground">
              {spec.label}
            </span>
            <span className="min-w-0 truncate">
              {result
                ? driverInputResultLabel(result)
                : currentDriverInputLabel(capitalLine, spec)}
            </span>
          </div>
        );
      })}
    </div>
  );
}