All files / libs/payout-definition/plans/views/hub/rule-designer/src/lib PlanHubRuleDesigner.context.ts

100% Statements 20/20
100% Branches 1/1
100% Functions 1/1
100% Lines 20/20

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 211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 1x 1x  
import { createContext, useContext } from 'react';
 
import { type CalculationType } from '@amalia/core/types';
import { assert } from '@amalia/ext/typescript';
 
interface PlanHubRuleDesignerContextType {
  planId: string;
  ruleId: string;
  calculationType: CalculationType;
}
 
const PlanHubRuleDesignerContext = createContext<PlanHubRuleDesignerContextType | null>(null);
 
export const usePlanHubRuleDesignerContext = () => {
  const context = useContext(PlanHubRuleDesignerContext);
  assert(context, 'Not in a PlanHubRuleDesignerContext');
  return context;
};
 
export const PlanHubRuleDesignerContextProvider = PlanHubRuleDesignerContext.Provider;