"""
Appreciation URLs - URL configuration for appreciation API and UI
"""
from django.urls import include, path
from rest_framework.routers import DefaultRouter

from apps.appreciation.views import (
    AppreciationBadgeViewSet,
    AppreciationCategoryViewSet,
    AppreciationStatsViewSet,
    AppreciationViewSet,
    LeaderboardView,
    UserBadgeViewSet,
)

from apps.appreciation import ui_views

router = DefaultRouter()
router.register(r'categories', AppreciationCategoryViewSet, basename='appreciation-category')
router.register(r'appreciations', AppreciationViewSet, basename='appreciation')
router.register(r'stats', AppreciationStatsViewSet, basename='appreciation-stats')
router.register(r'badges', AppreciationBadgeViewSet, basename='appreciation-badge')
router.register(r'user-badges', UserBadgeViewSet, basename='user-badge')

app_name = 'appreciation'

urlpatterns = [
    # API Routes
    path('api/', include(router.urls)),
    path('api/leaderboard/', LeaderboardView.as_view(), name='api-leaderboard'),

    # UI Routes
    path('', ui_views.appreciation_list, name='appreciation_list'),
    path('detail/<uuid:pk>/', ui_views.appreciation_detail, name='appreciation_detail'),
    path('detail/<uuid:pk>/activate/', ui_views.appreciation_activate, name='appreciation_activate'),
    path('detail/<uuid:pk>/send/', ui_views.appreciation_send, name='appreciation_send'),
    path('acknowledge/<uuid:pk>/', ui_views.appreciation_acknowledge, name='appreciation_acknowledge'),
    path('leaderboard/', ui_views.leaderboard_view, name='leaderboard_view'),
    path('badges/', ui_views.my_badges_view, name='my_badges_view'),

    # Admin: Category Management
    path('admin/categories/', ui_views.category_list, name='category_list'),
    path('admin/categories/create/', ui_views.category_create, name='category_create'),
    path('admin/categories/<uuid:pk>/edit/', ui_views.category_edit, name='category_edit'),
    path('admin/categories/<uuid:pk>/delete/', ui_views.category_delete, name='category_delete'),

    # Admin: Badge Management
    path('admin/badges/', ui_views.badge_list, name='badge_list'),
    path('admin/badges/create/', ui_views.badge_create, name='badge_create'),
    path('admin/badges/<uuid:pk>/edit/', ui_views.badge_edit, name='badge_edit'),
    path('admin/badges/<uuid:pk>/delete/', ui_views.badge_delete, name='badge_delete'),

    # Restore deleted appreciation
    path('admin/appreciations/<uuid:pk>/restore/', ui_views.appreciation_restore, name='admin_appreciation_restore'),

    # AJAX Helpers
    path('ajax/users/', ui_views.get_users_by_hospital, name='get_users_by_hospital'),
    path('ajax/staff/', ui_views.get_staff_by_hospital, name='get_staff_by_hospital'),
    path('ajax/physicians/', ui_views.get_physicians_by_hospital, name='get_physicians_by_hospital'),
    path('ajax/departments/', ui_views.get_departments_by_hospital, name='get_departments_by_hospital'),
    path('ajax/summary/', ui_views.appreciation_summary_ajax, name='appreciation_summary_ajax'),

    # Public submission (no auth required)
    path('public/submit/', ui_views.public_appreciation_submit, name='public_appreciation_submit'),
]
