from django.urls import reverse_lazy
from django.views.generic import TemplateView, RedirectView
from django.shortcuts import render

from accounts.models import DepotUser
from booking.models import Booking
from containers.models import Container
from preinfo.models import Preinfo


# Create your views here.
class IndexView(TemplateView):
    template_name = 'landing-page.html'
    extra_context = {
        'title': 'Home',
        'description': 'This is the home page of the container application.',
    }

    def get(self, request, *args, **kwargs):
        return render(request, self.template_name, self.extra_context)



class DashboardRedirectView(RedirectView):
    is_permanent = False

    def get_redirect_url(self, *args, **kwargs):
        # if self.request.user.is_authenticated:
            if self.request.user.user_type == DepotUser.UserType.COMPANY_ADMIN:
                return reverse_lazy('client_dashboard')
            elif self.request.user.user_type == DepotUser.UserType.CLIENT:
                return reverse_lazy('client_dashboard')
            elif self.request.user.user_type == DepotUser.UserType.BARRIER_STAFF:
                return  reverse_lazy('barrier_dashboard')
            elif self.request.user.user_type == DepotUser.UserType.EMPLOYEE:
                return  reverse_lazy('employee_dashboard')
            elif self.request.user.user_type == DepotUser.UserType.ADMIN:
                return  reverse_lazy('employee_dashboard')
            return  reverse_lazy('index')








# class ClientPreinfoView(TemplateView):
#     template_name = 'client-preinfo-content.html'
#
#
#
#     def get(self, request, *args, **kwargs):
#         return render(request, self.template_name, self.extra_context)