from django.urls import include, path
from rest_framework.routers import DefaultRouter

from .views import (
    AmmoViewSet,
    BipodViewSet,
    BrassViewSet,
    BulletViewSet,
    FirearmViewSet,
    MagazineViewSet,
    PowderViewSet,
    PrimerViewSet,
    ReloadedAmmoBatchViewSet,
    ReloadRecipeViewSet,
    RigViewSet,
    ScopeViewSet,
    SuppressorViewSet,
    UserGearViewSet,
)

router = DefaultRouter()

# Gear catalog — per type
router.register(r'gears/firearms',    FirearmViewSet,    basename='firearm')
router.register(r'gears/scopes',      ScopeViewSet,      basename='scope')
router.register(r'gears/suppressors', SuppressorViewSet, basename='suppressor')
router.register(r'gears/bipods',      BipodViewSet,      basename='bipod')
router.register(r'gears/magazines',   MagazineViewSet,   basename='magazine')

# Ammo catalog
router.register(r'gears/ammo', AmmoViewSet, basename='ammo')

# Reloading components (admin CRUD, read-only for users)
router.register(r'gears/components/primers', PrimerViewSet, basename='primer')
router.register(r'gears/components/brass',   BrassViewSet,  basename='brass')
router.register(r'gears/components/bullets', BulletViewSet, basename='bullet')
router.register(r'gears/components/powders', PowderViewSet, basename='powder')

# User inventory
router.register(r'inventory', UserGearViewSet, basename='usergear')

# Rigs
router.register(r'rigs', RigViewSet, basename='rig')

# Reload development (user-owned)
router.register(r'reloading/recipes', ReloadRecipeViewSet, basename='reload-recipe')
router.register(r'reloading/batches', ReloadedAmmoBatchViewSet, basename='reload-batch')

urlpatterns = [
    path('', include(router.urls)),
]
