package request

// MCFSetAttributes toggles a helicopter's MCF (Yes/No) and is the DRAFT work endpoint.
// active=true (or omitted) ACTIVATES it — creates the draft MCF if none is open, or
// UPDATES the open draft with the provided check-flight fields (all optional; partial
// edits allowed). Finalize it later via POST /mcf/sign (sign:true).
// active=false DEACTIVATES it — cancels the open draft ("tidak jadi") and releases the
// MCF status; the cancelled record stays in the list. A signed MCF is a real event and
// is not cancelled by this.
type MCFSetAttributes struct {
	Active *bool `json:"active,omitempty" example:"true"`
	// FlightID — OPTIONAL flight this check flight is performed on (on activate).
	FlightID     string  `json:"flight_id,omitempty" validate:"omitempty,uuid" example:"019d6774-98e8-7fba-9ef4-3795c0da8a13"`
	AFHours      string  `json:"af_hours,omitempty" example:"1245.3"`
	LandingCount *int    `json:"landing_count,omitempty" example:"3"`
	UTCTime      string  `json:"utc_time,omitempty" example:"2026-06-17T08:30:00Z"`
	Date         string  `json:"date,omitempty" example:"2026-06-17"`
	Result       string  `json:"result,omitempty" validate:"omitempty,oneof=passed failed" enums:"passed,failed" example:"passed"`
	Notes        *string `json:"notes,omitempty" example:"MCF required after engine mount work"`
}

type MCFSetData struct {
	Type       string           `json:"type" validate:"required,oneof=mcf_set mcf" example:"mcf_set"`
	Attributes MCFSetAttributes `json:"attributes" validate:"required"`
}

type MCFSetRequest struct {
	Data MCFSetData `json:"data" validate:"required"`
}

// MCFCompleteAttributes signs (completes) or unsigns an MCF. sign toggles the state:
//   - sign=true (or omitted) SIGNS it — af_hours, landing_count, utc_time, date and
//     result are required. "passed" clears the aircraft; "failed" keeps it grounded.
//   - sign=false UNSIGNS it — reverts the MCF to a draft (the fields below are ignored).
type MCFCompleteAttributes struct {
	Sign         *bool   `json:"sign,omitempty" example:"true"`
	AFHours      string  `json:"af_hours,omitempty" example:"1245.3"`
	LandingCount *int    `json:"landing_count,omitempty" example:"3"`
	UTCTime      string  `json:"utc_time,omitempty" example:"2026-06-17T08:30:00Z"`
	Date         string  `json:"date,omitempty" example:"2026-06-17"`
	Result       string  `json:"result,omitempty" validate:"omitempty,oneof=passed failed" enums:"passed,failed" example:"passed"`
	Notes        *string `json:"notes,omitempty" example:"Vibration within limits after check flight"`
}

type MCFCompleteData struct {
	Type       string                `json:"type" validate:"required,oneof=mcf_complete mcf_sign mcf" example:"mcf_sign"`
	Attributes MCFCompleteAttributes `json:"attributes" validate:"required"`
}

type MCFCompleteRequest struct {
	Data MCFCompleteData `json:"data" validate:"required"`
}
