package mapper

import (
	"campaign-pool-be/app/database/entity"
	res "campaign-pool-be/app/module/campaigns/response"
)

func CampaignsResponseMapper(campaignsReq *entity.Campaigns, host string) (campaignsRes *res.CampaignsResponse) {
	if campaignsReq != nil {
		campaignsRes = &res.CampaignsResponse{
			ID:                 campaignsReq.ID,
			Title:              campaignsReq.Title,
			CampaignTypeID:     campaignsReq.CampaignTypeID,
			StartDate:          campaignsReq.StartDate,
			EndDate:            campaignsReq.EndDate,
			MediaTypeSelected:  campaignsReq.MediaTypeSelected,
			MediaItemSelected:  campaignsReq.MediaItemSelected,
			Purpose:            campaignsReq.Purpose,
			MediaPromote:       campaignsReq.MediaPromote,
			Description:        campaignsReq.Description,
			CreatorID:          campaignsReq.CreatorID,
			Status:             campaignsReq.Status,
			CreatedAt:          campaignsReq.CreatedAt,
			UpdatedAt:          campaignsReq.UpdatedAt,
		}

		if campaignsReq.CampaignType.ID > 0 {
			campaignsRes.CampaignType = &res.CampaignTypeInfo{
				ID:          campaignsReq.CampaignType.ID,
				Name:        campaignsReq.CampaignType.Name,
				Description: campaignsReq.CampaignType.Description,
			}
		}

		if campaignsReq.Creator.ID > 0 {
			campaignsRes.Creator = &res.CreatorInfo{
				ID:       campaignsReq.Creator.ID,
				Fullname: campaignsReq.Creator.Fullname,
				Email:    campaignsReq.Creator.Email,
			}
		}
	}
	return campaignsRes
}

