from django.contrib import admin
from .models import RecommerceIntegration, WooCommerceIntegration


@admin.register(RecommerceIntegration)
class RecommerceIntegrationAdmin(admin.ModelAdmin):
    """Админка для Recommerce интеграции"""
    list_display = ['__str__', 'is_active', 'is_configured', 'updated_at']
    list_filter = ['is_active']
    readonly_fields = ['created_at', 'updated_at']

    fieldsets = (
        ('Основное', {'fields': ('name', 'is_active')}),
        ('API настройки', {'fields': ('store_url', 'api_token')}),
        ('Синхронизация', {'fields': ('auto_sync_products', 'import_orders')}),
        ('Служебное', {'fields': ('created_at', 'updated_at'), 'classes': ('collapse',)}),
    )


@admin.register(WooCommerceIntegration)
class WooCommerceIntegrationAdmin(admin.ModelAdmin):
    """Админка для WooCommerce интеграции"""
    list_display = ['__str__', 'is_active', 'is_configured', 'updated_at']
    list_filter = ['is_active']
    readonly_fields = ['created_at', 'updated_at']

    fieldsets = (
        ('Основное', {'fields': ('name', 'is_active')}),
        ('API настройки', {'fields': ('store_url', 'consumer_key', 'consumer_secret', 'api_version')}),
        ('Синхронизация', {'fields': ('auto_sync_products', 'import_orders')}),
        ('Служебное', {'fields': ('created_at', 'updated_at'), 'classes': ('collapse',)}),
    )
