declare namespace SgwModel {
  interface TripBasicInfo {
    name: string;
    departure_time: string;
    arrival_time: string;
    trip_status: number;
    ship_name: string;
    departure_port_id: number;
    arrival_port_id: number;
    fishing_ground_codes: number[];
    trip_cost: TripCost[];
    notes: string | null;
    fishing_gears?: FishingGear[];
  }

  interface Trip extends TripBasicInfo {
    id: string;
    ship_id: string;
    ship_length: number;
    vms_id: string;
    crews?: TripCrews[];
    total_catch_weight: number | null;
    total_species_caught: number | null;
    trip_status: number;
    approved_by: string;
    fishing_logs: FishingLog[] | null;
    sync: boolean;
  }
  interface TripQueryParams extends MasterModel.SearchPaginationBody {
    order?: string;
    metadata?: {
      from?: string;
      to?: string;
      ship_name?: string;
      reg_number?: string;
      province_code?: string;
      owner_id?: string;
      ship_id?: string;
      status?: string;
    };
  }

  interface TripQueryResponse extends MasterModel.PaginationReponse {
    trips: Trip[];
  }

  interface TripUpdateParams extends Partial<TripBasicInfo> {
    crews?: TripCrews[];
  }

  interface TripDeleteParams {
    trip_ids: string[];
  }

  interface TripUpdateStateRequest {
    status: number;
    note?: string;
  }

  interface TripCreateParams extends Partial<TripBasicInfo> {
    crews?: TripCrews[];
  }

  interface TripCost {
    type: string;
    unit: string;
    amount: string;
    total_cost: string;
    cost_per_unit: string;
  }

  // Trip Crews

  interface TripCrewPerson {
    personal_id: string;
    name: string;
    phone: string;
    email: string;
    birth_date: Date;
    note: string;
    address: string;
    created_at: Date;
    updated_at: Date;
  }

  interface TripCrews {
    role: string;
    joined_at: Date;
    left_at: Date | null;
    note: string | null;
    Person: TripCrewPerson;
  }

  interface TripCrewBasicInfo {
    personal_id: string;
    role: string;
    note?: string;
  }

  interface TripCrewCreateParams extends Partial<TripCrewBasicInfo> {
    trip_id: string;
  }

  interface TripCrewUpdateParams extends Partial<TripCrewBasicInfo> {
    trip_id: string;
  }
  interface TripCrewQueryResponse {
    trip_crews: TripCrews[];
    total?: number;
  }
}
