Skip to content

Commit

Permalink
Moved useRules
Browse files Browse the repository at this point in the history
  • Loading branch information
seanrathier committed Oct 31, 2024
1 parent ec7bf0d commit 6b90fb1
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ interface RulesContextValue {
const RulesContext = createContext<RulesContextValue | undefined>(undefined);
const MAX_ITEMS_PER_PAGE = 10000;

export function useRules() {
const context = useContext(RulesContext);
if (context === undefined) {
throw new Error('useRules must be used within a RulesProvider');
}
return context;
}

export function RulesProvider({ children }: RulesProviderProps) {
const params = useParams<PageUrlParams>();
const { pageSize, setPageSize } = usePageSize(LOCAL_STORAGE_PAGE_SIZE_RULES_KEY);
Expand Down Expand Up @@ -329,14 +337,6 @@ const getRulesPageData = (
};
};

export function useRules() {
const context = useContext(RulesContext);
if (context === undefined) {
throw new Error('useRules must be used within a RulesProvider');
}
return context;
}

const getRulesWithStates = (
data: FindCspBenchmarkRuleResponse | undefined,
rulesStates: ReturnType<typeof useCspGetRulesStates>
Expand Down

0 comments on commit 6b90fb1

Please sign in to comment.