import { useOptions as useOptionsQuery } from './useConfig';
import { OptionsConfig } from '@/types';

type OptionKey = keyof OptionsConfig;

export function useOptions() {
    const { data: options, isLoading: loading, error } = useOptionsQuery();

    const getOptionsList = (key: OptionKey, lang: 'zh' | 'en' = 'zh'): string[] => {
        if (!options) return [];
        return options[key]?.[lang] || [];
    };

    return {
        options,
        loading,
        error: error ? (error as Error).message : null,
        getOptionsList
    };
}
