from django import forms
from emoji_picker.widgets import EmojiPickerTextInputAdmin, EmojiPickerTextareaAdmin
from image_uploader_widget.widgets import ImageUploaderWidget
from .models import Category, Segment, Size, Season, Color, Product, Picture, Note


class CategoryAdminForm(forms.ModelForm):
    class Meta:
        model = Category
        fields = [
            'label',
        ]
        widgets = {
            'label_fr': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_en': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_ar': EmojiPickerTextInputAdmin(attrs={'dir': 'rtl'}),
        }


class SegmentAdminForm(forms.ModelForm):
    class Meta:
        model = Segment
        fields = [
            'label',
            'picture',
        ]
        widgets = {
            'label_fr': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_en': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_ar': EmojiPickerTextInputAdmin(attrs={'dir': 'rtl'}),
            'picture': ImageUploaderWidget(),
        }


class SizeAdminForm(forms.ModelForm):
    class Meta:
        model = Size
        fields = [
            'label',
        ]
        widgets = {
            'label': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
        }


class SeasonAdminForm(forms.ModelForm):
    class Meta:
        model = Season
        fields = [
            'label',
        ]
        widgets = {
            'label_en': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_fr': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_ar': EmojiPickerTextInputAdmin(attrs={'dir': 'rtl'}),
        }


class ColorAdminForm(forms.ModelForm):
    class Meta:
        model = Color
        fields = [
            'label',
            'color',
        ]
        widgets = {
            'label_en': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_fr': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'label_ar': EmojiPickerTextInputAdmin(attrs={'dir': 'rtl'}),
        }


class ProductAdminForm(forms.ModelForm):
    class Meta:
        model = Product
        fields = [
            'category',
            'segment',
            'sizes',
            'seasons',
            'colors',
            'reference',
            'title',
            'description',
            'youtube_video',
            'price',
            'previous_price',
            'available',
        ]
        widgets = {
            'title_en': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'title_fr': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'title_ar': EmojiPickerTextInputAdmin(attrs={'dir': 'rtl'}),
            'description_en': EmojiPickerTextareaAdmin(attrs={'dir': 'ltr'}),
            'description_fr': EmojiPickerTextareaAdmin(attrs={'dir': 'ltr'}),
            'description_ar': EmojiPickerTextareaAdmin(attrs={'dir': 'rtl'}),
        }


class PictureAdminForm(forms.ModelForm):
    class Meta:
        model = Picture
        fields = [
            'picture',
        ]
        widgets = {
            'picture': ImageUploaderWidget(),
        }


class NoteAdminForm(forms.ModelForm):
    class Meta:
        model = Note
        fields = [
            'content',
        ]
        widgets = {
            'content_en': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'content_fr': EmojiPickerTextInputAdmin(attrs={'dir': 'ltr'}),
            'content_ar': EmojiPickerTextInputAdmin(attrs={'dir': 'rtl'}),
        }
