from django.urls import path

from apps.rims.scholarships import views

app_name = "rims_scholarships"

urlpatterns = [
    # ── Scholarship programmes (staff) ────────────────────────────────────────
    path("programmes/", views.ScholarshipListView.as_view(), name="scholarship_list"),
    path("programmes/new/", views.ScholarshipCreateView.as_view(), name="scholarship_create"),
    path("programmes/<int:pk>/", views.ScholarshipDetailView.as_view(), name="scholarship_detail"),
    path("programmes/<int:pk>/edit/", views.ScholarshipUpdateView.as_view(), name="scholarship_edit"),

    # ── Scholars (staff) ──────────────────────────────────────────────────────
    path("scholars/", views.ScholarListView.as_view(), name="scholar_list"),
    path("scholars/enrol/", views.ScholarEnrolView.as_view(), name="scholar_enrol"),
    path("scholars/<int:pk>/", views.ScholarDetailView.as_view(), name="scholar_detail"),
    path("scholars/<int:pk>/edit/", views.ScholarUpdateView.as_view(), name="scholar_edit"),
    path("scholars/<int:pk>/status/", views.ScholarStatusUpdateView.as_view(), name="scholar_status_update"),

    # ── Scholarship calls (public + authenticated) ────────────────────────────
    path("calls/", views.ScholarshipCallListView.as_view(), name="call_list"),
    path("calls/<slug:slug>/", views.ScholarshipCallDetailView.as_view(), name="call_detail"),

    # ── Student self-service portal ───────────────────────────────────────────
    path("my/", views.MyScholarDashboardView.as_view(), name="my_dashboard"),
    path("my/scholarships/", views.MyScholarshipsListView.as_view(), name="my_scholarships"),
    path("my/<int:pk>/", views.MyScholarshipDetailView.as_view(), name="my_scholarship_detail"),

    # Academic profile
    path(
        "my/<int:scholar_pk>/academic-profile/",
        views.MyAcademicProfileUpdateView.as_view(),
        name="my_academic_profile",
    ),

    # Study status (pause / defer / resume)
    path(
        "my/<int:scholar_pk>/status/",
        views.MyStatusUpdateView.as_view(),
        name="my_status_update",
    ),

    # Progress reports — structured submission (self-service)
    path(
        "my/<int:scholar_pk>/progress-reports/new/",
        views.MyProgressReportCreateView.as_view(),
        name="my_progress_report_create",
    ),
    # Legacy URL kept for backward compat (redirects to structured form)
    path(
        "scholars/<int:scholar_pk>/progress-reports/new/",
        views.MyProgressReportCreateView.as_view(),
        name="progress_report_create",
    ),

    # Graduation submission (self-service)
    path(
        "my/<int:scholar_pk>/graduation/submit/",
        views.MyGraduationSubmitView.as_view(),
        name="my_graduation_submit",
    ),

    # ── Stipends (Finance Officer + Grants Manager) ───────────────────────────
    path("stipends/", views.StipendListView.as_view(), name="stipend_list"),
    path("stipends/new/", views.StipendCreateView.as_view(), name="stipend_create"),
    path(
        "scholars/<int:scholar_pk>/stipends/new/",
        views.StipendCreateView.as_view(),
        name="stipend_create_for_scholar",
    ),

    # ── Officer dashboard ─────────────────────────────────────────────────────
    path("officer/", views.ScholarshipOfficerDashboardView.as_view(), name="officer_dashboard"),

    # ── Scholar origin map ────────────────────────────────────────────────────
    path("scholars/map/", views.ScholarOriginMapView.as_view(), name="scholar_origin_map"),

    # ── At-risk / overdue scholars report ─────────────────────────────────────
    path("scholars/at-risk/", views.ScholarAtRiskView.as_view(), name="scholar_at_risk"),
]
