All files / src/pages/flowsheet-page/flowsheet/LeftSideBar/Scenarios useCurrentScenario.ts

100% Statements 10/10
100% Branches 4/4
100% Functions 3/3
100% Lines 9/9

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      33x 11430x 11430x 11430x 11430x 11430x     33x 6583x 6583x  
import { useScenarios } from "./useScenarios";
import { useSearchParam } from "../../../../../hooks/searchParams";
 
export const useCurrentScenario = () => {
  const scenarios = useScenarios();
  const [_scenarioNumber] = useSearchParam("scenario");
  const scenarioNumber = _scenarioNumber ? +_scenarioNumber : undefined;
  const scenario = scenarios?.find((scenario) => scenario.id == scenarioNumber);
  return scenario
};
 
export const useRatingMode = () => {
  const scenario = useCurrentScenario();
  return scenario?.enable_rating || false;
};