package mapper

import (
	"narasi-ahli-be/app/database/entity"
	"narasi-ahli-be/app/module/education_history/response"
)

func EducationHistoryResponseMapper(educationHistory *entity.EducationHistory) *response.EducationHistoryResponse {
	result := &response.EducationHistoryResponse{
		ID:               educationHistory.ID,
		UserID:           educationHistory.UserID,
		SchoolName:       educationHistory.SchoolName,
		Major:            educationHistory.Major,
		EducationLevel:   educationHistory.EducationLevel,
		GraduationYear:   educationHistory.GraduationYear,
		CertificateImage: educationHistory.CertificateImage,
		CreatedAt:        educationHistory.CreatedAt,
		UpdatedAt:        educationHistory.UpdatedAt,
	}

	if educationHistory.User != nil {
		result.User = &response.UserBasicInfo{
			ID:       educationHistory.User.ID,
			Username: educationHistory.User.Username,
			Fullname: educationHistory.User.Fullname,
			Email:    educationHistory.User.Email,
		}
	}

	return result
}
