from django.db import models
from django.utils import timezone

from at_django_boilerplate.utils.mixins import UUIDMixin



class FeedbackModel(UUIDMixin):
    user = models.ForeignKey('accounts.CustomUser',related_name='feedback_from',null=True,blank=True,on_delete=models.DO_NOTHING)
    email = models.EmailField(null=True,blank=True)
    phone = models.CharField(max_length=20, null=True, blank=True)  # Corrected
    name = models.CharField(max_length=255, blank=True, null=True)
    to = models.ForeignKey('accounts.CustomUser',related_name='feedbacks',null=True,blank=True,on_delete=models.DO_NOTHING)
    is_junk = models.BooleanField(default= False)
    
    subject = models.TextField(null=True,blank=True)
    message = models.TextField(null=True,blank=True)

    created_at = models.DateTimeField(default=timezone.now)  


# communications/models.py

class AppointmentModel(UUIDMixin):
    MEETING_CHOICES = (
        ('business-consultant', 'Meet to Lawyer'),
        ('compliance-specialist', 'Meet to CA'),
        ('incorporation-expert', 'Meet to Secretary'),
    )

    STATUS_CHOICES = (
        ('pending', 'Pending'),
        ('contacted', 'Contacted'),
        ('in_process', 'In Process'),
        ('rescheduled', 'Rescheduled'),
        ('completed', 'Completed'),
        ('cancelled', 'Cancelled'),
    )

    user = models.ForeignKey(
        'accounts.CustomUser',
        related_name='appointments',
        null=True,
        blank=True,
        on_delete=models.DO_NOTHING
    )
    full_name = models.CharField(max_length=255)
    email = models.EmailField()
    phone = models.CharField(max_length=20)
    meeting_with = models.CharField(max_length=50, choices=MEETING_CHOICES)
    appointment_datetime = models.DateTimeField()
    notes = models.TextField(blank=True, null=True)
    
    status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')

    created_at = models.DateTimeField(auto_now_add=True)


    def __str__(self):
        return f"APP-{self.pk:06d} - {self.full_name}"

    class Meta:
        ordering = ['-appointment_datetime']