from django.urls import path

from . import ui_views

app_name = "projects"

urlpatterns = [
    # QI Project Views
    path("", ui_views.project_list, name="project_list"),
    path("create/", ui_views.project_create, name="project_create"),
    path("create/from-template/<uuid:template_pk>/", ui_views.project_create, name="project_create_from_template"),
    path("<uuid:pk>/", ui_views.project_detail, name="project_detail"),
    path("<uuid:pk>/edit/", ui_views.project_edit, name="project_edit"),
    path("<uuid:pk>/delete/", ui_views.project_delete, name="project_delete"),
    # Task Management (legacy project-level + new phase-level)
    path("<uuid:project_pk>/tasks/add/", ui_views.task_create, name="task_create"),
    path("<uuid:project_pk>/tasks/<uuid:task_pk>/edit/", ui_views.task_edit, name="task_edit"),
    path("<uuid:project_pk>/tasks/<uuid:task_pk>/delete/", ui_views.task_delete, name="task_delete"),
    path("<uuid:project_pk>/tasks/<uuid:task_pk>/toggle/", ui_views.task_toggle_status, name="task_toggle_status"),
    # PDCA Phase Management
    path("<uuid:pk>/pdca/<str:phase>/", ui_views.pdca_phase_detail, name="pdca_phase_detail"),
    path("<uuid:pk>/pdca/<str:phase>/edit/", ui_views.pdca_phase_edit, name="pdca_phase_edit"),
    path("<uuid:project_pk>/pdca/<str:phase>/tasks/add/", ui_views.task_create, name="phase_task_create"),
    path("<uuid:project_pk>/pdca/<str:phase>/tasks/<uuid:task_pk>/edit/", ui_views.task_edit, name="phase_task_edit"),
    path(
        "<uuid:project_pk>/pdca/<str:phase>/tasks/<uuid:task_pk>/delete/",
        ui_views.task_delete,
        name="phase_task_delete",
    ),
    path(
        "<uuid:project_pk>/pdca/<str:phase>/tasks/<uuid:task_pk>/toggle/",
        ui_views.task_toggle_status,
        name="phase_task_toggle_status",
    ),
    # FOCUS Phase Management
    path("<uuid:pk>/focus/<str:phase>/", ui_views.focus_phase_detail, name="focus_phase_detail"),
    path("<uuid:pk>/focus/<str:phase>/edit/", ui_views.focus_phase_edit, name="focus_phase_edit"),
    path("<uuid:project_pk>/focus/<str:phase>/tasks/add/", ui_views.task_create, name="focus_phase_task_create"),
    path(
        "<uuid:project_pk>/focus/<str:phase>/tasks/<uuid:task_pk>/edit/",
        ui_views.task_edit,
        name="focus_phase_task_edit",
    ),
    path(
        "<uuid:project_pk>/focus/<str:phase>/tasks/<uuid:task_pk>/delete/",
        ui_views.task_delete,
        name="focus_phase_task_delete",
    ),
    path(
        "<uuid:project_pk>/focus/<str:phase>/tasks/<uuid:task_pk>/toggle/",
        ui_views.task_toggle_status,
        name="focus_phase_task_toggle_status",
    ),
    # Template Management
    path("templates/", ui_views.template_list, name="template_list"),
    path("templates/create/", ui_views.template_create, name="template_create"),
    path("templates/<uuid:pk>/", ui_views.template_detail, name="template_detail"),
    path("templates/<uuid:pk>/edit/", ui_views.template_edit, name="template_edit"),
    path("templates/<uuid:pk>/delete/", ui_views.template_delete, name="template_delete"),
    # Save Project as Template
    path("<uuid:pk>/save-as-template/", ui_views.project_save_as_template, name="project_save_as_template"),
    # Export
    path("<uuid:pk>/export/excel/", ui_views.project_export_excel, name="project_export_excel"),
    # PX Action Conversion
    path("convert-action/<uuid:action_pk>/", ui_views.convert_action_to_project, name="convert_action"),
    # HTMX Endpoints
    path("<uuid:project_pk>/htmx/tasks/<uuid:task_pk>/toggle/", ui_views.htmx_task_toggle_status, name="htmx_task_toggle"),
    path("<uuid:project_pk>/htmx/tasks/<uuid:task_pk>/delete/", ui_views.htmx_task_delete, name="htmx_task_delete"),
    path("<uuid:project_pk>/htmx/tasks/add/<str:phase_type>/<str:phase>/", ui_views.htmx_task_create, name="htmx_task_create"),
    path("<uuid:project_pk>/htmx/tasks/<uuid:task_pk>/edit-form/", ui_views.htmx_task_edit_form, name="htmx_task_edit_form"),
    path("<uuid:project_pk>/htmx/pdca/<str:phase>/column/", ui_views.htmx_pdca_column, name="htmx_pdca_column"),
    path("<uuid:project_pk>/htmx/focus/<str:phase>/column/", ui_views.htmx_focus_column, name="htmx_focus_column"),
    path("<uuid:project_pk>/htmx/phase/<str:phase_type>/<str:phase>/edit-form/", ui_views.htmx_phase_edit_form, name="htmx_phase_edit_form"),
]
