| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { useContext, use } from "react";
- import { ConfigContext } from "@/providers/ConfigProvider";
- export function useStore(){
- const context = useContext(ConfigContext);
- if(!context){
- throw new Error(
- "useConfig must be used inside ConfigProvider"
- );
- }
- const {store} = context.config;
-
-
- return {
- store,
- setCurrentCurrency: context.setCurrentCurrency
- };
-
- }
- export function useCountries() {
- const context = useContext(ConfigContext);
- if (!context) {
- throw new Error(
- "useCountries must be used within ConfigProvider",
- );
- }
- return use(context.config.countriesPromise);
- }
- export function useCurrencyList() {
- const context = useContext(ConfigContext);
- if (!context) {
- throw new Error(
- "useCurrencyList must be used within ConfigProvider",
- );
- }
- return use(context.config.currenciesPromise);
- }
|