from django.urls import path, include
from rest_framework import routers

from webservice_running import views
from webservice_running.views import *
from webservice_running.apiviews import *

from sharix_admin.apiviews import *
from sharix_admin.views import *

app_name = 'webservice_running'

router = routers.DefaultRouter()
router.register(r'webservice', OrdersLocalMVS)
router.register(r'personinfo', PersonInfoMVS)
router.register(r'frequentaddress', FrequentAddressMVS)
router.register(r'favoritecontacts', FavoriteContactsMVS)
router.register(r'preferredproviders', PreferredProvidersMVS)

urlpatterns_webadmin_local = [
    
    #TODO - make local pages based on Open with Local data. Now it points on Open Views, make your own to change

    path('local/', login_required(MainLocalView.as_view()), name='main_local'),

    #Order model SHOULD HAVE at least LIST, ADD, DETAIL, EDIT if that corresponds service idea, othervice Open models and pages might be enough
    path('orders_local/', login_required(OrdersLocalListView.as_view()), name='orders_local'),
    path('order_local/<int:pk>', login_required(OrderDetailView.as_view()), name='order_local_detail'),
    #todo - move from views.order_reg to this one
    path('order_local/add/', login_required(OrderCreateView.as_view()), name='order_local/add/'),
    path('order_local/edit/<int:pk>', login_required(OrderEditView.as_view()), name='order_local/edit'),

    #Resource model SHOULD HAVE at least LIST, ADD, DETAIL, EDIT if that corresponds service idea, othervice Open models and pages might be enough
    path('resources_local/', login_required(ResourcesLocalListView.as_view()), name='resources_local'),
    path('resource_local/<int:pk>', login_required(ResourceLocalDetailView.as_view()), name='resource_local_detail'),
    path('resource_local/add/', login_required(ResourceLocalCreate.as_view()), name='resource_local/add/'),
    path('resource_local/edit/<int:pk>', login_required(ResourceLocalEditView.as_view()), name='resource_local/edit'),
    
    #Provider model SHOULD HAVE at least LIST, DETAIL, EDIT if that corresponds service idea, othervice Open models and pages might be enough
#    path('providers_local/', login_required(ProvidersListView.as_view()), name='providers_local'),
#    path('provider_local/<str:pk>', login_required(ProviderDetailView.as_view()), name='provider_local_detail'),
#    path('provider_local/edit/<int:pk>', login_required(ProviderEditView.as_view()), name='provider_local_/edit'),

    #Client model SHOULD HAVE at least DETAIL, EDIT if that corresponds service idea, othervice Open models and pages might be enough
#    path('client_local/<int:pk>', login_required(ClientDetailView.as_view()), name="client_local"),
#    path('client_local/edit/<int:pk>', login_required(ClientEditView.as_view()), name='client_local/edit')

    #Service tariff SHOULD HAVE at least LIST, ADD, DETAIL, EDIT if that corresponds service idea, othervice Open models and pages might be enough
    path('service_tariffs_local/', login_required(ServiceTariffsListView.as_view()), name='service_tariffs_local'),
    #path('service_tariff_local/<int:pk>', login_required(ServiceTariffDetailView.as_view()), name='service_tariff_local_detail'),
    path('service_tariff_local/add/', login_required(ServiceTariffCreate.as_view()), name='service_tariff_local/add/'),
    path('service_tariff_local/edit/<int:pk>', login_required(ServiceTariffUpdateView.as_view()),
         name='service_tariff_local/edit/'),

    #Local Service Features
    path('frequent_address', views.order_reg, name="frequent_address"),
    path('favorite_contacts', views.order_reg, name="favorite_contacts"),
    path('preferred_providers', views.order_reg, name="preferred_providers"),
]

urlpatterns_api_local = [
#    path('map/providers/', get_nearest_providers, name='nearest_providers'),
]


urlpatterns = [
    path('', include(urlpatterns_webadmin_local)),
    path('api/', include(router.urls), name="webservice_running_api"),
    path('local/api/v1/', include(urlpatterns_api_local)),
]
