from django.core.management.base import BaseCommand

from testimonials.models import Testimonial


STORIES = [
    {
        'full_name': 'Grace Phiri',
        'role': 'Senior Data Scientist',
        'company': 'First Quantum Minerals',
        'story': 'I had been searching for a job in data science for 8 months. A colleague suggested PEZAJOB. I created my profile on a Monday, and by Friday I had 3 interview requests. Six weeks later I signed my offer letter.',
        'rating': 5,
        'testimonial_type': Testimonial.Type.SEEKER,
        'is_featured': True,
        'avatar_url': 'https://images.unsplash.com/photo-1580489944761-15a19d654956?w=150&q=70&fit=crop&crop=face',
    },
    {
        'full_name': 'David Mwanza',
        'role': 'HR Manager',
        'company': 'Airtel Zambia',
        'story': 'PEZAJOB helped us fill three critical engineering roles in under 30 days. The quality of candidates and the platform analytics saved our team countless hours.',
        'rating': 5,
        'testimonial_type': Testimonial.Type.COMPANY,
    },
    {
        'full_name': 'Chanda Banda',
        'role': 'Accountant',
        'company': 'ZANACO Bank',
        'story': 'The salary guide and interview prep articles gave me the confidence to negotiate a 20% higher offer than my previous role.',
        'rating': 5,
        'testimonial_type': Testimonial.Type.SEEKER,
    },
]


class Command(BaseCommand):
    help = 'Seed testimonials'

    def handle(self, *args, **options):
        for data in STORIES:
            Testimonial.objects.update_or_create(
                full_name=data['full_name'],
                role=data['role'],
                defaults={**data, 'is_approved': True},
            )
        self.stdout.write(self.style.SUCCESS(f'Seeded {Testimonial.objects.count()} testimonials'))
