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 | 56x 56x 56x 56x 56x 56x 59x 59x 67x 56x 82x 56x 48x 56x 56x 59x 68x 2x 2x 138x 97x 2x 2x 152x 96x 584x | import { api, useEconomicsStudiesListQuery } from "@/api/apiStore.gen";
import { useFlowsheetAccess } from "@/hooks/flowsheetAccess";
import { useProjectId } from "@/hooks/project";
import { useSearchParam } from "@/hooks/searchParams";
import { useAppDispatch } from "@/store/hooks";
import { ECONOMICS_STUDY_PARAM } from "../navigation/economicsNavigation";
import { EconomicsShell } from "./EconomicsShell";
import {
type EconomicsLoadState,
queryErrorStatus,
selectedEconomicsStudyId,
} from "./model";
export default function EconomicsPage() {
const flowsheetId = useProjectId();
const access = useFlowsheetAccess();
const dispatch = useAppDispatch();
const [studyParam, setStudyParam] = useSearchParam(ECONOMICS_STUDY_PARAM);
const studiesQuery = useEconomicsStudiesListQuery(
{ flowsheet: flowsheetId },
{ skip: !flowsheetId },
);
const studies = studiesQuery.currentData ?? [];
const studiesLoading =
studiesQuery.isLoading ||
(studiesQuery.isFetching && studiesQuery.currentData == null);
const selectedStudyId = selectedEconomicsStudyId(studies, studyParam);
const state: EconomicsLoadState = studiesLoading
? "loading"
: studiesQuery.isError
? "error"
: studies.length === 0
? "empty"
: "ready";
return (
<EconomicsShell
studies={studies}
selectedStudyId={selectedStudyId}
state={state}
canEdit={access?.can_edit ?? true}
readOnly={access?.read_only ?? false}
errorStatus={queryErrorStatus(studiesQuery.error)}
onStudyChange={(studyId) => setStudyParam(String(studyId))}
onStudyRecalculated={() => {
studiesQuery.refetch();
dispatch(api.util.invalidateTags(["SimulationObjects", "properties"]));
}}
onStudyConfigurationChanged={() => studiesQuery.refetch()}
onStudyCreated={(studyId) => {
setStudyParam(String(studyId));
studiesQuery.refetch();
}}
onStudyDeleted={(deletedStudyId) => {
const nextStudy = studies.find((study) => study.id !== deletedStudyId);
setStudyParam(nextStudy ? String(nextStudy.id) : "");
}}
/>
);
}
export { EconomicsShell } from "./EconomicsShell";
|