from rest_framework import serializers

from .models import Notification, NotificationTemplate


class NotificationSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notification
        fields = ["id", "user", "title", "message", "type", "is_read", "metadata", "created_at"]


class NotificationTemplateSerializer(serializers.ModelSerializer):
    channel_label = serializers.CharField(source="get_channel_display", read_only=True)

    class Meta:
        model = NotificationTemplate
        fields = [
            "id", "name", "channel", "channel_label", "purpose", "subject", "body",
            "provider_template_name", "is_active", "created_at", "updated_at",
        ]
        read_only_fields = ["id", "channel_label", "created_at", "updated_at"]
