package mapper

import (
	"campaign-pool-be/app/database/entity/users"
	userLevelsRepository "campaign-pool-be/app/module/user_levels/repository"
	res "campaign-pool-be/app/module/users/response"
)

func UsersResponseMapper(usersReq *users.Users, userLevelsRepo userLevelsRepository.UserLevelsRepository) (usersRes *res.UsersResponse) {
	if usersReq != nil {
		findUserLevel, _ := userLevelsRepo.FindOne(usersReq.UserLevelId)
		userLevelGroup := ""
		if findUserLevel != nil {
			userLevelGroup = findUserLevel.AliasName
		}

		usersRes = &res.UsersResponse{
			ID:                 usersReq.ID,
			Username:           usersReq.Username,
			Email:              usersReq.Email,
			Fullname:           usersReq.Fullname,
			Address:            usersReq.Address,
			PhoneNumber:        usersReq.PhoneNumber,
			WhatsappNumber:     usersReq.WhatsappNumber,
			Degree:             usersReq.Degree,
			WorkType:           usersReq.WorkType,
			GenderType:         usersReq.GenderType,
			IdentityType:       usersReq.IdentityType,
			IdentityNumber:     usersReq.IdentityNumber,
			DateOfBirth:        usersReq.DateOfBirth,
			LastEducation:      usersReq.LastEducation,
			KeycloakId:         usersReq.KeycloakId,
			UserRoleId:         usersReq.UserRoleId,
			UserLevelGroup:     userLevelGroup,
			StatusId:           usersReq.StatusId,
			UserLevelId:        usersReq.UserLevelId,
			CreatedById:        usersReq.CreatedById,
			ProfilePicturePath: usersReq.ProfilePicturePath,
			IsActive:           usersReq.IsActive,
			CreatedAt:          usersReq.CreatedAt,
			UpdatedAt:          usersReq.UpdatedAt,
		}
	}
	return usersRes
}
