export interface RefinerState {
    id?: string;
    filterPanelMode?: string;
    filterPanelLayout?: any;
    isFiltered?: boolean;
}

interface iSetTransforms {
    (transform: any): void;
}

interface iSetIsFiltered {
    (isFiltered: boolean): void;
}

export interface RefinerProps {
    config?: any;
    data?: any;
    setTransforms?: iSetTransforms;
    transforms?: any;
    hasRowLevels?: boolean;
    isSelectionColumn?: boolean;
    isSelected?: boolean;
    isIndeterminate?: boolean;
    onSelectionClick?: any;
    preSort?: string; // if column has already sorted data (ASC, DESC)
    transformsDelay?: number;
    setIsFiltered?: iSetIsFiltered;
    displayDefaultLabel?: boolean;
    componentHeadId?: number;
}

export interface SummaryColumnProps {
    config?: any;
}

/**
 * Make a copy of the transforms object.
 * @param transforms
 */
export function copyTransforms(transforms) {
    let filter,
        newTransforms: any = {
            filters: {},
        };
    if (transforms.order) {
        newTransforms.order = Object.assign({}, transforms.order);
    }

    if (transforms.filters) {
        for (const filterColumn in transforms.filters) {
            if (
                Object.prototype.hasOwnProperty.call(
                    transforms.filters,
                    filterColumn
                )
            ) {
                filter = transforms.filters[filterColumn];
                newTransforms.filters[filterColumn] = Object.assign({}, filter);
            }
        }
    }

    return newTransforms;
}
