package response

import shareddto "wucher/internal/transport/http/dto/shared"

// ComplaintMEL groups the MEL deferral attributes. All fields are always present
// (null when not set) so the response shape is predictable for clients.
type ComplaintMEL struct {
	// Severity — MEL class: 0=NON-MEL, 1=A, 2=B, 3=C, 4=D. Always set (classification is required at creation).
	Severity int8 `json:"severity" example:"2" enums:"0,1,2,3,4"`
	// SeverityLabel — human label of the severity (NON-MEL/A/B/C/D).
	SeverityLabel *string `json:"severity_label" example:"B"`
	// ClassifiedAt / ClassifiedByName / ClassifiedByShort — when/who classified the MEL.
	ClassifiedAt      *string `json:"classified_at" example:"2026-06-15T03:04:05Z"`
	ClassifiedByName  *string `json:"classified_by_name" example:"John Doe"`
	ClassifiedByShort *string `json:"classified_by_short" example:"JDO"`
	// Deadline — grace deadline; after this the aircraft is AOG. null for NON-MEL.
	Deadline *string `json:"deadline" example:"2026-06-18T03:04:05Z"`
}

type ComplaintNSR struct {
	// IsNSR — Non-Safety Release: true = aircraft released to fly despite the open defect.
	IsNSR bool `json:"is_nsr" example:"false"`
	// Reason — optional justification for the NSR decision.
	Reason *string `json:"reason" example:"not required"`
	// DecidedAt / DecidedByName / DecidedByShort — when/who decided NSR (may differ from the reporter).
	DecidedAt      *string `json:"decided_at" example:"2026-06-15T03:04:05Z"`
	DecidedByName  *string `json:"decided_by_name" example:"John Doe"`
	DecidedByShort *string `json:"decided_by_short" example:"JDO"`
}

type ComplaintAttributes struct {
	HelicopterID          string                           `json:"helicopter_id" example:"019d6771-5fb5-7337-837f-bc5ed85181a1"`
	FlightID              string                           `json:"flight_id,omitempty" example:"019d6774-98e8-7fba-9ef4-3795c0da8a13"`
	Description           string                           `json:"description" example:"Engine 2 N2 vibration intermittent during cruise above 110 KIAS"`
	Helicopter            *shareddto.FleetStatusHelicopter `json:"helicopter,omitempty"`
	ReportedBy            string                           `json:"reported_by" example:"John Doe"`
	ReportedByShort       string                           `json:"reported_by_short,omitempty" example:"JDO"`
	ReportedAt            string                           `json:"reported_at" example:"2026-06-15T03:04:05Z"`
	AircraftHoursAtReport *string                          `json:"aircraft_hours_at_report" example:"1245.3"`
	MEL                   ComplaintMEL                     `json:"mel"`
	NSR                   ComplaintNSR                     `json:"nsr"`
	ActionSigned          bool                             `json:"action_signed" example:"true"`
	ActionTaken           *string                          `json:"action_taken" example:"tightened mount"`
	ActionSignedAt        *string                          `json:"action_signed_at" example:"2026-06-15T03:04:05Z"`
	ActionSignedByName    *string                          `json:"action_signed_by_name" example:"John Doe"`
	ActionSignedByShort   *string                          `json:"action_signed_by_short" example:"JDO"`
	AircraftHoursAtFix    *string                          `json:"aircraft_hours_at_fix" example:"1250.1"`
	Status                string                           `json:"status" example:"active_mel" enums:"active_non_mel,active_mel,serviced"`
	CreatedAt             string                           `json:"created_at" example:"2026-06-15T03:04:05Z"`
	UpdatedAt             string                           `json:"updated_at" example:"2026-06-15T03:04:05Z"`
}

type ComplaintResource struct {
	Type       string              `json:"type" example:"complaint"`
	ID         string              `json:"id" example:"019d6771-5fb5-7337-837f-bc5ed85181a1"`
	Attributes ComplaintAttributes `json:"attributes"`
}

type ComplaintResponse struct {
	Data ComplaintResource `json:"data"`
}

type ComplaintListResponse struct {
	Data []ComplaintResource `json:"data"`
	Meta struct {
		PageNumber int   `json:"page_number" example:"1"`
		PageSize   int   `json:"page_size" example:"20"`
		Total      int64 `json:"total" example:"1"`
	} `json:"meta"`
}

type ComplaintHelicopterGroupAttributes struct {
	Helicopter *shareddto.FleetStatusHelicopter `json:"helicopter"`
	Complaints []ComplaintResource              `json:"complaints"`
}

type ComplaintHelicopterGroupResource struct {
	Type       string                             `json:"type" example:"complaint_helicopter_group"`
	Attributes ComplaintHelicopterGroupAttributes `json:"attributes"`
}

type ComplaintGroupedListResponse struct {
	Data []ComplaintHelicopterGroupResource `json:"data"`
	Meta struct {
		PageNumber int   `json:"page_number" example:"1"`
		PageSize   int   `json:"page_size" example:"20"`
		Total      int64 `json:"total" example:"1"`
	} `json:"meta"`
}

type ComplaintGroupedDataTableResponse struct {
	Data []ComplaintHelicopterGroupResource `json:"data"`
	Meta struct {
		Draw            int   `json:"draw" example:"1"`
		RecordsTotal    int64 `json:"records_total" example:"1"`
		RecordsFiltered int64 `json:"records_filtered" example:"1"`
	} `json:"meta"`
}
