package dev.lions.models;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table (name = "contacts")
public class Contact {
  @Id
  @GeneratedValue (strategy = GenerationType.IDENTITY)
  private Long id;

  @NotNull
  @Size (min = 2, max = 100)
  private String name;

  @NotNull
  @jakarta.validation.constraints.Email
  private String email;

  @Size (max = 100)
  private String company;

  @Size (max = 20)
  private String phone;

  @NotNull
  @Size (min = 3, max = 200)
  private String subject;

  @NotNull
  @Column (columnDefinition = "TEXT")
  private String message;

  @NotNull
  @Enumerated (EnumType.STRING)
  private ContactStatus status;

  @NotNull
  private LocalDateTime submitDate;

  private LocalDateTime processDate;

  @Size (max = 500)
  private String internalNotes;

  public Contact(String name, String email, String subject, String message) {
    this.name = name;
    this.email = email;
    this.subject = subject;
    this.message = message;
    this.status = ContactStatus.NEW;
    this.submitDate = LocalDateTime.now();
  }
}
