from flask import Blueprint, redirect, url_for, render_template, session,flash
from flask_login import login_required, current_user

main_bp = Blueprint("main", __name__, url_prefix="")

@main_bp.route("/")
def home():
    if current_user.is_authenticated:
        return redirect(url_for("main.dashboard"))
    return redirect(url_for("auth.login"))

@main_bp.route("/dashboard")
@login_required
def dashboard():
    
    jwt_info = session.get("appwrite_jwt", {})
    profile = session.get("user_profile", {})
    return render_template("main/dashboard.html", profile=profile, jwt_info=jwt_info)
