from django.urls import path
from . import views
from . import planilha_views
from .megasena_aposta import megasena_aposta
from .megasena_portal import megasena_portal

app_name = 'api'

urlpatterns = [
    # Auth
    path('auth/google/', views.google_auth, name='google-auth'),
    path('auth/apple/', views.apple_auth, name='apple-auth'),
    path('auth/me/', views.me, name='auth-me'),
    path('auth/account/', views.delete_account, name='delete-account'),
    path('auth/location/', views.update_location, name='update-location'),
    path('auth/radius/', views.update_radius, name='update-radius'),
    path('auth/notification-settings/', views.notification_settings, name='notification-settings'),
    path('auth/goals/', views.goals_view, name='goals'),

    # Products
    path('produtos/', views.product_list_create, name='product-list-create'),
    path('produtos/<int:product_id>/', views.product_detail, name='product-detail'),
    path('produtos/<int:product_id>/historico/', views.product_history, name='product-history'),

    # Notifications
    path('notificacoes/', views.notification_list, name='notification-list'),
    path('notificacoes/unread-count/', views.notification_unread_count, name='notification-unread-count'),
    path('notificacoes/<int:notification_id>/', views.notification_detail, name='notification-detail'),
    path('notificacoes/<int:notification_id>/read/', views.notification_mark_read, name='notification-mark-read'),
    path('notificacoes/read-all/', views.notification_read_all, name='notification-read-all'),
    path('notificacoes/delete-all/', views.notification_delete_all, name='notification-delete-all'),
    path('notificacoes/<int:notification_id>/delete/', views.notification_delete, name='notification-delete'),

    # Estabelecimentos (Vendors)
    path('estabelecimentos/', views.vendor_list, name='vendor-list'),
    path('estabelecimentos/<int:vendor_id>/', views.vendor_detail, name='vendor-detail'),
    path('estabelecimentos/<int:vendor_id>/compras/', views.vendor_orders, name='vendor-orders'),

    # Compras (Orders)
    path('compras/<int:order_id>/', views.order_detail, name='order-detail'),

    # Import
    path('import/', views.import_sefaz, name='import-sefaz'),
    path('import/status/', views.import_status, name='import-status'),

    # Contas Básicas
    path('contas/', views.conta_list_create, name='conta-list-create'),
    path('contas/<int:conta_id>/', views.conta_detail, name='conta-detail'),
    path('contas/<int:conta_id>/historico/', views.conta_history, name='conta-history'),

    # Dashboard
    path('dashboard/', views.dashboard_data, name='dashboard-data'),
    path('dashboard/settings/', views.dashboard_settings, name='dashboard-settings'),

    # Planilha de orçamento
    path('planilha/', planilha_views.planilha_export, name='planilha-export'),

    # Family Groups
    path('family/', views.family_detail, name='family-detail'),
    path('family/invite/', views.family_invite, name='family-invite'),
    path('family/invites/', views.family_invites, name='family-invites'),
    path('family/invites/<int:invite_id>/accept/', views.family_invite_accept, name='family-invite-accept'),
    path('family/invites/<int:invite_id>/reject/', views.family_invite_reject, name='family-invite-reject'),
    path('family/members/<int:user_id>/', views.family_remove_member, name='family-remove-member'),

    # Loterias (internal portal endpoint, consumed by the Drupal-cron)
    path('internal/loterias/megasena/', megasena_portal, name='megasena-portal'),
    # Aposta automática (Drupal scheduler chama nas janelas Ter/Qui/Sáb)
    path('internal/loterias/megasena/aposta/', megasena_aposta, name='megasena-aposta'),
]
