from django.db import models

# Create your models here.


class Group(models.Model):
    name = models.CharField(max_length=100)
    def __str__(self):
        return self.name


class Country(models.Model):
    name = models.CharField(max_length=100)
    code = models.CharField(max_length=5)

class AddressBook(models.Model):
    first_name = models.CharField(max_length=100)
    middle_name = models.CharField(max_length=100, blank=True, null=True)
    last_name = models.CharField(max_length=100)
    country = models.ForeignKey(Country, null=True, on_delete=models.SET_NULL)
    group = models.ManyToManyField(Group, blank=True)


class Contact(models.Model):
    TYPE_CHOICES = (
        ('Email', 'Email'),
        ('Mobile', 'Mobile'),
        ('Phone', 'Phone'),
        ('Whatsapp', 'Whatsapp'),
    )
    type = models.CharField(max_length=20, choices=TYPE_CHOICES)
    contact = models.CharField(max_length=100)
    addressbook = models.ForeignKey(AddressBook, on_delete=models.CASCADE)


class SocialMedia(models.Model):
    TYPE_CHOICES = (
        ('Facebook', 'Facebook'),
        ('Instagram', 'Instagram'),
        ('X', 'X'),
        ('Tiktok', 'Tiktok'),
        ('Linkedin', 'Linkedin'),
        ('Youtube', 'Youtube'),
    )
    type = models.CharField(max_length=20, choices=TYPE_CHOICES)
    username = models.CharField(max_length=50, blank=True)
    link = models.URLField(blank=True)
    addressbook = models.ForeignKey(AddressBook, on_delete=models.CASCADE, null=True)

