package domain

import (
	"context"
	"time"

	"github.com/google/uuid"
)

type User struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Email       string    `json:"email"`
	Password    string    `json:"-"`
	Phone       string    `json:"phone"`
	CompanyID   *uuid.UUID `json:"company_id"`
	Verified    bool      `json:"verified"`
	VerifiedAt  *time.Time `json:"verified_at"`
	RoleID      uuid.UUID `json:"role_id"`
	CandidateID *uuid.UUID `json:"candidate_id"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	DeletedAt   *time.Time `json:"deleted_at,omitempty"`
}

type UserRepository interface {
	Create(ctx context.Context, user *User) error
	GetByEmail(ctx context.Context, email string) (*User, error)
	GetByID(ctx context.Context, id uuid.UUID, companyID uuid.UUID) (*User, error)
	GetByIDGlobal(ctx context.Context, id uuid.UUID) (*User, error)
	GetAll(ctx context.Context, companyID uuid.UUID, search string, roleID uuid.UUID, limit, offset int) ([]*User, int, error)
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, id uuid.UUID, companyID uuid.UUID) error
}

type UserUsecase interface {
	Create(ctx context.Context, user *User) error
	GetAll(ctx context.Context, companyID uuid.UUID, search string, roleID uuid.UUID, limit, offset int) ([]*User, int, error)
	GetByID(ctx context.Context, id uuid.UUID, companyID uuid.UUID) (*User, error)
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, id uuid.UUID, companyID uuid.UUID) error
}

type AuthUsecase interface {
	Login(ctx context.Context, email, password string) (string, *User, string, []string, error) // Returns JWT, User, RoleName, Permissions
	Register(ctx context.Context, user *User) error
	GetMe(ctx context.Context, userID uuid.UUID) (*User, error)
	Logout(ctx context.Context) error
}
