from rest_framework import serializers
# from product.models import Category, Product, Images, Tags
from settings.models import Setting

class SettingSerializer(serializers.ModelSerializer):
    b_logo = serializers.SerializerMethodField()
    w_logo = serializers.SerializerMethodField()

    class Meta:
        model = Setting
        fields = ['title', 'meta_title', 'meta_description', 'phone', 'url', 'email', 'facebook', 'x',
                  'instagram', 'whatsapp', 'slogan', 'w_logo', 'b_logo', 'created_at',
                  'updated_at', 'is_active']

    def get_w_logo(self, obj):
        if obj.w_logo:
            request = self.context.get('request')
            if request:
                return obj.w_logo.url
            else:
                # Fallback olarak manuel URL oluşturma
                return None
        return None
    def get_b_logo(self, obj):
        if obj.b_logo:
            request = self.context.get('request')
            if request:
                return obj.b_logo.url
            else:
                # Fallback olarak manuel URL oluşturma
                return None
        return None
