import { Entity, Property, ManyToOne, Unique } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
import { NotifTitleEnum } from '../interfaces/notification.interface';
import { NotifChannelEnum } from '../interfaces/notification.interface';

@Entity({ tableName: 'notification_preferences' })
@Unique({ properties: ['restaurant', 'title'] })
export class NotificationPreference extends BaseEntity {
  @ManyToOne(() => Restaurant)
  restaurant!: Restaurant;

  @Property()
  title!: NotifTitleEnum;

  @Property({ type: 'json' })
  channels: NotifChannelEnum[] = [];
}
