# api/urls.py
from django.urls import path
from . import views

app_name = 'api'

urlpatterns = [

    # ── Auth ──────────────────────────────────────────────────────
    path('auth/login/',   views.api_login,   name='login'),
    path('auth/logout/',  views.api_logout,  name='logout'),
    path('auth/me/',      views.api_me,      name='me'),

    # ── Users ─────────────────────────────────────────────────────
    path('users/',        views.api_users,       name='users'),
    path('users/<int:pk>/', views.api_user_detail, name='user_detail'),

    # ── Branches ──────────────────────────────────────────────────
    path('branches/',          views.api_branches,        name='branches'),
    path('branches/<int:pk>/', views.api_branch_detail,   name='branch_detail'),

    # ── Categories ────────────────────────────────────────────────
    path('categories/',          views.api_categories,        name='categories'),
    path('categories/<int:pk>/', views.api_category_detail,   name='category_detail'),

    # ── Products ──────────────────────────────────────────────────
    path('products/',                      views.api_products,       name='products'),
    path('products/<int:pk>/',             views.api_product_detail, name='product_detail'),
    path('products/<int:pk>/stock/',       views.api_product_stock,  name='product_stock'),

    # ── Stock History ─────────────────────────────────────────────
    path('stock-history/',   views.api_stock_history,  name='stock_history'),

    # ── Suppliers ─────────────────────────────────────────────────
    path('suppliers/',          views.api_suppliers,        name='suppliers'),
    path('suppliers/<int:pk>/', views.api_supplier_detail,  name='supplier_detail'),

    # ── Purchase Orders ───────────────────────────────────────────
    path('purchase-orders/',          views.api_purchase_orders,        name='purchase_orders'),
    path('purchase-orders/<int:pk>/', views.api_purchase_order_detail,  name='purchase_order_detail'),

    # ── Orders (POS Sales) ────────────────────────────────────────
    path('orders/',               views.api_orders,       name='orders'),
    path('orders/create/',        views.api_order_create, name='order_create'),
    path('orders/<int:pk>/',      views.api_order_detail, name='order_detail'),

    # ── Credit ────────────────────────────────────────────────────
    path('orders/credit/',                views.api_credit_orders,  name='credit_orders'),
    path('orders/<int:pk>/clear-credit/', views.api_clear_credit,   name='clear_credit'),

    # ── Customers ─────────────────────────────────────────────────
    path('customers/',          views.api_customers,       name='customers'),
    path('customers/<int:pk>/', views.api_customer_detail, name='customer_detail'),

    # ── Dashboard ─────────────────────────────────────────────────
    path('dashboard/',         views.api_dashboard,         name='dashboard'),

    # ── P&L Report ────────────────────────────────────────────────
    path('pnl/',               views.api_pnl,               name='pnl'),

    # ── Staff Performance ─────────────────────────────────────────
    path('staff-performance/', views.api_staff_performance,  name='staff_performance'),

    # ── Audit Log ─────────────────────────────────────────────────
    path('audit-log/',         views.api_audit_log,          name='audit_log'),

    # ── Suspicious Activity ───────────────────────────────────────
    path('suspicious/',               views.api_suspicious,         name='suspicious'),
    path('suspicious/<int:pk>/resolve/', views.api_suspicious_resolve, name='suspicious_resolve'),

    # ── Exports ───────────────────────────────────────────────────
    path('exports/orders/',   views.api_export_orders,   name='export_orders'),
    path('exports/products/', views.api_export_products, name='export_products'),

    # ── Barcode Lookup ────────────────────────────────────────────
    path('barcode/',               views.api_barcode_lookup, name='barcode_lookup'),

    # ── System Info ───────────────────────────────────────────────
    path('system/',            views.api_system_info,        name='system_info'),
]
