All files / packages/app/features/receipt-components context.ts

83.33% Statements 10/12
50% Branches 2/4
100% Functions 2/2
83.33% Lines 10/12

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                  88x       88x 31376x 31376x     31376x     88x       88x 73398x 73398x     73398x    
import React from "react";
 
import type {
	ReceiptContext as ReceiptContextType,
	useActionHooks,
} from "~app/features/receipt/hooks";
 
export type ActionsHooksContextType = ReturnType<typeof useActionHooks>;
 
export const ActionsHooksContext = React.createContext<
	ActionsHooksContextType | undefined
>(undefined);
 
export const useActionsHooksContext = () => {
	const context = React.use(ActionsHooksContext);
	Iif (!context) {
		throw new Error("Expected to have receipt actions hooks context!");
	}
	return context;
};
 
export const ReceiptContext = React.createContext<
	ReceiptContextType | undefined
>(undefined);
 
export const useReceiptContext = () => {
	const context = React.use(ReceiptContext);
	Iif (!context) {
		throw new Error("Expected to have receipt context!");
	}
	return context;
};