from django.db import models
from datetime import datetime

# Create your models here.

class Traveler(models.Model):
    date_of_birth = models.DateField(null=True, default=datetime.now())
    first_name = models.CharField(max_length=255, null=True)
    last_name = models.CharField(max_length=255, null=True)
    gender = models.CharField(max_length=10, null=True)
    email_address = models.EmailField(null=True)
    # Phones
    device_type = models.CharField(max_length=255, null=True)
    country_calling_code = models.CharField(max_length=10, null=True)
    phone_number = models.CharField(max_length=20, null=True)
    # Documents
    document_type = models.CharField(max_length=255, null=True)
    birth_place = models.CharField(max_length=255, null=True)
    issuance_location = models.CharField(max_length=255, null=True)
    issuance_date = models.DateField(null=True, default=datetime.now())
    document_number = models.CharField(max_length=255, null=True)
    expiry_date = models.DateField(null=True, default=datetime.now())
    issuance_country = models.CharField(max_length=255, null=True)
    validity_country = models.CharField(max_length=255, null=True)
    nationality = models.CharField(max_length=255, null=True)
    holder = models.BooleanField(default=False)
    # Flight details
    price = models.DecimalField(max_digits=10, decimal_places=2)
    created = models.DateField(null=True, default=datetime.now())
    reference = models.CharField(max_length=255, null=True)
    confirmed = models.CharField(max_length=20, null=True)
    first_name_flight = models.CharField(max_length=255, null=True)
    last_name_flight = models.CharField(max_length=255, null=True)
    first_flight_departure_airport = models.CharField(max_length=3, null=True)
    first_flight_airline_logo = models.URLField()
    first_flight_airline = models.CharField(max_length=255, null=True)
    first_flight_departure_date = models.TimeField()
    departure_date = models.DateField()
    first_flight_arrival_airport = models.CharField(max_length=3, null=True)
    first_flight_arrival_date = models.TimeField()
    # datestamps
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return f'{self.id} {self.first_name}'

    class Meta:
        verbose_name_plural = 'Traveler booking'



# "id": "1",
#             "dateOfBirth": request.POST.get("dateOfBirth"),
#             "name": {"firstName": request.POST.get("firstName"), "lastName": request.POST.get("lastName")},
#             "gender": request.POST.get("gender"),
#             "contact": {
#                 "emailAddress": request.POST.get("emailAddress"),
#                 "phones": [
#                     {
#                         "deviceType": request.POST.get("deviceType"),
#                         "countryCallingCode": request.POST.get("countryCallingCode"),
#                         "number":request.POST.get("phone_number"),
#                     }
#                 ],
#             },
#             "documents": [
#                 {
#                     "documentType": request.POST.get("documentType"),
#                     "birthPlace": request.POST.get("birthPlace"),
#                     "issuanceLocation": request.POST.get("issuanceLocation"),
#                     "issuanceDate": request.POST.get("issuanceDate"),
#                     "number": request.POST.get("documentNumber"),
#                     "expiryDate": request.POST.get("expiryDate"),
#                     "issuanceCountry": request.POST.get("issuanceCountry"),
#                     "validityCountry": request.POST.get("validityCountry"),
#                     "nationality": request.POST.get("nationality"),
#                     "holder": True,
#                 }
#             ],
#         }

