from django.core.management.base import BaseCommand
from apparel.models import TShirtType, TShirtSize

class Command(BaseCommand):
    help = 'Sets up initial data for the apparel module'

    def handle(self, *args, **options):
        # Create T-shirt types
        tshirt_types = [
            {'name': 'Regular Fit', 'description': 'Standard fit t-shirt with straight cut'},
            {'name': 'Slim Fit', 'description': 'Slimmer cut t-shirt that fits closer to the body'}
        ]

        for type_data in tshirt_types:
            TShirtType.objects.get_or_create(
                name=type_data['name'],
                defaults={'description': type_data['description']}
            )
            self.stdout.write(self.style.SUCCESS(f"Created T-shirt type: {type_data['name']}"))

        # Create T-shirt sizes
        tshirt_sizes = [
            {'name': 'Small', 'code': 'S', 'description': 'Small size'},
            {'name': 'Medium', 'code': 'M', 'description': 'Medium size'},
            {'name': 'Large', 'code': 'L', 'description': 'Large size'},
            {'name': 'Extra Large', 'code': 'XL', 'description': 'Extra large size'},
            {'name': 'Double Extra Large', 'code': 'XXL', 'description': 'Double extra large size'},
            {'name': 'Triple Extra Large', 'code': 'XXXL', 'description': 'Triple extra large size'}
        ]

        for size_data in tshirt_sizes:
            TShirtSize.objects.get_or_create(
                name=size_data['name'],
                code=size_data['code'],
                defaults={'description': size_data['description']}
            )
            self.stdout.write(self.style.SUCCESS(f"Created T-shirt size: {size_data['name']} ({size_data['code']})"))

        self.stdout.write(self.style.SUCCESS('Successfully set up initial apparel data'))
