import { FormCategory, FormContent, IBreadcrumbItem, IModule, ISchema } from "@ax/types";
import {
	SET_BREADCRUMB,
	SET_COPY_MODULE,
	SET_CURRENT_FORM_ID,
	SET_FORM_CONTENT,
	SET_FORMS,
	SET_SCHEMA,
	SET_SELECTED_CONTENT,
	SET_SELECTED_EDITOR_ID,
	SET_SELECTED_PARENT,
	SET_TAB,
	SET_TEMPLATE,
	SET_SUMMARY,
	SET_CURRENT_FORM_CATEGORIES,
	SET_IS_NEW_TRANSLATION,
	SET_IS_IA_TRANSLATED,
} from "./constants";

export interface ISetForms {
	type: typeof SET_FORMS;
	payload: { forms: FormContent[] };
}

export interface ISetFormContent {
	type: typeof SET_FORM_CONTENT;
	payload: { formContent: FormContent | null };
}

export interface ISetSchema {
	type: typeof SET_SCHEMA;
	payload: { schema: ISchema | Record<string, never> };
}

export interface ISetTemplate {
	type: typeof SET_TEMPLATE;
	payload: { template: string };
}

export interface ISetTab {
	type: typeof SET_TAB;
	payload: { tab: string };
}

export interface ISetSelectedContent {
	type: typeof SET_SELECTED_CONTENT;
	payload: { selectedContent: Record<string, unknown> };
}

export interface ISetSelectedParent {
	type: typeof SET_SELECTED_PARENT;
	payload: { selectedParent: Record<string, unknown> | null };
}

export interface ISetSelectedEditorID {
	type: typeof SET_SELECTED_EDITOR_ID;
	payload: { selectedEditorID: number };
}

export interface ISetCurrentFormID {
	type: typeof SET_CURRENT_FORM_ID;
	payload: { currentFormID: number | null };
}

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

export interface ISetCopyModule {
	type: typeof SET_COPY_MODULE;
	payload: { moduleCopy: { date: Date; elements: IModule[] } | null };
}

export interface ISetSummary {
	type: typeof SET_SUMMARY;
	payload: { summary: { total: number; active: number; inactive: number } };
}

export interface ISetCurrentFormCategories {
	type: typeof SET_CURRENT_FORM_CATEGORIES;
	payload: { currentFormCategories: FormCategory[] };
}

export interface ISetIsNewTranslation {
	type: typeof SET_IS_NEW_TRANSLATION;
	payload: { isNewTranslation: boolean };
}

export interface ISetIsIATranslated {
	type: typeof SET_IS_IA_TRANSLATED;
	payload: { isIATranslated: boolean };
}

export type FormsActionsCreators = ISetForms;
