package subscribeplanrepository

import (
	"legalgo-BE-go/database"
	subscribeplandomain "legalgo-BE-go/internal/domain/subscribe_plan"

	"github.com/google/uuid"
)

func (s *accessor) GetDefault() (*subscribeplandomain.SubscribePlan, error) {
	var subscribePlan *subscribeplandomain.SubscribePlan

	if err := s.db.First(&subscribePlan, "code = ?", "basic").Error; err != nil {
		s.db.Create(&database.SubscribePlan{
			ID:   uuid.NewString(),
			Code: "basic",
			Name: "Basic",
		})
	}

	return subscribePlan, nil
}
