from flask import jsonify, make_response, session

from src.lib.dms import has_unapproved_dms
from src.pages.api.v1 import v1api_bp


@v1api_bp.get("/has_pending_dms")
def get_has_pending_dms():
    has_pending_dms = False
    account_id = session.get("account_id")
    if account_id:
        has_pending_dms = has_unapproved_dms(account_id)
    response = make_response(jsonify(has_pending_dms), 200)
    response.headers["Cache-Control"] = "s-maxage=600"
    return response
