from flask_wtf import FlaskForm
from wtforms import IntegerField, PasswordField, SelectField, StringField, SubmitField
from wtforms.validators import DataRequired, Email, Length, Optional


class KullaniciEklemeFormu(FlaskForm):
    # ad_soyad: nullable=False olduğu için DataRequired eklendi
    ad_soyad = StringField("Ad Soyad", validators=[DataRequired(), Length(max=50)])

    # eposta: Email format kontrolü
    eposta = StringField(
        "E-posta", validators=[DataRequired(), Email(), Length(max=120)]
    )

    # telefon: nullable=True olduğu için Optional eklendi
    telefon = StringField("Telefon", validators=[Optional(), Length(max=50)])

    # parola: Yeni kayıt ve güncellemeler için
    parola = PasswordField(
        "Parola", validators=[DataRequired(), Length(min=6, max=120)]
    )

    # rol_num ve durum: Tam sayı girişleri
    rol_num = SelectField(
        "Rol Numarası",
        choices=[(1, "Admin"), (2, "Kullanıcı")],
        default=2,
    )


class KullaniciDuzenlemeFormu(FlaskForm):
    # ad_soyad: nullable=False olduğu için DataRequired eklendi
    ad_soyad = StringField("Ad Soyad", validators=[DataRequired(), Length(max=50)])

    # eposta: Email format kontrolü
    eposta = StringField(
        "E-posta", validators=[DataRequired(), Email(), Length(max=120)]
    )

    # telefon: nullable=True olduğu için Optional eklendi
    telefon = StringField("Telefon", validators=[Optional(), Length(max=50)])

    # parola: Yeni kayıt ve güncellemeler için
    parola = PasswordField("Parola", validators=[Optional()])

    # rol_num ve durum: Tam sayı girişleri
    rol_num = SelectField(
        "Rol Numarası",
        choices=[(1, "Admin"), (2, "Kullanıcı")],
        default=2,
    )
