from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

from django.http import JsonResponse

# Custom Admin Branding
admin.site.site_header = "SONICTECH Enterprise CMS"
admin.site.site_title = "SONICTECH Admin Portal"
admin.site.index_title = "Welcome to SONICTECH Management Dashboard"

def api_root_view(request):
    return JsonResponse({
        "status": "online",
        "company": "SONICTECH COMPANY LIMITED",
        "message": "SONICTECH Enterprise API Backend is operational.",
        "admin_portal": "/admin/",
        "api_endpoints": "/api/",
        "website": "https://sonictech.co.tz/"
    })

urlpatterns = [
    path('', api_root_view, name='api-root'),
    path('admin/', admin.site.urls),
    path('api/', include('config.api_urls')),
]

from django.urls import re_path
from django.views.static import serve

# Serve static and media files directly on shared hosting
urlpatterns += [
    re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
    re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
]
