package mappers

import (
	"actatempus_backend/internal/application/services/dto"
	"actatempus_backend/internal/domain/entities"
	"time"
)

// MapProjectTaskToDTO converts a ProjectTask domain object to a ProjectTaskDTO.
func MapProjectTaskToDTO(task entities.ProjectTask) dto.ProjectTaskDTO {
	return dto.ProjectTaskDTO{
		ID:          task.ID,
		Name:        task.Name,
		Description: task.Description,
		ProjectID:   task.ProjectID,
		CreatedAt:   task.CreatedAt.Format(time.RFC3339),
		UpdatedAt:   task.UpdatedAt.Format(time.RFC3339),
	}
}

// MapCreateDTOToProjectTask converts a ProjectTaskCreateDTO to a ProjectTask domain object.
func MapCreateDTOToProjectTask(dto dto.ProjectTaskCreateDTO) entities.ProjectTaskCreate {
	return entities.ProjectTaskCreate{
		Name:        dto.Name,
		Description: dto.Description,
		ProjectID:   dto.ProjectID,
	}
}

// MapUpdateDTOToProjectTask converts a ProjectTaskUpdateDTO to a partial ProjectTask domain object.
func MapUpdateDTOToProjectTask(dto dto.ProjectTaskUpdateDTO, ID string) entities.ProjectTaskUpdate {
	return entities.ProjectTaskUpdate{
		ID:          ID,
		Name:        dto.Name,
		Description: dto.Description,
		ProjectID:   dto.ProjectID,
	}
}
