package mapper

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

func AiChatFilesResponseMapper(aiChatFilesReq *entity.AiChatFiles, host string) (aiChatFilesRes *res.AiChatFilesResponse) {
	fileUrl := host + "/ai-chat-files/viewer/"
	if aiChatFilesReq.FileName != nil {
		fileUrl += *aiChatFilesReq.FileName
	}

	if aiChatFilesReq != nil {
		aiChatFilesRes = &res.AiChatFilesResponse{
			ID:            aiChatFilesReq.ID,
			MessageId:     aiChatFilesReq.MessageId,
			FilePath:      aiChatFilesReq.FilePath,
			FileUrl:       &fileUrl,
			FileName:      aiChatFilesReq.FileName,
			FileAlt:       aiChatFilesReq.FileAlt,		
			Size:          aiChatFilesReq.Size,			
			IsActive:      aiChatFilesReq.IsActive,
			CreatedAt:     aiChatFilesReq.CreatedAt,
			UpdatedAt:     aiChatFilesReq.UpdatedAt,
		}
	}
	return aiChatFilesRes
}
