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

from .views import PortfolioViewSet, StockViewSet, TransactionViewSet, AIUpdateView
from . import template_views

router = DefaultRouter()
router.register(r'portfolios', PortfolioViewSet, basename='invest-portfolio')
router.register(r'stocks', StockViewSet, basename='invest-stock')
router.register(r'transactions', TransactionViewSet, basename='invest-transaction')

# API URL patterns (mounted at /api/invest/ in core/urls.py)
api_urlpatterns = [
    path('', include(router.urls)),
    path('ai-update/', AIUpdateView.as_view(), name='invest-ai-update'),
]

# Template URL patterns (mounted at /invest/ in core/urls.py)
urlpatterns = [
    path('', template_views.dashboard, name='invest-dashboard'),
    path('portfolios/<int:pk>/', template_views.portfolio_detail, name='invest-portfolio-detail'),
    path('portfolios/<int:pk>/transactions/', template_views.portfolio_transactions, name='invest-portfolio-transactions'),
]
