Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / payments / client-extensions / useChargebeeContext.tsx
blob939f119a89547beb4c1398fe91ffeec5ed6723c1
1 import { type MutableRefObject, createContext, useContext } from 'react';
3 import { ChargebeeEnabled } from '@proton/shared/lib/interfaces';
5 export type CalledKillSwitchString = 'called' | 'not-called';
7 export type ChargebeeContext = {
8     enableChargebeeRef: MutableRefObject<ChargebeeEnabled>;
9     calledKillSwitch: CalledKillSwitchString;
10     setCalledKillSwitch: (value: CalledKillSwitchString) => unknown;
13 export const PaymentSwitcherContext = createContext<ChargebeeContext>({
14     enableChargebeeRef: {
15         current: ChargebeeEnabled.CHARGEBEE_FORCED,
16     },
17     calledKillSwitch: 'not-called',
18     setCalledKillSwitch: () => {},
19 });
21 export const useChargebeeContext = () => {
22     return useContext(PaymentSwitcherContext);
25 export const useChargebeeEnabledCache = () => {
26     const chargebeeContext = useChargebeeContext();
27     return (): ChargebeeEnabled => chargebeeContext.enableChargebeeRef.current;