# Blueprint import
from all_paw_care.users import users

# TODO uncomment database imports
# Database imports
from all_paw_care.db.actions import add_user
from all_paw_care.db.actions import login
from all_paw_care.db.types.user import User

# Flask imports
from flask import render_template
from flask import request

# SQLAlchemy imports
from sqlalchemy import select

@users.route('/login', methods=['GET', 'POST'])
def user_login():
    if request.method == 'POST':
        if login(request.form['username']):
            return 'Your now logged in.'

        else:
            return 'User not found.'

    return render_template("user/user_login.html")

@users.route('/create', methods=['GET', 'POST'])
def user_create():
    if request.method == 'POST':
        try:
            add_user(request.form['username'])
            return 'User created sucessfully.'

        except:
            return 'User exists'

    return render_template("user/user_create.html")

