import re
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, ColorField
from wtforms import SubmitField, TextAreaField, FileField, SelectField
from flask_wtf.file import FileField, FileAllowed, FileRequired
from wtforms import validators
from wtforms.validators import DataRequired, Length, EqualTo

class FormBloc(FlaskForm):
    title = StringField('Titre', validators=[])
    subtitle = StringField('Sous-titre', validators=[])
    property = StringField('Classes CSS', validators=[])
    bg_color = ColorField('Couleur de fond', validators=[])
    fg_color = ColorField('Couleur du texte', validators=[])
    text = TextAreaField('Présentation', validators=[])
    text_button = StringField('Texte du bouton', validators=[])
    link = StringField('Lien', validators=[])
    image = FileField('image', validators=[FileAllowed(['jpg','jpeg','png'])])
    email = StringField('Email', validators=[])
    phone = StringField('Téléphone', validators=[])
    address = StringField('Addresse', validators=[])
    postal_code = StringField('Code Postal', validators=[])
    city = StringField('Ville', validators=[])

    
class ImageForm(FlaskForm):
    title = StringField('Titre', validators=[DataRequired()])
    name = StringField('Nom du bloc', validators=[])
    subtitle = StringField('Sous-titre',validators=[])
    category = StringField('Categories',validators=[])
    description = StringField('Description', validators=[])

class ImageUpload(FlaskForm):
    name = StringField('Nom du bloc', validators=[])
    title = StringField('Titre', validators=[DataRequired()])
    subtitle = StringField('Sous-titre',validators=[])
    text = StringField('Une description de votre image', validators=[])
    category = StringField('Categories',validators=[])
    image = FileField('image', validators=[FileAllowed(['jpg', 'png', 'gif'], 'Images only!')])

class Login(FlaskForm):
    login = StringField('Votre identifiant', validators=[DataRequired()])
    passwd = PasswordField('Votre mot de passe', validators=[DataRequired()])
    submit = SubmitField("Se connecter",validators=[])

class CreateWebsite(FlaskForm):
    login = StringField('Votre identifiant', validators=[DataRequired()])
    passwd = StringField('Votre mot de passe', validators=[DataRequired(), EqualTo('passwd_confirm', "Le mot de passe doit être identique")])
    passwd_confirm = StringField('Confirmer votre mot de passe', validators=[DataRequired()])
    site_title = StringField('Titre de votre site', validators=[DataRequired()])
    theme =  SelectField('Thème', choices=[('creative','creative'),('nocreative', 'nocreative')],validators=[DataRequired()])
    submit = SubmitField("Créer le site !",validators=[])

