import { IData, IIsLoading, IIsSaving } from "./reducer";
import {
	SET_DATA,
	SET_IS_LOADING,
	SET_IS_SAVING,
	SET_IS_UPLOADING,
	SET_UPLOAD_SUCCESS,
	SET_UPLOAD_ERROR,
	SET_DISPLAY_MODE,
	SET_SELECTED_TAB,
	SET_CURRENT_FOLDER_CONTENT,
	SET_CURRENT_FOLDER,
	SET_BREADCRUMB,
	SET_FOLDERS_TREE,
} from "./constants";
import { IFolderTree, IImageFolder } from "@ax/types";

export interface ISetData {
	type: typeof SET_DATA;
	payload: { data: IData };
}

export interface ISetIsLoading {
	type: typeof SET_IS_LOADING;
	payload: { isLoading: IIsLoading };
}

export interface ISetIsSaving {
	type: typeof SET_IS_SAVING;
	payload: { isSaving: IIsSaving };
}

export interface ISetIsUploading {
	type: typeof SET_IS_UPLOADING;
	payload: { isUploading: boolean };
}

export interface ISetUploadSuccess {
	type: typeof SET_UPLOAD_SUCCESS;
	payload: { isUploading: boolean; isSuccess: boolean };
}

export interface ISetUploadError {
	type: typeof SET_UPLOAD_ERROR;
	payload: { isUploading: boolean; isError: boolean; errorMsg: string };
}

export interface ISetCurrentFolderContent {
	type: typeof SET_CURRENT_FOLDER_CONTENT;
	payload: { currentFolderContent: IImageFolder | null };
}

export interface ISetCurrentFolder {
	type: typeof SET_CURRENT_FOLDER;
	payload: { currentFolderID: number | null };
}

export interface ISetBreadcrumb {
	type: typeof SET_BREADCRUMB;
	payload: { breadcrumb: IFolderTree[] };
}

export interface ISetFoldersTree {
	type: typeof SET_FOLDERS_TREE;
	payload: { foldersTree: IFolderTree[] };
}

export interface ISetDisplayMode {
	type: typeof SET_DISPLAY_MODE;
	payload: { displayMode: "grid" | "list" };
}

export interface ISetSelectedTab {
	type: typeof SET_SELECTED_TAB;
	payload: { selectedTab: "site" | "global" };
}

export type GalleryActionsCreators =
	| ISetData
	| ISetIsLoading
	| ISetIsSaving
	| ISetIsUploading
	| ISetUploadSuccess
	| ISetUploadError
	| ISetCurrentFolderContent
	| ISetCurrentFolder
	| ISetBreadcrumb
	| ISetFoldersTree
	| ISetDisplayMode
	| ISetSelectedTab;
