All files / src/pages/flowsheet-page/economics/cost-curves/authoring DiscreteVariantSummary.tsx

0% Statements 0/15
14.28% Branches 1/7
0% Functions 0/3
0% Lines 0/8

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                                                                                 
import { Label } from "@/ahuora-design-system/ui/label";
import type { CostCurveDraft } from "../model/payloads";
import { FieldError } from "../ui/FieldError";
 
export function DiscreteVariantSummary({
  variants,
  error,
}: {
  variants: CostCurveDraft["discrete_variants"];
  error?: string;
}) {
  return (
    <section className="grid gap-2" aria-label="Discrete curve candidates">
      <Label>Published curve candidates</Label>
      <div className="rounded-md border p-3 text-sm">
        {variants.length === 0 ? (
          <div className="text-muted-foreground">No candidates</div>
        ) : (
          <div className="grid gap-2">
            {variants.map((variant) => (
              <div
                key={variant.key}
                className="grid gap-1 border-b pb-2 last:border-b-0 last:pb-0"
              >
                <div className="font-medium">{variant.label}</div>
                <div className="text-xs text-muted-foreground">
                  {Object.entries(variant.selector_values)
                    .map(([key, value]) => `${key}: ${value}`)
                    .join(" | ")}
                </div>
                <code className="text-xs">{variant.expression_text}</code>
              </div>
            ))}
          </div>
        )}
      </div>
      <FieldError id="curve-discrete-variants-error" message={error} />
    </section>
  );
}