package mapper

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

func CampaignDestinationsResponseMapper(campaignDestinationsReq *entity.CampaignDestinations) (campaignDestinationsRes *res.CampaignDestinationsResponse) {
	if campaignDestinationsReq != nil {
		campaignDestinationsRes = &res.CampaignDestinationsResponse{
			ID:             campaignDestinationsReq.ID,
			CampaignTypeID: campaignDestinationsReq.CampaignTypeID,
			SubType:        campaignDestinationsReq.SubType,
			Name:           campaignDestinationsReq.Name,
			Description:    campaignDestinationsReq.Description,
			URL:            campaignDestinationsReq.URL,
			IsActive:       campaignDestinationsReq.IsActive,
			CreatedAt:      campaignDestinationsReq.CreatedAt,
			UpdatedAt:      campaignDestinationsReq.UpdatedAt,
		}

		if campaignDestinationsReq.CampaignType.ID > 0 {
			campaignDestinationsRes.CampaignType = &res.CampaignTypeInfo{
				ID:          campaignDestinationsReq.CampaignType.ID,
				Name:        campaignDestinationsReq.CampaignType.Name,
				Description: campaignDestinationsReq.CampaignType.Description,
			}
		}
	}
	return campaignDestinationsRes
}

