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 | 33x 1824x 1824x 1824x 1824x 685x 674x 11x | import { StateNameEnum, useCoreScenarioRetrieveQuery } from "@/api/apiStore.gen";
import { useSearchParam } from "../../../hooks/searchParams";
import ResultSheet from "./ResultSheet";
import { Button } from "@/ahuora-design-system/ui/button";
import { ChevronDown, ChevronUp } from "lucide-react";
import { useLocalStorage } from "usehooks-ts";
import { cn } from "@/lib/utils";
const ScenarioResult = () => {
const [scenarioId] = useSearchParam("scenario");
const { data: scenario } = useCoreScenarioRetrieveQuery({ id: Number(scenarioId) }, { skip: !scenarioId });
const [open, setOpen] = useLocalStorage('scenario-result-open', false);
if (!scenario || !scenarioId || scenario.state_name == StateNameEnum.SteadyState) return null;
if (open) {
return (
<div className="h-[50%] absolute bottom-0 left-0 w-full z-10 bg-background flex">
<Button
variant="secondary"
size="sm"
className={
cn(
"select-none bg-background rounded-full",
"absolute top-[-35px] left-1/2 -translate-x-1/2 z-1"
)
}
onClick={() => setOpen(false)}
>
<p>Close</p>
<ChevronDown />
</Button>
<ResultSheet scenario={scenario} />
</div>
);
} else {
return (
<div className="absolute w-full flex justify-center bottom-1 left-0 z-1">
<Button
variant="secondary"
size="sm"
className={
cn(
"select-none bg-background rounded-full",
"absolute bottom-1 left-1/2 -translate-x-1/2 z-1"
)
} onClick={() => setOpen(true)}
>
<p>Scenario results</p>
<ChevronUp />
</Button>
</div>
)
}
};
export default ScenarioResult;
|