package dto

import (
	"time"

	entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
)

// === DTO Structs ===

type ConfigChecklistRelationDTO struct {
	Id   uint      `json:"id"`
	Date time.Time `json:"date"`
}

type ConfigChecklistListDTO struct {
	Id                        uint      `json:"id"`
	Date                      time.Time `json:"date"`
	PercentageThresholdBad    int       `json:"percentage_threshold_bad"`
	PercentageThresholdEnough int       `json:"percentage_threshold_enough"`
	CreatedAt                 time.Time `json:"created_at"`
	UpdatedAt                 time.Time `json:"updated_at"`
}

type ConfigChecklistDetailDTO struct {
	ConfigChecklistListDTO
}

// === Mapper Functions ===

func ToConfigChecklistRelationDTO(e entity.ConfigChecklist) ConfigChecklistRelationDTO {
	return ConfigChecklistRelationDTO{
		Id:   e.Id,
		Date: e.Date,
	}
}

func ToConfigChecklistListDTO(e entity.ConfigChecklist) ConfigChecklistListDTO {
	return ConfigChecklistListDTO{
		Id:                        e.Id,
		Date:                      e.Date,
		PercentageThresholdBad:    e.PercentageThresholdBad,
		PercentageThresholdEnough: e.PercentageThresholdEnough,
		CreatedAt:                 e.CreatedAt,
		UpdatedAt:                 e.UpdatedAt,
	}
}

func ToConfigChecklistListDTOs(e []entity.ConfigChecklist) []ConfigChecklistListDTO {
	result := make([]ConfigChecklistListDTO, len(e))
	for i, r := range e {
		result[i] = ToConfigChecklistListDTO(r)
	}
	return result
}

func ToConfigChecklistDetailDTO(e entity.ConfigChecklist) ConfigChecklistDetailDTO {
	return ConfigChecklistDetailDTO{
		ConfigChecklistListDTO: ToConfigChecklistListDTO(e),
	}
}
