from django.contrib import admin

from mission.models import Mission, MissionCategory, MissionParticipant, MissionReply


@admin.register(MissionCategory)
class MissionCategoryAdmin(admin.ModelAdmin):
    list_display = ["id", "merchant", "name", "payload_processor", "speech_enabled", "created_at"]
    list_filter = ["merchant", "payload_processor", "speech_enabled", "created_at"]
    search_fields = ["name"]
    readonly_fields = ["created_at", "updated_at"]


@admin.register(Mission)
class MissionAdmin(admin.ModelAdmin):
    list_display = [
        "id",
        "merchant",
        "category",
        "creator",
        "is_urgent",
        "is_completed",
        "is_cancelled",
        "created_at",
    ]
    list_filter = ["merchant", "category", "is_urgent", "is_completed", "is_cancelled", "created_at"]
    search_fields = ["description", "creator__name"]
    readonly_fields = ["created_at", "updated_at"]


@admin.register(MissionParticipant)
class MissionParticipantAdmin(admin.ModelAdmin):
    list_display = ["id", "merchant", "mission", "employee", "created_at"]
    list_filter = ["merchant", "created_at"]
    search_fields = ["employee__name"]
    readonly_fields = ["created_at", "updated_at"]


@admin.register(MissionReply)
class MissionReplyAdmin(admin.ModelAdmin):
    list_display = ["id", "merchant", "mission", "responder", "ends_task", "is_rejected", "replied_at"]
    list_filter = ["merchant", "ends_task", "is_rejected", "replied_at"]
    search_fields = ["content", "responder__name"]
    readonly_fields = ["created_at", "updated_at"]
