from django.core.management.base import BaseCommand
from apps.appreciation.models import AppreciationCategory


class Command(BaseCommand):
    help = 'Create Patient Feedback Appreciation category'

    def handle(self, *args, **options):
        # Check if category already exists
        existing = AppreciationCategory.objects.filter(
            code='patient_feedback'
        ).first()

        if existing:
            self.stdout.write(
                self.style.WARNING(
                    f'Category "Patient Feedback Appreciation" already exists.'
                )
            )
            return

        # Create the category
        category = AppreciationCategory.objects.create(
            hospital=None,  # System-wide category
            code='patient_feedback',
            name_en='Patient Feedback Appreciation',
            name_ar='تقدير ملاحظات المرضى',
            description_en='Appreciation received from patient feedback',
            description_ar='تقدير مستلم من ملاحظات المرضى',
            icon='bi-heart',
            color='#388e3c',
            order=100,
            is_active=True
        )

        self.stdout.write(
            self.style.SUCCESS(
                f'Successfully created "Patient Feedback Appreciation" category (ID: {category.id})'
            )
        )
