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 | 49x 5821x 5821x 5821x 5821x 4964x 857x 804x 53x 2x | import { ChevronDown, ChevronUp } from "lucide-react";
import { useLocalStorage } from "usehooks-ts";
import { Button } from "@/ahuora-design-system/ui/button";
import {
StateNameEnum,
useCoreScenarioRetrieveQuery,
} from "@/api/apiStore.gen";
import { cn } from "@/lib/utils";
import { useSearchParam } from "../../../hooks/searchParams";
import ResultSheet from "./ResultSheet";
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;
|