package userrepository

import (
	"errors"

	userdomain "legalgo-BE-go/internal/domain/user"
)

func (ur *accessor) GetUserByID(id string) (*userdomain.User, error) {
	var user userdomain.User

	if id == "" {
		return nil, errors.New("id is empty")
	}

	if err := ur.db.
		Preload("Subscribe").
		Preload("Subscribe.SubscribePlan").
		First(&user, "id = ?", id).Error; err != nil {
		return nil, err
	}

	return &user, nil
}
