package mapper

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

func AdvertisementResponseMapper(advertisementReq *entity.Advertisement, host string) (advertisementRes *res.AdvertisementResponse) {
	if advertisementReq != nil {
		advertisementRes = &res.AdvertisementResponse{
			ID:           advertisementReq.ID,
			Title:        advertisementReq.Title,
			Description:  advertisementReq.Description,
			RedirectLink: advertisementReq.RedirectLink,
			Placement:    advertisementReq.Placement,
			StatusId:     advertisementReq.StatusId,
			IsActive:     advertisementReq.IsActive,
			IsPublish:    advertisementReq.IsPublish,
			CreatedAt:    advertisementReq.CreatedAt,
			UpdatedAt:    advertisementReq.UpdatedAt,
		}

		if advertisementReq.ContentFilePath != nil {
			advertisementRes.ContentFileUrl = host + "/advertisement/viewer/" + *advertisementReq.ContentFileName
		}
	}
	return advertisementRes
}
