from recruitment import views,views_frontend
from django.conf import settings
from django.contrib import admin

from django.urls import path, include
from django.conf.urls.static import static
from django.views.generic import RedirectView
from django.conf.urls.i18n import i18n_patterns
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'jobs', views.JobPostingViewSet)
router.register(r'candidates', views.CandidateViewSet)

# 1. URLs that DO NOT have a language prefix (admin, API, static files)
urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include(router.urls)),
    path('accounts/', include('allauth.urls')),

    path('i18n/', include('django.conf.urls.i18n')),
    # path('summernote/', include('django_summernote.urls')),
    # path('', include('recruitment.urls')),
    path("ckeditor5/", include('django_ckeditor_5.urls')),

    path('application/<slug:template_slug>/', views.application_submit_form, name='application_submit_form'),
    path('application/<slug:template_slug>/submit/', views.application_submit, name='application_submit'),
    path('application/<slug:slug>/apply/', views.application_detail, name='application_detail'),
    path('application/<slug:slug>/signup/', views.candidate_signup, name='candidate_signup'),
    path('application/<slug:slug>/success/', views.application_success, name='application_success'),
    # path('application/applicant/profile', views.applicant_profile, name='applicant_profile'),

    path('api/templates/', views.list_form_templates, name='list_form_templates'),
    path('api/templates/save/', views.save_form_template, name='save_form_template'),
    path('api/templates/<slug:template_slug>/', views.load_form_template, name='load_form_template'),
    path('api/templates/<slug:template_slug>/delete/', views.delete_form_template, name='delete_form_template'),
    path('api/webhook/',views.zoom_webhook_view,name='zoom_webhook_view'),

    path('sync/task/<str:task_id>/status/', views_frontend.sync_task_status, name='sync_task_status'),
    path('sync/history/', views_frontend.sync_history, name='sync_history'),
    path('sync/history/<slug:job_slug>/', views_frontend.sync_history, name='sync_history_job'),

]

urlpatterns += i18n_patterns(
    path('', include('recruitment.urls')),
)
# 2. URLs that DO have a language prefix (user-facing views)
# This includes the root path (''), which is handled by 'recruitment.urls'

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
