import os
import sys

# Add the project root to sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

from core.config import get_db
from core.security.authentication import hash_password
from models import User, UserProfile, UserWallet


def create_super_admin():
    with get_db() as db:
        first_name = "Wac"
        last_name = "Admin"
        email = "admin@wacarts.co.uk"
        gender = "male"
        # new_user = User(first_name=first_name, sur_name=last_name, email=email, hashed_password=hash_password("admin"),
        #     user_type="admin", country_code="+1", mobile_number="1234567890", is_active=True
        #                 )
        new_user = User(first_name=first_name, sur_name=last_name, email=email, hashed_password=hash_password("admin@wacarts.co.uk"),
            user_type="admin", country_code="+1", mobile_number="1234567890", is_active=True
                        )
        try:
            db.add(new_user)
            db.commit()
            print(f"User {new_user.first_name} {new_user.sur_name} added successfully.")
        except Exception as e:
            db.rollback()
            print(f"Error: {e}")


if __name__ == "__main__":
    create_super_admin()
