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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 225x 225x 225x 225x 225x 337x 225x 5x 5x 421x 225x 225x 2475x 225x 256x 287x 225x 900x 198x 1413x 965x 675x | import { useMemo, useState } from "react";
import { ScrollArea } from "@/ahuora-design-system/ui/scroll-area";
import { Separator } from "@/ahuora-design-system/ui/separator";
import type { EconomicsStudyRead } from "@/api/apiStore.gen";
import {
EconomicsEmptyState,
EconomicsErrorState,
EconomicsHeader,
EconomicsLoadingState,
} from "./components";
import { EconomicsStudySurface } from "./EconomicsStudySurface";
import type { EconomicsLoadState } from "./model";
export type EconomicsShellProps = {
studies: EconomicsStudyRead[];
selectedStudyId?: number;
routeFlowsheetId?: number;
state: EconomicsLoadState;
canEdit?: boolean;
readOnly?: boolean;
isRevisionPreview?: boolean;
errorStatus?: string;
onStudyChange: (studyId: number) => void;
onStudyRecalculated?: () => void;
onStudyConfigurationChanged?: () => void;
onStudyCreated?: (study: EconomicsStudyRead) => void;
onStudyDeleted?: (studyId: number) => void;
};
export function EconomicsShell({
studies,
selectedStudyId,
routeFlowsheetId,
state,
canEdit = true,
readOnly = false,
isRevisionPreview = false,
errorStatus,
onStudyChange,
onStudyRecalculated,
onStudyConfigurationChanged,
onStudyCreated,
onStudyDeleted,
}: EconomicsShellProps) {
const [recalculationRefreshKey, setRecalculationRefreshKey] = useState(0);
const selectedStudy = useMemo(
() => studies.find((study) => study.id === selectedStudyId),
[studies, selectedStudyId],
);
const handleStudyRecalculated = () => {
setRecalculationRefreshKey((current) => current + 1);
onStudyRecalculated?.();
};
return (
<main
aria-label="Economics workspace"
className="h-full min-w-0 overflow-hidden bg-background"
data-testid="economics-shell"
>
<div className="flex h-full flex-col">
<EconomicsHeader
readOnly={readOnly}
state={state}
studies={studies}
selectedStudy={selectedStudy}
routeFlowsheetId={routeFlowsheetId}
canEdit={canEdit}
onStudyChange={onStudyChange}
onStudyCreated={onStudyCreated}
onStudyDeleted={onStudyDeleted}
onStudyRecalculated={handleStudyRecalculated}
/>
<Separator />
<ScrollArea
className="min-h-0 flex-1"
aria-label="Economics panel content"
>
{state === "loading" && <EconomicsLoadingState />}
{state === "error" && <EconomicsErrorState status={errorStatus} />}
{state === "empty" && (
<EconomicsEmptyState
canEdit={canEdit}
onStudyCreated={onStudyCreated}
/>
)}
{state === "ready" && selectedStudy && (
<EconomicsStudySurface
study={selectedStudy}
canEdit={canEdit}
isRevisionPreview={isRevisionPreview}
recalculationRefreshKey={recalculationRefreshKey}
onStudyConfigurationChanged={onStudyConfigurationChanged}
/>
)}
</ScrollArea>
</div>
</main>
);
}
|