package staffrepository

import (
	"errors"
	authdomain "legalgo-BE-go/internal/domain/auth"

	"gorm.io/gorm"
)

func (sr *StaffRepository) GetStaffByID(ID string) (*authdomain.Staff, error) {
	var staff authdomain.Staff

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

	if err := sr.DB.First(&staff, "id = ? ", ID).Error; err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return nil, errors.New("staff not found")
		}
		return nil, err
	}

	return &staff, nil
}
