import type { ApplicationPayment } from '../licensing/licensing.types';

export type SeafarerDocumentKind = 'SEAMAN_BOOK' | 'BTC_BASIC_TRAINING';

export type SeafarerDocumentStatus =
  | 'AWAITING_REGISTRATION'
  | 'PAYMENT_PENDING'
  | 'PAID'
  | 'PAYMENT_CONFIRMED'
  | 'SCHEDULED'
  | 'ISSUED'
  | 'REJECTED'
  | 'CANCELLED';

/** NEW comes from a seafarer registration; RENEWAL/REPLACEMENT are applicant-initiated. */
export type SeafarerDocumentRequestKind = 'NEW' | 'RENEWAL' | 'REPLACEMENT';

/** A Seaman Book or BTC request — opened by a seafarer registration, or by the applicant as a renewal/replacement. */
export interface SeafarerDocument {
  id: string;
  kind: SeafarerDocumentKind;
  requestKind: SeafarerDocumentRequestKind;
  requestNumber: string;
  applicantUserId: string;
  profileId: string | null;
  seafarerRegistrationId: string | null;
  previousDocumentId: string | null;
  status: SeafarerDocumentStatus;
  feeAmount: number | null;
  feeCurrency: string;
  submittedAt: string | null;
  paidAt: string | null;
  paymentReference: string | null;
  scheduledIssuanceDate: string | null;
  documentNumber: string | null;
  issueDate: string | null;
  expiryDate: string | null;
  documentFileKey: string | null;
  issuedAt: string | null;
  rejectionReason: string | null;
  createdAt: string;
}

export interface SeafarerDocumentApplicant {
  name: string;
  seafarerNumber: string | null;
  registrationNumber: string | null;
  registrationId: string | null;
}

export type SeafarerDocumentRow = SeafarerDocument & {
  applicant: SeafarerDocumentApplicant | null;
};

export interface SeafarerDocumentDetail {
  document: SeafarerDocument;
  applicant: SeafarerDocumentApplicant | null;
  payment: ApplicationPayment | null;
}
