
export interface Plant {
  id: number;
  type: string;
  variety: string;
  purchaseLocation: string;
  seedlingAge: number;
  seedlingHeight: number;
  plantingDate: string;
  healthStatus: 'good' | 'needs-attention' | 'dead';
  currentHeight?: number;
  photoUrl?: string;
  currentPhotoUrl?: string;
  estimatedRipeningStart?: number;
  estimatedRipeningEnd?: number;
  ripeningNotes?: string;
  notes: string;
  createdAt: string;
  updatedAt: string;
}

export interface PlantHistory {
  id: number;
  plantId: number;
  year: number;
  bloomingDate?: string;
  fruitingDate?: string;
  harvestDate?: string;
  currentHeight?: number;
  currentPhotoUrl?: string;
  createdAt: string;
  updatedAt: string;
}

export interface PlantObservation {
  id: number;
  plantId: number;
  date: string;
  title: string;
  observation: string;
  weatherConditions?: string;
  temperature?: number;
  photoUrl?: string;
  tags?: string;
  createdAt: string;
  updatedAt: string;
}

export interface HarvestRecord {
  id: number;
  plantId: number;
  date: string;
  quantity: number;
  unit: string;
  weight?: number;
  weightUnit?: string;
  notes: string;
  createdAt: string;
  updatedAt: string;
}

export interface HarvestProcessing {
  id: number;
  harvestId: number;
  processType: 'fresh' | 'frozen' | 'jam' | 'dried' | 'canned' | 'juice' | 'sauce' | 'pickled' | 'other';
  quantity: number;
  unit: string;
  processDate: string;
  expiryDate?: string;
  storageLocation?: string;
  notes?: string;
  createdAt: string;
  updatedAt: string;
}

export interface HarvestStock {
  id: number;
  processingId: number;
  currentQuantity: number;
  unit: string;
  lastUpdated: string;
  status: 'available' | 'consumed' | 'expired' | 'spoiled';
  notes?: string;
  createdAt: string;
  updatedAt: string;
}

export interface MaintenanceRecord {
  id: number;
  plantId: number;
  date: string;
  type: 'chemical' | 'fertilizer' | 'watering' | 'pruning' | 'transplanting' | 'other';
  description: string;
  amount?: string;
  fertilizerId?: number;
  chemicalId?: number;
  fertilizerName?: string;
  chemicalName?: string;
  isPlanned: boolean;
  isCompleted: boolean;
  createdAt: string;
  updatedAt: string;
}

export const taskTypes = [
  'general',
  'fertilizer',
  'chemical',
  'watering',
  'pruning',
  'transplanting',
  'harvesting',
  'other',
] as const;

//export type TaskType = typeof taskTypes[number];

export type TaskDraft = {
  plantId?: number;
  type?: TaskType;
  title: string;
  description: string;
  deadline: string;
  completed: boolean;
  fertilizerId?: number;
  chemicalId?: number;
};

export interface Task {
  id: number;
  plantId?: number;
  type?: 'general' | 'fertilizer' | 'chemical' | 'watering' | 'pruning' | 'transplanting' | 'harvesting' | 'other';
  title: string;
  description: string;
  deadline: string;
  completed: boolean;
  fertilizerId?: number;
  chemicalId?: number;
  fertilizerName?: string;
  chemicalName?: string;
  createdAt: string;
  updatedAt: string;
}

export interface PlantWithHistory extends Plant {
  history: PlantHistory[];
  harvests: HarvestRecord[];
  maintenance: MaintenanceRecord[];
}

export interface PlantStatistics {
  plantId: number;
  year: number;
  bloomingDates: string[];
  fruitingDates: string[];
  harvestDates: string[];
  totalHarvest: number;
  heightGrowth: number;
  maintenanceCount: {
    chemical: number;
    fertilizer: number;
    watering: number;
    pruning: number;
  };
  completedTasks: number;
  plannedTasks: number;
}

export interface Fertilizer {
  id: number;
  name: string;
  brand?: string;
  type: 'organic' | 'synthetic' | 'liquid' | 'granular' | 'slow-release';
  npkRatio?: string;
  description?: string;
  applicationRate?: string;
  frequency?: string;
  season?: string;
  notes?: string;
  createdAt: string;
  updatedAt: string;
}

export interface Chemical {
  id: number;
  name: string;
  brand?: string;
  type: 'pesticide' | 'herbicide' | 'fungicide' | 'insecticide' | 'miticide';
  activeIngredient?: string;
  concentration?: string;
  targetPests?: string;
  applicationMethod?: string;
  safetyPeriod?: number;
  notes?: string;
  createdAt: string;
  updatedAt: string;
}

export const HarvestUnits: Record<string, string> = {
  'kg': 'кг',
  'pieces': 'плоды',
  'bunches': 'пучки',
  'cups': 'чашки',
  'liters': 'литры'
};

export const PlantTitles: Record<string, string> = {
  'tree': 'дерево',
  'shrub': 'кустарник',
  'herb': 'зелень',
  'vegetable': 'овощи',
  'flower': 'цветы',
  'grass': 'трава',
  'other': 'другое'
};

export const Conditions: Record<string, string> = {
  'good': 'хорошее',
  'needs-attention': 'требует внимания',
  'dead': 'погибло'
};

export const Maintenances: Record<string, string> = {
  'chemical': 'обработка химикатами',
  'fertilizer': 'внесение удобрений',
  'watering': 'полив',
  'pruning': 'обрезка',
  'transplanting': 'пересадка',
  'other': 'другое'
};

export type TaskType = NonNullable<Task["type"]>;

export const TaskTitles: Record<TaskType, string> = {
  general: 'общая',
  fertilizer: 'внесение удобрений',
  chemical: 'обработка химикатами',
  watering: 'полив',
  pruning: 'обрезка',
  transplanting: 'пересадка',
  harvesting: 'сбор урожая',
  other: 'другое'
};
