import { BaseMetadata } from '@/types/api/api-general';
import { Uom } from '@/types/api/master-data/uom';
import { ProductCategory } from '@/types/api/master-data/product-category';
import { BaseSupplier } from '@/types/api/master-data/supplier';

export type BaseProduct = {
  id: number;
  name: string;
  brand: string;
  sku?: string;
  product_price: number;
  selling_price?: number;
  tax?: number;
  expiry_period?: number;
  uom: Uom;
  product_category: ProductCategory;
  suppliers: (BaseSupplier & { price: number })[];
  flag: string;
  sub_flag?: string;
  sub_flags?: string[];
  flags?: string[];
};

export type Product = BaseMetadata & BaseProduct;

export type CreateProductPayload = {
  name: string;
  brand: string;
  sku?: string;
  uom_id: number;
  product_category_id: number;
  product_price: number;
  selling_price?: number;
  tax?: number;
  expiry_period?: number;
  suppliers: {
    supplier_id: number;
    price: number;
  }[];
  flag: string;
  sub_flags?: string[];
};

export type UpdateProductPayload = CreateProductPayload;
