import type { SourceType } from '../../third-party/entities/category.entity';

export type FulfillmentType = 'third_party_api' | 'local_only' | 'manual';
export type OrderFormFieldType =
  | 'text'
  | 'password'
  | 'phone'
  | 'number'
  | 'textarea'
  | 'select'
  | 'checkbox';

export type OrderFormFieldDto = {
  key?: string;
  label?: string;
  type?: OrderFormFieldType;
  required?: boolean;
  placeholder?: string | null;
  options?: Array<{ label?: string; value?: string }>;
};

export type CreateCatalogCategoryDto = {
  name?: string;
  sortOrder?: number;
  enabled?: boolean;
};

export type UpdateCatalogCategoryDto = {
  name?: string;
  sortOrder?: number;
  enabled?: boolean;
};

export type CreateCatalogProductDto = {
  categoryId?: string | null;
  name?: string;
  price?: number | string;
  coverUrl?: string | null;
  content?: string | null;
  stock?: number | null;
  salesLimit?: number | null;
  fulfillmentType?: FulfillmentType;
  afterSalesNote?: string | null;
  orderFormSchema?: OrderFormFieldDto[] | null;
  sortOrder?: number;
  enabled?: boolean;
};

export type UpdateCatalogProductDto = {
  categoryId?: string | null;
  name?: string;
  price?: number | string;
  coverUrl?: string | null;
  content?: string | null;
  stock?: number | null;
  salesLimit?: number | null;
  fulfillmentType?: FulfillmentType;
  afterSalesNote?: string | null;
  orderFormSchema?: OrderFormFieldDto[] | null;
  sortOrder?: number;
  enabled?: boolean;
};

export type UpdateEnabledDto = {
  enabled?: boolean;
};

export type CatalogListQuery = {
  page?: number;
  pageSize?: number;
  keyword?: string;
  sourceType?: SourceType | 'all';
  enabled?: string;
  categoryId?: string;
  remoteCategoryId?: string;
};
