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

48.27% Statements 14/29
43.47% Branches 10/23
66.66% Functions 2/3
47.82% Lines 11/23

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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79          2x                         2x                                                         4x               4x               4x 2x 4x     6x 4x       12x   12x      
import { AlertCircle, CircleDollarSign } from "lucide-react";
import { Skeleton } from "@/ahuora-design-system/ui/skeleton-t";
import { Spinner } from "@/ahuora-design-system/ui/spinner";
import { CreateEconomicsStudyButton } from "../actions";
 
export function EconomicsLoadingState() {
  return (
    <div
      className="flex h-full items-center justify-center"
      aria-label="Loading economics studies"
    >
      <div className="space-y-3 text-center">
        <Spinner size="medium" />
        <div className="text-sm text-muted-foreground">
          Loading economics studies
        </div>
      </div>
      <Skeleton className="sr-only" />
    </div>
  );
}
 
export function EconomicsErrorState({ status }: { status?: string }) {
  const isPermissionError = status === "403";
  return (
    <div
      className="flex h-full items-center justify-center p-6"
      role="alert"
      aria-label="Economics loading error"
    >
      <div className="max-w-md rounded-md border bg-card p-5">
        <div className="mb-2 flex items-center gap-2 text-sm font-semibold">
          <AlertCircle className="size-4 text-destructive" />
          {isPermissionError
            ? "Economics unavailable"
            : "Could not load economics"}
        </div>
        <p className="text-sm text-muted-foreground">
          {isPermissionError
            ? "You do not have access to economics studies for this flowsheet."
            : "The economics workspace could not load study data."}
        </p>
      </div>
    </div>
  );
}
 
export function EconomicsEmptyState({
  canEdit,
  onStudyCreated,
}: {
  canEdit: boolean;
  onStudyCreated?: (studyId: number) => void;
}) {
  return (
    <div
      className="flex h-full items-center justify-center p-6"
      aria-label="No economics studies"
    >
      <div className="max-w-md rounded-md border bg-card p-5">
        <div className="mb-2 flex items-center gap-2 text-sm font-semibold">
          <CircleDollarSign className="size-4 text-primary" />
          No economics studies
        </div>
        <p className="text-sm text-muted-foreground">
          {canEdit
            ? "Start an economics study for this flowsheet."
            : "No economics studies are available in this read-only flowsheet."}
        </p>
        {canEdit && (
          <div className="mt-4">
            <CreateEconomicsStudyButton onCreated={onStudyCreated} />
          </div>
        )}
      </div>
    </div>
  );
}