import type {
	SET_CATEGORIES,
	SET_STRUCTURED_DATA,
	SET_CURRENT_STRUCTURED_DATA,
	SET_CURRENT_STRUCTURED_DATA_ID,
	SET_CURRENT_STRUCTURED_DATA_CONTENTS,
	SET_SCHEMA,
	UPDATE_FORM,
	SET_FILTER,
	SET_SCHEMA_VERSION,
	SET_ERRORS,
	SET_VALIDATED,
	SET_CONTENT_FILTERS,
	SET_IS_IA_TRANSLATED,
	SET_CURRENT_DATA_CATEGORY,
	SET_CURRENT_SEARCH,
} from "./constants";

import type {
	IStructuredData,
	IStructuredDataContent,
	IErrorItem,
	IStructuredDataCategory,
	IQueryValue,
} from "@ax/types";

export interface ISetCategories {
	type: typeof SET_CATEGORIES;
	payload: { categories: { global: IStructuredData[]; site: IStructuredData[] } };
}

export interface ISetStructuredData {
	type: typeof SET_STRUCTURED_DATA;
	payload: { structuredData: { global: IStructuredData[]; site: IStructuredData[] } };
}

export interface ISetCurrentData {
	type: typeof SET_CURRENT_STRUCTURED_DATA;
	payload: { currentStructuredData: any };
}

export interface ISetCurrentDataID {
	type: typeof SET_CURRENT_STRUCTURED_DATA_ID;
	payload: { currentStructuredDataId: number | null };
}

export interface ISetSchema {
	type: typeof SET_SCHEMA;
	payload: { schema: any };
}
export interface ISetCurrentDataContent {
	type: typeof SET_CURRENT_STRUCTURED_DATA_CONTENTS;
	payload: { currentDataContent: IStructuredDataContent[] };
}

export interface ISetCurrentCategories {
	type: typeof SET_CURRENT_DATA_CATEGORY;
	payload: { currentDataCategory: IStructuredDataCategory[] };
}

export interface IUpdateForm {
	type: typeof UPDATE_FORM;
	payload: { value: any };
}

export interface ISetFilter {
	type: typeof SET_FILTER;
	payload: { currentFilter: string };
}

export interface ISetSchemaVersion {
	type: typeof SET_SCHEMA_VERSION;
	payload: { schemaVersion: string };
}

export interface ISetErrors {
	type: typeof SET_ERRORS;
	payload: { errors: IErrorItem[] };
}

export interface ISetValidated {
	type: typeof SET_VALIDATED;
	payload: { validated: boolean };
}

export interface ISetContentFilters {
	type: typeof SET_CONTENT_FILTERS;
	payload: { contentFilters: Record<string, Record<string, IQueryValue[]>> | null };
}

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

export interface ISetCurrentSearch {
	type: typeof SET_CURRENT_SEARCH;
	payload: { currentSearch: string };
}

export type CategoryActionsCreators = ISetCategories & ISetCurrentData;

export type StructuredDataActionsCreators = CategoryActionsCreators &
	ISetStructuredData &
	ISetCurrentData &
	ISetCurrentDataID &
	ISetCurrentDataContent &
	ISetCurrentCategories;
