from django.contrib.auth.views import LoginView, LogoutView
from django.urls import path
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

from .api import current_user_api
from .forms import LoginForm
from .views import home, kitchen_board, order_detail, table_detail

urlpatterns = [
    path("", home, name="home"),
    path(
        "login/",
        LoginView.as_view(
            template_name="registration/login.html",
            authentication_form=LoginForm,
            redirect_authenticated_user=True,
        ),
        name="login",
    ),
    path("logout/", LogoutView.as_view(), name="logout"),
    path("kitchen/", kitchen_board, name="kitchen_board"),
    path("tables/<int:table_id>/", table_detail, name="table_detail"),
    path("orders/<int:order_id>/", order_detail, name="order_detail"),
    path("api/auth/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
    path("api/auth/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
    path("api/auth/me/", current_user_api, name="current_user_api"),
]
