from django.contrib.auth.models import AbstractUser
from django.db import models

class User(AbstractUser):
    class Role(models.TextChoices):
        COMPANY = "COMPANY", "Company"
        INFLUENCER = "INFLUENCER", "Influencer"

    role = models.CharField(max_length=50, choices=Role.choices)

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    bio = models.TextField(blank=True)
    profile_picture = models.ImageField(upload_to='profile_pictures/', blank=True, null=True)

    def __str__(self):
        return self.user.username

class SocialProfile(models.Model):
    profile = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='social_profiles')
    platform = models.CharField(max_length=255)
    handle = models.CharField(max_length=255)
    url = models.URLField()

    def __str__(self):
        return f'{self.profile.user.username} - {self.platform}'
