package logic

import (
	"juwan-backend/app/review/rpc/internal/models"
	"juwan-backend/app/review/rpc/pb"
)

func entReviewToPb(r *models.Reviews) *pb.Reviews {
	out := &pb.Reviews{
		Id:             r.ID,
		OrderId:        r.OrderID,
		FromUserId:     r.FromUserID,
		FromUserName:   r.FromUserName,
		FromUserAvatar: r.FromUserAvatar,
		ToUserId:       r.ToUserID,
		Rating:         int32(r.Rating),
		Content:        r.Content,
		Sealed:         r.Sealed,
		CreatedAt:      r.CreatedAt.Unix(),
	}
	if r.UnsealedAt != nil {
		out.UnsealedAt = r.UnsealedAt.Unix()
	}
	return out
}
