import { FormControl } from '@angular/forms';
import { ColumnDefinition, PageLinks, PageMeta } from './shared.model';
import { Brand, Category, Packaging, Profile, Tag } from '.';

export interface Product {
    id: number;
    slug: string;
    eancode: string;
    name: string;
    description: string;
    stock: number;
    weightGross?: number;
    weightNet?: number;
    priceBuy?: number;
    priceRetail?: number;
    priceTaxe?: number;
    tags?: Tag[];
    brand: Brand;
    packaging: Packaging;
    owner: Profile;
    productCategories: Category[];
    createdAt: string;
    updatedAt: string;
    isSelected?: boolean;
}

export interface ProductForm {
    slug: FormControl<string>;
    eancode: FormControl<string>;
    name: FormControl<string>;
    description: FormControl<string>;
    stock: FormControl<number>;
    weightGross: FormControl<number>;
    weightNet: FormControl<number>;
    priceBuy: FormControl<number>;
    priceRetail: FormControl<number>;
    priceTaxe: FormControl<number>;
    tags: FormControl<Array<string>>;
    brandId: FormControl<number>;
    ownerId: FormControl<string>;
    packagingId: FormControl<number>;
}

export interface ProductPageData {
    product: Product;
    _links: PageLinks;
    _meta: PageMeta;
}

export interface ProductsPageData {
    products: Array<Product>;
    count: number;
    category?: Category;
    _links: PageLinks;
    _meta: PageMeta;
}


export const productColumns: Array<ColumnDefinition> = [
    {
        key: 'isSelected',
        type: 'isSelected',
        label: ''
    },
    {
        key: 'name',
        type: 'text',
        label: 'Libellé',
        required: true
    },
    {
        key: 'eancode',
        type: 'text',
        label: 'Code EAN13',
        required: true
    },
    {
        key: 'stock',
        type: 'numeric',
        label: 'Stock',
        required: true,
        min: 0,
        step: 1
    },
    {
        key: 'weightGross',
        type: 'numeric',
        label: 'Poid brut',
        min: 0,
        step: 1
    },
    {
        key: 'weightNet',
        type: 'numeric',
        label: 'Poid net',
        min: 0,
        step: 1
    },
    {
        key: 'priceBuy',
        type: 'numeric',
        label: 'Prix achat',
        min: 0,
        step: 1
    },
    {
        key: 'priceRetail',
        type: 'numeric',
        label: 'Prix vente',
        min: 0,
        step: 1
    },
    {
        key: 'priceTaxe',
        type: 'numeric',
        label: 'TVA',
        min: 0,
        step: 1
    },
    {
        key: 'tags',
        type: 'text',
        label: 'Tags'
    }
];