package request

import (
	"time"
	"web-qudo-be/app/database/entity"
	"web-qudo-be/utils/paginator"
)

type AboutUsContentQueryRequest struct {
	PrimaryTitle *string               `json:"primary_title"`
	Pagination   *paginator.Pagination `json:"pagination"`
}

type AboutUsContentCreateRequest struct {
	PrimaryTitle     string `json:"primary_title" validate:"required"`
	SecondaryTitle   string `json:"secondary_title"`
	Description      string `json:"description"`
	PrimaryCTA       string `json:"primary_cta"`
	SecondaryCTAText string `json:"secondary_cta_text"`
}

func (req AboutUsContentCreateRequest) ToEntity() *entity.AboutUsContent {
	return &entity.AboutUsContent{
		PrimaryTitle:     req.PrimaryTitle,
		SecondaryTitle:   req.SecondaryTitle,
		Description:      req.Description,
		PrimaryCta:       req.PrimaryCTA,
		SecondaryCtaText: req.SecondaryCTAText,
		CreatedAt:        time.Now(),
	}
}

type AboutUsContentUpdateRequest struct {
	PrimaryTitle     string `json:"primary_title"`
	SecondaryTitle   string `json:"secondary_title"`
	Description      string `json:"description"`
	PrimaryCTA       string `json:"primary_cta"`
	SecondaryCTAText string `json:"secondary_cta_text"`
}

func (req AboutUsContentUpdateRequest) ToEntity() *entity.AboutUsContent {
	return &entity.AboutUsContent{
		PrimaryTitle:     req.PrimaryTitle,
		SecondaryTitle:   req.SecondaryTitle,
		Description:      req.Description,
		PrimaryCta:       req.PrimaryCTA,
		SecondaryCtaText: req.SecondaryCTAText,
		UpdatedAt:        time.Now(),
	}
}

type AboutUsContentQueryRequestContext struct {
	PrimaryTitle string `json:"primary_title"`
}

func (req AboutUsContentQueryRequestContext) ToParamRequest() AboutUsContentQueryRequest {
	var request AboutUsContentQueryRequest

	if req.PrimaryTitle != "" {
		request.PrimaryTitle = &req.PrimaryTitle
	}

	return request
}