from django.forms import fields, widgets
from app.models import Customer
from django import forms
from django.contrib.auth import password_validation
from django.contrib.auth.forms import PasswordChangeForm, PasswordResetForm, SetPasswordForm, UserCreationForm,AuthenticationForm, UsernameField
PasswordChangeForm,PasswordResetForm,SetPasswordForm
from django.contrib.auth.models import User
from django.forms import widgets
from .models import Customer
from django.utils.translation import gettext, gettext_lazy as _

class CustomerRegistrationFrom(UserCreationForm):
  password1 = forms.CharField(label='Password',widget=forms.
  PasswordInput(attrs={'class':'form-control'}))
  password2 = forms.CharField(label='Comfrim Password',widget=forms.
  PasswordInput(attrs={'class':'form-control'}))
  email = forms.CharField(required=True,widget=forms.
  EmailInput(attrs={'class':'form-control'}))

  class Meta:
    model=User
    fields = ['username','email','password1','password2']
    labels ={'email': 'Email'}
    widgets  = {'username':forms.TextInput(attrs=
    {'class':"form-control"})}


class LoginForm(AuthenticationForm):
  username = UsernameField(widget=forms.TextInput
  (attrs={'autofocus':True,'class':'form-control'}))
  password = forms.CharField(label= _("Password"),strip=False,
  widget=forms.PasswordInput(attrs={'autofcomplete':'current-password',
  'class':'form-control'}))

class MyPasswordChangeForm(PasswordChangeForm):
  old_password = forms.CharField(label=_("Old Password"),
  strip=False,widget=forms.PasswordInput(attrs={'autocomplete':'current-password','autofocus':True,
  'class':'form-control'}))
  new_password1 = forms.CharField(label=_("New Password"),
  strip=False,widget=forms.PasswordInput(attrs={'autocomplete':'New password',
  'class':'form-control'}),help_text=password_validation.
  password_validators_help_text_html())
  new_password2 = forms.CharField(label=_("Confrim New Password"),
  strip=False,widget=forms.PasswordInput(attrs={'autocomplete':'current-password',
  'class':'form-control'}))

class MyPasswordResetForm(PasswordResetForm):
  email  = forms.EmailField(label=_("Email"),max_length=254,
  widget=forms.EmailInput(attrs={'autocomplete':'email',
  'class':'form-control'}))

class MySetPasswordForm(SetPasswordForm):
  new_password1= forms.CharField(label=_("New Password"),
  strip=False,widget=forms.PasswordInput(attrs={'autocomplete':'new-password',
  'class':'form-control'}),help_text=password_validation.
  password_validators_help_text_html())
  new_password2= forms.CharField(label=_("Comfrim New Password"),
  strip=False,widget=forms.PasswordInput(attrs={'autocomplete':'new-password',
  'class':'form-control'}))

class CustomerProfileform(forms.ModelForm):
  class Meta:
    model = Customer
    fields = ['name','locality','city','state','zipcode']
    widgets= {'name':forms.TextInput(attrs={'class':'form-control'}),
    'locality':forms.TextInput(attrs={'class':'form-control'}),
    'city':forms.TextInput(attrs={'class':'form-control'}),
    'state':forms.Select(attrs={'class':'form-control'}),
    'zipcode':forms.NumberInput(attrs={'class':'form-control'})}
