#pragma once

#include "../server/database/database.h"
#include <string>
#include <vector>
#include <memory>

namespace scar {

class DBManager {
public:
    explicit DBManager(const std::string& db_path);
    ~DBManager() = default;
    
    // User management
    bool addUser(const std::string& username, const std::string& password, 
                 const std::string& avatar = "");
    bool deleteUser(const std::string& username);
    
    // Modify user fields
    bool modifyPassword(const std::string& username, const std::string& new_password);
    bool modifyAvatar(const std::string& username, const std::string& avatar_path);
    bool modifyEmail(const std::string& username, const std::string& email);
    bool modifyRole(const std::string& username, const std::string& role);
    
    // Query operations
    void fetchUser(const std::string& username);
    void searchUsers(const std::string& field, const std::string& value);
    void listAllUsers();
    
    // Database location
    static std::string findDatabase(const std::string& override_path = "");
    
private:
    std::unique_ptr<Database> db_;
    
    void printUserDetails(const UserRecord& user);
    std::vector<uint8_t> readAvatarFile(const std::string& path);
};

} // namespace scar
