from flask import Blueprint, jsonify, session
from core.db import get_db
from services.dashboard_service import get_dashboard_data

dashboard_bp = Blueprint('dashboard', __name__)


@dashboard_bp.route('/api/dashboard')
def dashboard():
    if not session.get('giris'):
        return jsonify({'hata': 'Yetkisiz'}), 401
    db = get_db()
    return jsonify(get_dashboard_data(db))
