import { ModifyDocumentApiParams } from '@/apis';

export type Record = {
    [x: string]: any;
    documentId: string,
    knowledgeId: string,
    name: string,// 知识文件名称
    createTime: string,// 创建时间
    updateTime: string,// 更新时间
};

// 定义状态
export type State = {
    listLoading: boolean,
    list: Record[],
    infoModalId: string,
    infoModalOpen: boolean,
    page: {
        pageNum: number,
        pageSize: number,
        total: number,
    },
};

// 只读状态
export type ReadonlyState = Readonly<State>;

// 修改状态
export type StateAction = {
    setListLoading: (loading: State['listLoading']) => void,
    setList: (list: State['list']) => void,
    setInfoModalId: (id: State['infoModalId']) => void,
    setInfoModalOpen: (open: State['infoModalOpen']) => void,
    setPage: (page: State['page']) => void,
};

// 仓库类型
export type DocumentLibListStore = {
    state: ReadonlyState,
    onChangePagination: (pageNum: number, pageSize: number) => Promise<any>,
    onClickCreate: () => void,
    onClickModify: (documentId: string) => void,
    onClickfetchTakaiApplicationDetail: (appId: string) => void,
    infoModalOnClickConfirm: (documentId: string, userId: string, data: ModifyDocumentApiParams) => Promise<any>,
    infoModalOnClickCancel: (documentId: string, userId: string, data: ModifyDocumentApiParams) => Promise<any>,
    infoModalOnClickClose:  () => void,
    init: (userId: string) => Promise<any>,
    reset: () => void,
};