package vehicle

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ercl "simrs-vx/internal/domain/references/clinical"
)

type CreateDto struct {
	Type_Code       ercl.VehicleTypeCode `json:"type_code" validate:"required"`
	PoliceNumber    *string              `json:"policeNumber" validate:"required"`
	FrameNumber     *string              `json:"frameNumber"`
	RegNumber       *string              `json:"regNumber"`
	AvailableStatus bool                 `json:"availableStatus"`
}

type ReadListDto struct {
	FilterDto
	Includes   string `json:"includes"`
	Pagination ecore.Pagination
}

type FilterDto struct {
	Type_Code       ercl.VehicleTypeCode `json:"type-code"`
	PoliceNumber    *string              `json:"policeNumber"`
	FrameNumber     *string              `json:"frameNumber"`
	RegNumber       *string              `json:"regNumber"`
	AvailableStatus bool                 `json:"availableStatus"`
}

type ReadDetailDto struct {
	Id uint16 `json:"id"`
}

type UpdateDto struct {
	Id uint `json:"id"`
	CreateDto
}

type DeleteDto struct {
	Id uint16 `json:"id"`
}

type MetaDto struct {
	PageNumber int `json:"page_number"`
	PageSize   int `json:"page_size"`
	Count      int `json:"count"`
}

type ResponseDto struct {
	ecore.Main
	Type_Code       *ercl.VehicleTypeCode `json:"type_code"`
	PoliceNumber    *string               `json:"policeNumber"`
	FrameNumber     *string               `json:"frameNumber"`
	RegNumber       *string               `json:"regNumber"`
	AvailableStatus bool                  `json:"availableStatus"`
}

func (d Vehicle) ToResponse() ResponseDto {
	resp := ResponseDto{
		Type_Code:       d.Type_Code,
		PoliceNumber:    d.PoliceNumber,
		FrameNumber:     d.FrameNumber,
		RegNumber:       d.RegNumber,
		AvailableStatus: d.AvailableStatus,
	}
	resp.Main = d.Main
	return resp
}

func ToResponseList(data []Vehicle) []ResponseDto {
	resp := make([]ResponseDto, len(data))
	for i, u := range data {
		resp[i] = u.ToResponse()
	}
	return resp
}
