import { create } from 'zustand';

interface AuditHistoryState {
    listLoading: boolean;
    historyList: any[];
}

interface AuditHistoryActions {
    setListLoading: (loading: boolean) => void;
    setHistoryList: (list: any[]) => void;
}

export type AuditHistoryStore = AuditHistoryState & AuditHistoryActions & {
    fetchAuditHistory: (appId: string) => Promise<void>;
};

export const useAuditHistoryStore = create<AuditHistoryStore>((set) => ({
    listLoading: false,
    historyList: [],
    
    setListLoading: (loading) => set({ listLoading: loading }),
    
    setHistoryList: (list) => set({ historyList: list }),
    
    fetchAuditHistory: async (appId: string) => {
        set({ listLoading: true });
        try {
            // TODO: 调用 API 获取审核历史
            set({ historyList: [] });
        } catch (error) {
            console.error('获取审核历史失败:', error);
        } finally {
            set({ listLoading: false });
        }
    },
}));

export default useAuditHistoryStore;
