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

73.33% Statements 11/15
66.66% Branches 8/12
75% Functions 3/4
75% Lines 6/8

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      34432x 34432x 34432x 34432x 39548x         21400x      
import { useSearchParam } from "../../../../../hooks/searchParams";
import { useScenarios } from "./useScenarios";
 
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;
};