import { Entity, Property, ManyToOne, Enum } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
import { User } from '../../users/entities/user.entity';
import { NotifTitleEnum } from '../interfaces/notification.interface';
import { Admin } from 'src/modules/admin/entities/admin.entity';

@Entity({ tableName: 'notifications' })
export class Notification extends BaseEntity {
  @ManyToOne(() => Restaurant)
  restaurant!: Restaurant;

  @ManyToOne(() => User, { nullable: true })
  user?: User;

  @ManyToOne(() => Admin, { nullable: true })
  admin?: Admin;

  @Enum(() => NotifTitleEnum)
  title!: NotifTitleEnum;

  @Property()
  content!: string;

  @Property({ nullable: true })
  seenAt?: Date;
}
