import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm'
import { UserModifiableEntity } from '../entity'
import { Category } from './category.model'
import { MenuItem } from './menu.model'

@Entity()
export class MenuItemCategory extends UserModifiableEntity<MenuItemCategory> {
	@ManyToOne(() => MenuItem, { nullable: false })
	@JoinColumn()
	item: MenuItem

	@ManyToOne(() => Category, { nullable: false })
	@JoinColumn()
	category: Category

	/**
	 * The position at which item is displayed on Menu within the category
	 */
	@Column({
		type: 'integer',
		nullable: false,
	})
	sortOrder: number

	/**
	 * True if the item is visible in the menu within this category
	 */
	@Column({
		type: 'boolean',
		nullable: false,
		default: true,
	})
	isVisible: boolean
}
