"use client";


import {
    createContext,
} from "react";

import {CurrencyItem} from "@/types/currency/type";
import { Country } from "@/types/checkout/type";



export interface StoreConfig {

    storeName: string;

    defaultCurrency: string;

    defaultLocale: string;
    
    defaultChannel: string;

    currentCurrency: string; // 货币码 e.g. USD GBP

    currentLocale: string;

    currentChannel: string;
}



export interface AppConfig {


    currencies: CurrencyItem[];


    countries: Country[];


    store: StoreConfig;

}

export const ConfigContext = createContext<AppConfig|null>(null);

export function ConfigProvider({
    config,
    children
}:{
    config:AppConfig;
    children:React.ReactNode;
}){
    return (
        <ConfigContext.Provider
            value={config}
        >
            {children}
        </ConfigContext.Provider>
    );
}



