ConfigProvider.tsx 773 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use client";
  2. import {
  3. createContext,
  4. } from "react";
  5. import {CurrencyItem} from "@/types/currency/type";
  6. import { Country } from "@/types/checkout/type";
  7. export interface StoreConfig {
  8. storeName: string;
  9. defaultCurrency: string;
  10. defaultLocale: string;
  11. defaultChannel: string;
  12. }
  13. export interface AppConfig {
  14. currencies: CurrencyItem[];
  15. countries: Country[];
  16. store: StoreConfig;
  17. }
  18. export const ConfigContext = createContext<AppConfig|null>(null);
  19. export function ConfigProvider({
  20. config,
  21. children
  22. }:{
  23. config:AppConfig;
  24. children:React.ReactNode;
  25. }){
  26. return (
  27. <ConfigContext.Provider
  28. value={config}
  29. >
  30. {children}
  31. </ConfigContext.Provider>
  32. );
  33. }