export type DjiboutiIncidentType =
  | 'SEAL_BROKEN'
  | 'CONTAINER_OPENED'
  | 'CONTAINER_DAMAGED'
  | 'FLUID_LEAKING'
  | 'QUANTITY_MISMATCH'
  | 'WEIGHT_MISMATCH'
  | 'OTHER';

export interface DjiboutiIncident {
  id: string;
  bookingId: string;
  containerNumber: string | null;
  cargoId: string | null;
  facility: string | null;
  station: string | null;
  incidentType: DjiboutiIncidentType;
  description: string;
  photos: string[];
  reportedBy: string | null;
  reportedAt: string;
}

export interface CreateDjiboutiIncidentPayload {
  bookingId: string;
  containerNumber?: string;
  cargoId?: string;
  facility?: string;
  station?: string;
  incidentType: DjiboutiIncidentType;
  description: string;
  photos?: string[];
  reportedBy?: string;
  reportedAt?: string;
}

export type ImportCustomsDocumentType =
  | 'IM4'
  | 'IM5'
  | 'T1_CLOSURE_PROOF'
  | 'TRANSIT_PERMIT_SCREENSHOT'
  | 'CUSTOMER_PAYMENT_SLIP'
  | 'IMPORT_RELEASE_PERMIT';

export type ImportCustomsRiskLevel = 'GREEN' | 'YELLOW' | 'BLUE' | 'RED';

export interface ImportCustomsFinalization {
  id: string;
  bookingId: string;
  documents: Partial<Record<ImportCustomsDocumentType, string>>;
  declarationSerialNumber: string | null;
  dutiesTaxesNotifiedAt: string | null;
  dutiesTaxesPaidAt: string | null;
  customsRisk: ImportCustomsRiskLevel | null;
  importReleasePermittedAt: string | null;
  completedAt: string | null;
  performedBy: string | null;
  notes: string | null;
}

export interface ImportOperationActionPayload {
  performedBy?: string;
  notes?: string;
}

export interface UploadImportCustomsDocumentPayload {
  documentType: ImportCustomsDocumentType;
  fileId: string;
  performedBy?: string;
}

export interface RecordDeclarationPayload {
  declarationSerialNumber: string;
  performedBy?: string;
}

export interface AssignCustomsRiskPayload {
  risk: ImportCustomsRiskLevel;
  performedBy?: string;
}

export type EmptyContainerReturnStatus =
  | 'RETURNED'
  | 'ASSIGNED_STORAGE'
  | 'DOCUMENTATION_CLEARED'
  | 'WAGON_ALLOCATED'
  | 'TRANSPORTED_TO_DJIBOUTI'
  | 'HANDOVER_ISSUED'
  | 'COMPLETED';

export interface EmptyContainerReturn {
  id: string;
  containerNumber: string;
  bookingId: string | null;
  customerId: string | null;
  returnDate: string;
  facility: string | null;
  yard: string | null;
  zone: string | null;
  condition: string | null;
  handoverNote: string | null;
  status: EmptyContainerReturnStatus;
  wagonAllocationReference: string | null;
  performedBy: string | null;
}

export interface CreateEmptyContainerReturnPayload {
  containerNumber: string;
  bookingId?: string;
  customerId?: string;
  returnDate?: string;
  facility?: string;
  yard?: string;
  zone?: string;
  condition?: string;
  handoverNote?: string;
  performedBy?: string;
}

export interface UpdateEmptyContainerReturnStatusPayload extends ImportOperationActionPayload {
  status: EmptyContainerReturnStatus;
  wagonAllocationReference?: string;
  handoverNote?: string;
}
