package staffrepository

import (
	"errors"
	staffdomain "legalgo-BE-go/internal/domain/staff"

	"gorm.io/gorm"
)

func (sr *impl) GetStaffByID(ID string) (*staffdomain.Staff, error) {
	var staff staffdomain.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
}
