import { makeAutoObservable } from 'mobx';
import { apis } from '@/apis';
interface ChatState {
    QuestionList: string[];
}
const stateChat = (): ChatState => ({
    QuestionList: [],
});

const setStateChat = (state: ChatState) => ({
    setQuestionList: (list: string[]) => {
        state.QuestionList = list;
    },
});

const useStateChat = ()=>{
    const state = makeAutoObservable(stateChat());
    const actions = setStateChat(state);

    const fetchPresetsApi = async (appId: string) => {
        try {
            const res = await apis.getPresets(appId);
            if(res && Array.isArray(res)){
                actions.setQuestionList(res);
            }
        } catch (error) {
            console.error('Failed to fetch presets:', error);
        }
    };

    return {
        state,
        fetchPresetsApi,
    };
}
export default useStateChat;