import { Customer } from "src/modules/customers/entities/customer.entity"
import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
} from "typeorm"

@Entity("customer_notifications")
export class CustomerNotification {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: "int" })
  customer_id: number

  @ManyToOne(() => Customer, (customer) => customer.customerNotifications)
  @JoinColumn({ name: "customer_id" })
  customer: Customer

  @Column({ type: "varchar", length: 255, nullable: false })
  title: string

  @Column({ type: "text", nullable: false })
  message: string

  @Column({ type: "json", nullable: true })
  data: any

  @Column({ type: "boolean", default: false })
  is_read: boolean

  @CreateDateColumn({
    type: "timestamp",
    nullable: true,
    default: () => "NOW()",
  })
  created_at: Date
}
