import { _attributes } from 'src/_mock/_data';

export type Type = 'BOOLEAN' | 'DATE' | 'TIME' | 'DATETIME' | 'VARCHAR' | 'INTEGER' | 'DECIMAL';

export const filterTypes: Type[] = [
    'BOOLEAN',
    'DATE',
    'TIME',
    'DATETIME',
    'VARCHAR',
    'INTEGER',
    'DECIMAL'
];

export type AttributeCreateDto = {
    label?: string | undefined;
    name: string;
    type: Type;
};

export type Attribute = AttributeCreateDto & {
    id: number;
};

export function getAttributes(): Promise<Attribute[]> {
    return Promise.resolve(_attributes);
}

export function createAttributes(filter: AttributeCreateDto): Promise<Attribute> {
    const newFilter: Attribute = {
        ...filter,
        id: _attributes.length + 1
    };
    _attributes.push(newFilter);
    return Promise.resolve(newFilter);
}