import { OptionType } from '@/components/input/SelectInput';

export type ApprovalWorkflowStep = {
  step_number: number;
  step_name: string;
};

export type ApprovalWorkflow = {
  key: string;
  steps: ApprovalWorkflowStep[];
};

export type ProductFlagMappingOption = {
  flag: string;
  sub_flags: string[];
  allow_without_sub_flag: boolean;
};

export type ProductFlagMappingApiResponse = {
  flags: string[];
  options: ProductFlagMappingOption[];
  sub_flag_to_flag: Record<string, string>;
};

export type AdjustmentTransactionSubtypes = {
  RECORDING: string[];
  PENJUALAN: string[];
  PEMBELIAN: string[];
};

export type StockLogConfig = {
  log_types: string[];
  transaction_types: string[];
};

export type ConstantsApiResponse = {
  warehouse_types: string[];
  supplier_categories: string[];
  customer_supplier_types: string[];
  adjustment: {
    transaction_subtypes: AdjustmentTransactionSubtypes;
  };
  approval_workflows: ApprovalWorkflow[];
  flags: string[];
  product_flag_mapping: ProductFlagMappingApiResponse;
  legacy_flag_aliases: Record<string, string>;
  stock_log: StockLogConfig;
};

export type ProductFlagMappingItem = {
  flag: OptionType;
  sub_flags: OptionType[];
  allow_without_sub_flag: boolean;
};

export type ProductFlagMapping = {
  flags: OptionType[];
  options: ProductFlagMappingItem[];
  sub_flag_to_flag: Record<string, string>;
};

export type TransformedApprovalWorkflow = {
  key: string;
  steps: OptionType[];
};

export type TransformedConstants = {
  warehouse_types: OptionType[];
  supplier_categories: OptionType[];
  customer_supplier_types: OptionType[];
  adjustment: {
    transaction_subtypes: {
      RECORDING: OptionType[];
      PENJUALAN: OptionType[];
      PEMBELIAN: OptionType[];
    };
  };
  approval_workflows: TransformedApprovalWorkflow[];
  flags: OptionType[];
  product_flag_mapping: ProductFlagMapping;
  legacy_flag_aliases: OptionType[];
  stock_log: {
    log_types: OptionType[];
    transaction_types: OptionType[];
  };
};
