from django.urls import include, path
from django.views.generic import RedirectView

from servala.frontend import views

urlpatterns = [
    path("accounts/profile/", views.ProfileView.as_view(), name="profile"),
    path("accounts/logout/", views.LogoutView.as_view(), name="logout"),
    path(
        "invitations/<str:secret>/accept/",
        views.InvitationAcceptView.as_view(),
        name="invitation.accept",
    ),
    path(
        "organizations/",
        views.OrganizationSelectionView.as_view(),
        name="organization.selection",
    ),
    path(
        "organizations/create",
        views.OrganizationCreateView.as_view(),
        name="organization.create",
    ),
    path(
        "org/<slug:organization>/",
        include(
            [
                path(
                    "details/",
                    views.OrganizationUpdateView.as_view(),
                    name="organization.details",
                ),
                path(
                    "details/invitations/<int:pk>/delete/",
                    views.InvitationDeleteView.as_view(),
                    name="invitation.delete",
                ),
                path(
                    "services/",
                    views.ServiceListView.as_view(),
                    name="organization.services",
                ),
                path(
                    "services/<slug:slug>/",
                    views.ServiceDetailView.as_view(),
                    name="organization.service",
                ),
                path(
                    "services/<slug:slug>/offering/<int:pk>/",
                    views.ServiceInstanceCreateView.as_view(),
                    name="organization.instance.create",
                ),
                path(
                    "",
                    views.OrganizationDashboardView.as_view(),
                    name="organization.dashboard",
                ),
                path(
                    "instances/",
                    views.ServiceInstanceListView.as_view(),
                    name="organization.instances",
                ),
                path(
                    "instances/<slug:slug>/",
                    views.ServiceInstanceDetailView.as_view(),
                    name="organization.instance",
                ),
                path(
                    "instances/<slug:slug>/update/",
                    views.ServiceInstanceUpdateView.as_view(),
                    name="organization.instance.update",
                ),
                path(
                    "instances/<slug:slug>/delete/",
                    views.ServiceInstanceDeleteView.as_view(),
                    name="organization.instance.delete",
                ),
                path(
                    "support/",
                    views.SupportView.as_view(),
                    name="organization.support",
                ),
            ]
        ),
    ),
    path(
        "",
        RedirectView.as_view(pattern_name="frontend:organization.selection"),
        name="index",
    ),
]
