from rest_framework import serializers
from distributors.models import Distributors
from retailers.models import Retailer
from settings.models import (
    AppDashboardMessage,
    Operator,
    MRobotics,
    State,
    ServiceCategory,
    Banners,
)


class BannersSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = Banners
        fields = ["id", "name", "image"]


class AppDashboardMessageSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = AppDashboardMessage
        fields = [
            "id",
            "message",
        ]


class RetailerSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = Retailer
        fields = ["id", "name"]


class DistributorsSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = Distributors
        fields = ["id", "name"]


class OperatorSerializer(serializers.ModelSerializer):
    class Meta:
        model = Operator
        fields = [
            "id",
            "name",
            "operator_id",
            "operator_code",
            "icon",
            "is_active",
            "commission",
            "retailer_commission",
        ]


class ServiceCategorySerializer(serializers.ModelSerializer):
    operators = OperatorSerializer(many=True)

    class Meta:
        model = ServiceCategory
        fields = [
            "id",
            "name",
            "operators",
        ]


class MRoboticsSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    operator_name = serializers.ReadOnlyField(source="operator.name")

    class Meta:
        model = MRobotics
        fields = [
            "id",
            "lapu_id",
            "lapu_no",
            "operator",
            "operator_name",
            "balance",
            "is_active",
        ]


class StateSerializer(serializers.ModelSerializer):
    # business = BusinessSerializer(read_only=True)
    class Meta:
        model = State
        fields = ["id", "name", "is_active"]
