from django.urls import path, include
from rest_framework.routers import DefaultRouter
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework.permissions import AllowAny
from .views import (
    EmployeeViewSet, WorkTimeLogViewSet, LeaveViewSet, 
    OvertimeReportViewSet, ReportViewSet
)

# Create the router for HR-related views
router_hr = DefaultRouter()
router_hr.register(r'employees', EmployeeViewSet)
router_hr.register(r'work-time-logs', WorkTimeLogViewSet)
router_hr.register(r'leaves', LeaveViewSet)
router_hr.register(r'overtime-reports', OvertimeReportViewSet)
router_hr.register(r'reports', ReportViewSet)

# Swagger schema view for HR
schema_view_hr = get_schema_view(
    openapi.Info(
        title="Human Resources API",
        default_version='v1',
        description="API for managing HR-related data and operations",
        terms_of_service="https://www.example.com/terms/",
        contact=openapi.Contact(email="support@example.com"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(AllowAny,),
)

urlpatterns = [
    path('', include(router_hr.urls)),
    path('swagger/', schema_view_hr.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui-hr'),
    path('redoc/', schema_view_hr.with_ui('redoc', cache_timeout=0), name='schema-redoc-hr'),
]
