from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import TemplateView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('apps.users.urls')),
    path('api/', include('apps.leads.urls')),
    path('api/costing/', include('apps.costing.urls')),
    path('api/approvals/', include('apps.approvals.urls')),
    path('api/projects/', include('apps.projects.urls')),
    path('api/tasks/', include('apps.tasks.urls')),
    path('api/finance/', include('apps.finance.urls')),
    path('api/', include('apps.discussions.urls')),
    path('api/', include('apps.notifications.urls')),
    path('api/reports/', include('apps.reports.urls')),
]

from django.views.static import serve

# Serve media files (Forced for local testing with DEBUG=False)
urlpatterns += [
    re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
]

# Catch-all for React Frontend (must be last)
urlpatterns += [
    re_path(r'^.*$', TemplateView.as_view(template_name='index.html')),
]
