/**
 * ParcelSync module types.
 */

export type UatEntry = {
  siruta: string;
  name: string;
  county?: string;
  workspacePk?: number;
  /** Number of GIS features synced locally for this UAT */
  localFeatures?: number;
};

export type LayerSyncStatus = {
  layerId: string;
  localCount: number;
  lastSync?: string; // ISO date
  lastSyncStatus?: string; // done | error
  lastSyncNew?: number;
  lastSyncRemoved?: number;
};

export type SyncRunEntry = {
  id: string;
  siruta: string;
  uatName?: string;
  layerId: string;
  status: string;
  totalRemote: number;
  totalLocal: number;
  newFeatures: number;
  removedFeatures: number;
  startedAt: string;
  completedAt?: string;
  errorMessage?: string;
};

export type ParcelFeature = {
  id: string;
  layerId: string;
  siruta: string;
  objectId: number;
  inspireId?: string;
  cadastralRef?: string;
  areaValue?: number;
  isActive: boolean;
  attributes: Record<string, unknown>;
  geometry?: unknown;
  projectId?: string;
  createdAt: string;
  updatedAt: string;
};

export type SyncProgress = {
  jobId: string;
  downloaded: number;
  total?: number;
  status: "running" | "done" | "error";
  phase?: string;
  message?: string;
  note?: string;
  phaseCurrent?: number;
  phaseTotal?: number;
};
