package ports

import (
	"context"
	"time"

	"Yimaru-Backend/internal/domain"
)

type ProfileCompletionStatus struct {
	IsCompleted bool
	Percentage  int
}

type UserStore interface {
	CreateGoogleUser(ctx context.Context, gUser domain.GoogleUser) (domain.User, error)
	LinkGoogleAccount(ctx context.Context, userID int64, googleID string) error
	GetProfileCompletionStatus(ctx context.Context, userId int64) (ProfileCompletionStatus, error)
	UpdateUserStatus(ctx context.Context, req domain.UpdateUserStatusReq) error
	// GetCorrectOptionForQuestion(
	// 	ctx context.Context,
	// 	questionID int64,
	// ) (int64, error)
	// GetLatestAssessmentAttempt(
	// 	ctx context.Context,
	// 	userID int64,
	// ) (*dbgen.AssessmentAttempt, error)
	UpdateUserKnowledgeLevel(ctx context.Context, userID int64, knowledgeLevel string) error
	// IsUserNameUnique(ctx context.Context, userName string) (bool, error)
	IsUserPending(ctx context.Context, userID int64) (bool, error)
	// GetUserByUserName(
	// 	ctx context.Context,
	// 	userName string,
	// ) (domain.User, error)
	CreateUser(
		ctx context.Context,
		user domain.User,
		usedOtpId int64,
	) (domain.User, error)
	CreateUserWithoutOtp(
		ctx context.Context,
		user domain.User,
	) (domain.User, error)
	GetUserByGoogleID(
		ctx context.Context,
		googleId string,
	) (domain.User, error)
	GetUserByID(
		ctx context.Context,
		id int64,
	) (domain.User, error)
	GetAllUsers(
		ctx context.Context,
		role *string,
		query *string,
		createdBefore, createdAfter *time.Time,
		limit, offset int32,
	) ([]domain.User, int64, error)
	GetTotalUsers(ctx context.Context, role *string) (int64, error)
	SearchUserByNameOrPhone(
		ctx context.Context,
		search string,
		role *string,
	) ([]domain.User, error)
	UpdateUser(ctx context.Context, req domain.UpdateUserReq) error
	DeleteUser(ctx context.Context, userID int64) error
	CheckPhoneEmailExist(ctx context.Context, phone, email string) (phoneExists, emailExists bool, err error)
	GetUserByEmailPhone(
		ctx context.Context,
		email string,
		phone string,
	) (domain.User, error)
	UpdatePassword(ctx context.Context, password string, userID int64) error
	UpdatePasswordHash(ctx context.Context, hashedPassword []byte, userID int64) error
	RegisterDevice(ctx context.Context, userID int64, deviceToken, platform string) error
	GetUserDeviceTokens(ctx context.Context, userID int64) ([]string, error)
	DeactivateDevice(ctx context.Context, userID int64, deviceToken string) error
	DeactivateAllUserDevices(ctx context.Context, userID int64) error
}
type SmsGateway interface {
	SendSMSOTP(ctx context.Context, phoneNumber, otp string) error
}
type EmailGateway interface {
	SendEmailOTP(ctx context.Context, email string, otp string) error
}
type OtpStore interface {
	UpdateOtp(ctx context.Context, otp string, userID int64) error
	MarkOtpAsUsed(ctx context.Context, otp domain.Otp) error
	CreateOtp(ctx context.Context, otp domain.Otp) error
	GetOtp(ctx context.Context, userID int64) (domain.Otp, error)
}
