from django.db import models

from module_iam.models import BaseModel, IAmPrincipal

# Create your models here.

class ContactUs(BaseModel):
    name = models.CharField(max_length=100, blank=True, null=True)
    email_address = models.EmailField()
    mobile_number = models.CharField(max_length=15, blank=True, null=True)
    subject = models.CharField(max_length=200)
    message = models.TextField()
    reply = models.TextField(blank=True, null=True)

    class Meta:
        db_table = "contact_us"


class Feedback(BaseModel):
    principal = models.ForeignKey(
        IAmPrincipal,
        on_delete=models.SET_NULL,
        null=True,
        blank=True,
        related_name="feedbacks",
        help_text="User associated with this feedback",
    )
    email = models.EmailField(null=True, blank=True, help_text="Email address of the feedback provider")
    comment = models.TextField(help_text="Feedback comment")
    feedback_reaction = models.CharField(
        max_length=20,
        null=True,
        blank=True,
        help_text="Reaction associated with the feedback",
    )

    class Meta:
        db_table = "feedback"

    def __str__(self):
        return f"Author: {self.principal}, Comment: {self.comment}"
