import { Machine, Operator } from "@/app/api/jo";

export interface OperatorQrCode {
  username: string;
}

export interface MachineQrCode {
  id?: string;
  code: string;
  name?: string;
}

export interface Material {
  id: number;
  name: string;
  isUsed: boolean;
  lotNumbers: string[];
  required: boolean;
}

export interface MaterialDatabase {
  name: string;
  lotPattern: RegExp;
  required: boolean;
}

export interface FormData {
  productionDate: string;
  notes: string;
  operators: Operator[];
  machines: Machine[];
  materials: Material[];
}

export interface ProductionRecord extends FormData {
  timestamp: string;
}

export interface ValidationRule {
  required?: boolean;
  message?: string;
  custom?: (value: any, allValues?: any) => string | null;
}

export interface ValidationRules {
  [key: string]: ValidationRule;
}

export interface ProcessData {
  id: string;
  processName: string;
  status: "Not Started" | "In Progress" | "Completed";
  recordedData?: any; // You can type this based on your actual data structure
  materials: Material[];
}

/// QC related, will be moved to api level when fetching from backend
export interface QualityCheckItem {
  id: number;
  code: string;
  name: string;
  description: string;
  category?: string;
}

export interface QualityCheckData {
  inspectors: Operator[];
  checkDate: string;
  status: "pending" | "passed" | "failed";
  notes: string;
  defects: QualityCheckItem[];
}

export interface QualityCheckRecord extends QualityCheckData {
  itemId?: string;
  itemName?: string;
  timestamp: string;
}

export interface QualityCheckModalProps {
  isOpen: boolean;
  onClose: () => void;
  item?: QualityCheckItem | null;
}

export interface QualityCheckModalFormProps {
  item?: QualityCheckItem | null;
}

export interface DefectsSectionProps {
  defects: QualityCheckItem[];
  onDefectsChange: (defects: QualityCheckItem[]) => void;
  error?: string;
}
