All files / src/pages/flowsheet-page/economics/page/components StudyOverview.tsx

89.28% Statements 25/28
90% Branches 9/10
100% Functions 2/2
88.88% Lines 16/18

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        7x               5x     10x 5x 12x 12x 17x   12x 3x       10x 17x   17x       5x 10x   5x   10x      
import { Badge } from "@/ahuora-design-system/ui/badge";
import type { EconomicsStudyRead } from "@/api/apiStore.gen";
import { statusLabel } from "../model";
 
export function StudyOverview({
  study,
  canEdit,
}: {
  study: EconomicsStudyRead;
  canEdit: boolean;
}) {
  return (
    <section className="mb-4 min-w-0" aria-label="Economics study overview">
      <div className="mb-4 flex flex-wrap items-start justify-between gap-4 rounded-md border bg-card p-3">
        <div className="min-w-0">
          <h2 className="truncate text-sm font-semibold">{study.name}</h2>
          <p className="text-xs text-muted-foreground">
            {statusLabel(study.result_state.status)}
          </p>
        </div>
        <div className="flex flex-wrap items-start justify-end gap-2">
          <StatusBadge status={study.result_state.classification} />
          {!canEdit && (
            <Badge variant="secondary" size="xs" borderRadius="round">
              View only
            </Badge>
          )}
        </div>
      </div>
    </section>
  );
}
 
function StatusBadge({ status }: { status: string }) {
  const label = statusLabel(status);
  return (
    <Badge variant="secondary" size="xs" borderRadius="round">
      {label}
    </Badge>
  );
}