from django.db import migrations


SEED_LINKS = [
    # (column, label, url, target, order)
    ('who_we_are', 'About Us',      '/#about',                                           '_self',  0),
    ('who_we_are', 'Career',        'https://www.linkedin.com/company/FinalTarget/jobs', '_blank', 1),
    ('who_we_are', 'Portfolio',     '/portfolio/',                                        '_self',  2),
    ('who_we_are', 'Insights',      '/insights/',                                         '_self',  3),
    ('who_we_are', 'Support & FAQ', '/faq/',                                              '_self',  4),
    ('who_we_are', 'Contact',       '/contact/',                                          '_self',  5),

    ('products', 'Premium Domains',       '/shop/', '_self', 0),
    ('products', 'AI Products',           '/shop/', '_self', 1),
    ('products', 'Templates & Resources', '/shop/', '_self', 2),
    ('products', 'Business Starter Kits', '/shop/', '_self', 3),
    ('products', 'Software',              '/shop/', '_self', 4),
    ('products', 'Marketplace',           '/shop/', '_self', 5),

    ('services', 'Digital Transformation', '/services/digital-transformation/', '_self', 0),
    ('services', 'Software Development',   '/services/',                        '_self', 1),
    ('services', 'AI Solutions',           '/services/ai-solutions/',           '_self', 2),
    ('services', 'Web & App Development',  '/services/',                        '_self', 3),
    ('services', 'Growth Marketing',       '/services/',                        '_self', 4),
    ('services', 'Support & Maintenance',  '/services/',                        '_self', 5),

    ('subscriptions', 'FT Panel',        '/shop/', '_self', 0),
    ('subscriptions', 'FT Ads',          '/shop/', '_self', 1),
    ('subscriptions', 'FT BizHub',       '/shop/', '_self', 2),
    ('subscriptions', 'Hosting & Cloud', '/shop/', '_self', 3),
    ('subscriptions', 'Business Email',  '/shop/', '_self', 4),
    ('subscriptions', 'Website Care',    '/shop/', '_self', 5),
]


def seed(apps, schema_editor):
    FooterLink = apps.get_model('pages', 'FooterLink')
    Tenant     = apps.get_model('tenants', 'Tenant')
    tenant     = Tenant.objects.first()

    for column, label, url, target, order in SEED_LINKS:
        exists = FooterLink.objects.filter(tenant=tenant, column=column, label=label).exists()
        if not exists:
            FooterLink.objects.create(
                tenant=tenant,
                column=column,
                label=label,
                url=url,
                target=target,
                order=order,
                is_active=True,
            )


def unseed(apps, schema_editor):
    pass  # non-destructive reverse


class Migration(migrations.Migration):

    dependencies = [
        ('pages', '0012_footerlink_seed'),
        ('tenants', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(seed, unseed),
    ]
